1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6 isPyPy,
7
8 # build-system
9 flit-core,
10
11 # dependencies
12 babel,
13 alabaster,
14 docutils,
15 imagesize,
16 importlib-metadata,
17 jinja2,
18 packaging,
19 pygments,
20 requests,
21 snowballstemmer,
22 sphinxcontrib-applehelp,
23 sphinxcontrib-devhelp,
24 sphinxcontrib-htmlhelp,
25 sphinxcontrib-jsmath,
26 sphinxcontrib-qthelp,
27 sphinxcontrib-serializinghtml,
28 sphinxcontrib-websupport,
29 tomli,
30
31 # check phase
32 defusedxml,
33 filelock,
34 html5lib,
35 pytestCheckHook,
36 pytest-xdist,
37}:
38
39buildPythonPackage rec {
40 pname = "sphinx";
41 version = "7.3.7";
42 format = "pyproject";
43 disabled = pythonOlder "3.9";
44
45 src = fetchFromGitHub {
46 owner = "sphinx-doc";
47 repo = "sphinx";
48 rev = "refs/tags/v${version}";
49 postFetch = ''
50 # Change ä to æ in file names, since ä can be encoded multiple ways on different
51 # filesystems, leading to different hashes on different platforms.
52 cd "$out";
53 mv tests/roots/test-images/{testimäge,testimæge}.png
54 sed -i 's/testimäge/testimæge/g' tests/{test_build*.py,roots/test-images/index.rst}
55 '';
56 hash = "sha256-XGGRWEvd1SbQsK8W5yxDzBd5hlvXcDzr8t5Qa6skH/M=";
57 };
58
59 build-system = [ flit-core ];
60
61 dependencies =
62 [
63 alabaster
64 babel
65 docutils
66 imagesize
67 jinja2
68 packaging
69 pygments
70 requests
71 snowballstemmer
72 sphinxcontrib-applehelp
73 sphinxcontrib-devhelp
74 sphinxcontrib-htmlhelp
75 sphinxcontrib-jsmath
76 sphinxcontrib-qthelp
77 sphinxcontrib-serializinghtml
78 # extra[docs]
79 sphinxcontrib-websupport
80 ]
81 ++ lib.optionals (pythonOlder "3.11") [ tomli ]
82 ++ lib.optionals (pythonOlder "3.10") [ importlib-metadata ];
83
84 __darwinAllowLocalNetworking = true;
85
86 nativeCheckInputs = [
87 defusedxml
88 filelock
89 html5lib
90 pytestCheckHook
91 pytest-xdist
92 ];
93
94 preCheck = ''
95 export HOME=$TMPDIR
96 '';
97
98 disabledTests =
99 [
100 # requires network access
101 "test_latex_images"
102 # racy
103 "test_defaults"
104 "test_check_link_response_only"
105 "test_anchors_ignored_for_url"
106 "test_autodoc_default_options"
107 "test_too_many_requests_retry_after_int_delay"
108 # racy with pytest-xdist
109 "test_domain_cpp_build_semicolon"
110 "test_class_alias"
111 "test_class_alias_having_doccomment"
112 "test_class_alias_for_imported_object_having_doccomment"
113 "test_decorators"
114 # requires cython_0, but fails miserably on 3.11
115 "test_cython"
116 # Could not fetch remote image: http://localhost:7777/sphinx.png
117 "test_copy_images"
118 ]
119 ++ lib.optionals isPyPy [
120 # PyPy has not __builtins__ which get asserted
121 # https://doc.pypy.org/en/latest/cpython_differences.html#miscellaneous
122 "test_autosummary_generate_content_for_module"
123 "test_autosummary_generate_content_for_module_skipped"
124 # internals are asserted which are sightly different in PyPy
125 "test_autodoc_inherited_members_None"
126 "test_automethod_for_builtin"
127 "test_builtin_function"
128 "test_isattributedescriptor"
129 "test_methoddescriptor"
130 "test_partialfunction"
131 ];
132
133 meta = {
134 description = "Python documentation generator";
135 longDescription = ''
136 Sphinx makes it easy to create intelligent and beautiful documentation.
137
138 Here are some of Sphinx’s major features:
139 - Output formats: HTML (including Windows HTML Help), LaTeX (for printable
140 PDF versions), ePub, Texinfo, manual pages, plain text
141 - Extensive cross-references: semantic markup and automatic links for
142 functions, classes, citations, glossary terms and similar pieces of
143 information
144 - Hierarchical structure: easy definition of a document tree, with
145 automatic links to siblings, parents and children
146 - Automatic indices: general index as well as a language-specific module
147 indices
148 - Code handling: automatic highlighting using the Pygments highlighter
149 - Extensions: automatic testing of code snippets, inclusion of docstrings
150 from Python modules (API docs) via built-in extensions, and much more
151 functionality via third-party extensions.
152 - Themes: modify the look and feel of outputs via creating themes, and
153 re-use many third-party themes.
154 - Contributed extensions: dozens of extensions contributed by users; most
155 of them installable from PyPI.
156
157 Sphinx uses the reStructuredText markup language by default, and can read
158 MyST markdown via third-party extensions. Both of these are powerful and
159 straightforward to use, and have functionality for complex documentation
160 and publishing workflows. They both build upon Docutils to parse and write
161 documents.
162 '';
163 homepage = "https://www.sphinx-doc.org";
164 changelog = "https://www.sphinx-doc.org/en/master/changes.html";
165 license = lib.licenses.bsd3;
166 maintainers = lib.teams.sphinx.members;
167 };
168}