summaryrefslogtreecommitdiff
path: root/pkgs/development/tools/hotdoc/default.nix
blob: 64f7538ca37b67f6a13378b24454e3b0b6ee7a49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
{
  lib,
  stdenv,
  buildPythonApplication,
  fetchpatch,
  fetchPypi,
  replaceVars,
  clang,
  libclang,
  pytestCheckHook,
  pkg-config,
  cmake,
  flex,
  glib,
  json-glib,
  libxml2,
  appdirs,
  backports-entry-points-selectable,
  dbus-deviation,
  faust-cchardet,
  feedgen,
  lxml,
  networkx,
  pkgconfig,
  pyyaml,
  schema,
  setuptools,
  toposort,
  wheezy-template,
  llvmPackages,
  gst_all_1,
}:

buildPythonApplication rec {
  pname = "hotdoc";
  version = "0.17.4";
  pyproject = true;

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-xNXf9kfwOqh6HS0GA10oGe3QmbkWNeOy7jkIKTV66fw=";
  };

  patches = [
    (replaceVars ./clang.patch {
      clang = lib.getExe clang;
      libclang = "${lib.getLib libclang}/lib/libclang${stdenv.hostPlatform.extensions.sharedLibrary}";
    })

    # Fix build with gcc15
    (fetchpatch {
      name = "hotdoc-fix-c_comment_scanner-function-prototypes-gcc15.patch";
      url = "https://github.com/hotdoc/hotdoc/commit/adf8518431fafb78c9b47862a0a9a58824b6a421.patch";
      hash = "sha256-5y50Yk+AjV3aSk8H3k9od/Yvy09FyQQOcVOAcstQnw8=";
    })
  ];

  build-system = [ setuptools ];

  nativeBuildInputs = [
    pkg-config
    cmake
    flex
  ];

  buildInputs = [
    glib
    json-glib
    libxml2.dev
  ];

  dependencies = [
    appdirs
    backports-entry-points-selectable
    dbus-deviation
    faust-cchardet
    feedgen
    lxml
    networkx
    pkgconfig
    pyyaml
    schema
    setuptools # for pkg_resources
    toposort
    wheezy-template
  ];

  nativeCheckInputs = [ pytestCheckHook ];

  # CMake is used to build CMARK, but the build system is still python
  dontUseCmakeConfigure = true;

  # Ensure C+GI+GST extensions are built and can be imported
  pythonImportsCheck = [
    "hotdoc.extensions.c.c_extension"
    "hotdoc.extensions.gi.gi_extension"
    "hotdoc.extensions.gst.gst_extension"
  ];

  pytestFlags = [
    # Run the tests by package instead of current dir
    "--pyargs"
    "hotdoc"
  ];

  disabledTestPaths = [
    # Executing hotdoc exits with code 1
    "tests/test_hotdoc.py::TestHotdoc::test_basic"
    "tests/test_hotdoc.py::TestHotdoc::test_explicit_conf_file"
    "tests/test_hotdoc.py::TestHotdoc::test_implicit_conf_file"
    "tests/test_hotdoc.py::TestHotdoc::test_private_folder"
  ];

  disabledTests = [
    # Test does not correctly handle path normalization for test comparison
    "test_cli_overrides"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # Test does not correctly handle absolute /home paths on Darwin (even fake ones)
    "test_index"
  ];

  postPatch =
    # Hardcode libclang paths
    ''
      substituteInPlace hotdoc/extensions/c/c_extension.py \
        --replace "shutil.which('llvm-config')" 'True' \
        --replace "subprocess.check_output(['llvm-config', '--version']).strip().decode()" '"${lib.versions.major llvmPackages.libclang.version}"' \
        --replace "subprocess.check_output(['llvm-config', '--prefix']).strip().decode()" '"${lib.getLib llvmPackages.libclang}"' \
        --replace "subprocess.check_output(['llvm-config', '--libdir']).strip().decode()" '"${lib.getLib llvmPackages.libclang}/lib"'
    ''
    # <https://github.com/MathieuDuponchelle/cmark/pull/2>
    + ''
      patch -p1 -d cmark -i ${./fix-cmake-4.patch}
    '';

  # Make pytest run from a temp dir to have it pick up installed package for cmark
  preCheck = ''
    pushd $TMPDIR
  '';
  postCheck = ''
    popd
  '';

  passthru.tests = {
    inherit (gst_all_1) gstreamer gst-plugins-base;
  };

  meta = {
    description = "Tastiest API documentation system";
    homepage = "https://hotdoc.github.io/";
    license = [ lib.licenses.lgpl21Plus ];
    maintainers = [ ];
  };
}