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