summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/sphinx-autodoc2/default.nix
blob: a0cf4db57cab7c568517760b4ad52414628b642e (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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  fetchDebianPatch,

  flit-core,

  astroid,
  typing-extensions,
  typer,

  pytestCheckHook,
  pytest-regressions,
  sphinx,
  defusedxml,
}:

buildPythonPackage (finalAttrs: {
  pname = "sphinx-autodoc2";
  version = "0.5.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "sphinx-extensions2";
    repo = "sphinx-autodoc2";
    tag = "v${finalAttrs.version}";
    hash = "sha256-Wu079THK1mHVilD2Fx9dIzuIOOYOXpo/EMxVczNutCI=";
  };

  patches = [
    # compatibility with astroid 4, see: https://github.com/sphinx-extensions2/sphinx-autodoc2/pull/93
    (fetchDebianPatch {
      pname = "python-sphinx-autodoc2";
      inherit (finalAttrs) version;
      debianRevision = "9";
      patch = "astroid-4.patch";
      hash = "sha256-tRWDee30GSQ+AobCAHdtw65B6YyRpzn7kW5rzK7/QOk=";
    })
  ];

  build-system = [ flit-core ];

  dependencies = [
    astroid
    typing-extensions

    # cli deps
    typer
  ]
  ++ typer.optional-dependencies.standard;

  preCheck = ''
    # make sphinx_path an alias of pathlib.Path, since sphinx_path was removed in Sphinx v7.2.0
    substituteInPlace tests/test_render.py --replace-fail \
        'from sphinx.testing.util import path as sphinx_path' \
        'sphinx_path = Path'
  '';

  nativeCheckInputs = [
    pytestCheckHook
    pytest-regressions
    sphinx
    defusedxml
  ];

  disabledTests = [
    # some generated files differ in newer versions of Sphinx
    "test_sphinx_build_directives"
  ];

  pythonImportsCheck = [ "autodoc2" ];

  meta = {
    changelog = "https://github.com/sphinx-extensions2/sphinx-autodoc2/releases/tag/${finalAttrs.src.tag}";
    homepage = "https://github.com/sphinx-extensions2/sphinx-autodoc2";
    description = "Sphinx extension that automatically generates API documentation for your Python packages";
    license = lib.licenses.mit;
    mainProgram = "autodoc2";
    maintainers = with lib.maintainers; [ tomasajt ];
  };
})