1{
2 lib,
3 stdenv,
4 buildPythonApplication,
5 fetchPypi,
6 replaceVars,
7 clang,
8 libclang,
9 pytestCheckHook,
10 pkg-config,
11 cmake,
12 flex,
13 glib,
14 json-glib,
15 libxml2,
16 appdirs,
17 backports-entry-points-selectable,
18 dbus-deviation,
19 faust-cchardet,
20 feedgen,
21 lxml,
22 networkx,
23 pkgconfig,
24 pyyaml,
25 schema,
26 setuptools,
27 toposort,
28 wheezy-template,
29 llvmPackages,
30 gst_all_1,
31}:
32
33buildPythonApplication rec {
34 pname = "hotdoc";
35 version = "0.17.4";
36 pyproject = true;
37
38 src = fetchPypi {
39 inherit pname version;
40 hash = "sha256-xNXf9kfwOqh6HS0GA10oGe3QmbkWNeOy7jkIKTV66fw=";
41 };
42
43 patches = [
44 (replaceVars ./clang.patch {
45 clang = lib.getExe clang;
46 libclang = "${lib.getLib libclang}/lib/libclang${stdenv.hostPlatform.extensions.sharedLibrary}";
47 })
48 ];
49
50 build-system = [ setuptools ];
51
52 nativeBuildInputs = [
53 pkg-config
54 cmake
55 flex
56 ];
57
58 buildInputs = [
59 glib
60 json-glib
61 libxml2.dev
62 ];
63
64 dependencies = [
65 appdirs
66 backports-entry-points-selectable
67 dbus-deviation
68 faust-cchardet
69 feedgen
70 lxml
71 networkx
72 pkgconfig
73 pyyaml
74 schema
75 setuptools # for pkg_resources
76 toposort
77 wheezy-template
78 ];
79
80 nativeCheckInputs = [ pytestCheckHook ];
81
82 # CMake is used to build CMARK, but the build system is still python
83 dontUseCmakeConfigure = true;
84
85 # Ensure C+GI+GST extensions are built and can be imported
86 pythonImportsCheck = [
87 "hotdoc.extensions.c.c_extension"
88 "hotdoc.extensions.gi.gi_extension"
89 "hotdoc.extensions.gst.gst_extension"
90 ];
91
92 pytestFlags = [
93 # Run the tests by package instead of current dir
94 "--pyargs"
95 "hotdoc"
96 ];
97
98 disabledTestPaths = [
99 # Executing hotdoc exits with code 1
100 "tests/test_hotdoc.py::TestHotdoc::test_basic"
101 "tests/test_hotdoc.py::TestHotdoc::test_explicit_conf_file"
102 "tests/test_hotdoc.py::TestHotdoc::test_implicit_conf_file"
103 "tests/test_hotdoc.py::TestHotdoc::test_private_folder"
104 ];
105
106 disabledTests = [
107 # Test does not correctly handle path normalization for test comparison
108 "test_cli_overrides"
109 ]
110 ++ lib.optionals stdenv.hostPlatform.isDarwin [
111 # Test does not correctly handle absolute /home paths on Darwin (even fake ones)
112 "test_index"
113 ];
114
115 # Hardcode libclang paths
116 postPatch = ''
117 substituteInPlace hotdoc/extensions/c/c_extension.py \
118 --replace "shutil.which('llvm-config')" 'True' \
119 --replace "subprocess.check_output(['llvm-config', '--version']).strip().decode()" '"${lib.versions.major llvmPackages.libclang.version}"' \
120 --replace "subprocess.check_output(['llvm-config', '--prefix']).strip().decode()" '"${lib.getLib llvmPackages.libclang}"' \
121 --replace "subprocess.check_output(['llvm-config', '--libdir']).strip().decode()" '"${lib.getLib llvmPackages.libclang}/lib"'
122 '';
123
124 # Make pytest run from a temp dir to have it pick up installed package for cmark
125 preCheck = ''
126 pushd $TMPDIR
127 '';
128 postCheck = ''
129 popd
130 '';
131
132 passthru.tests = {
133 inherit (gst_all_1) gstreamer gst-plugins-base;
134 };
135
136 meta = with lib; {
137 description = "Tastiest API documentation system";
138 homepage = "https://hotdoc.github.io/";
139 license = [ licenses.lgpl21Plus ];
140 maintainers = [ ];
141 };
142}