1{ stdenv
2, lib
3, buildPythonPackage
4, pythonOlder
5, fetchFromGitHub
6, fetchpatch
7
8# nativeBuildInputs
9, flit-core
10
11# propagatedBuildInputs
12, babel
13, alabaster
14, docutils
15, imagesize
16, importlib-metadata
17, jinja2
18, packaging
19, pygments
20, requests
21, snowballstemmer
22, sphinxcontrib-apidoc
23, sphinxcontrib-applehelp
24, sphinxcontrib-devhelp
25, sphinxcontrib-htmlhelp
26, sphinxcontrib-jsmath
27, sphinxcontrib-qthelp
28, sphinxcontrib-serializinghtml
29, sphinxcontrib-websupport
30
31# check phase
32, cython
33, html5lib
34, pytestCheckHook
35, typed-ast
36}:
37
38buildPythonPackage rec {
39 pname = "sphinx";
40 version = "5.3.0";
41 format = "pyproject";
42
43 disabled = pythonOlder "3.6";
44
45 src = fetchFromGitHub {
46 owner = "sphinx-doc";
47 repo = pname;
48 rev = "refs/tags/v${version}";
49 hash = "sha256-80bVg1rfBebgSOKbWkzP84vpm39iLgM8lWlVD64nSsQ=";
50 postFetch = ''
51 cd $out
52 mv tests/roots/test-images/testimäge.png \
53 tests/roots/test-images/testimæge.png
54 patch -p1 < ${./0001-test-images-Use-normalization-equivalent-character.patch}
55 '';
56 };
57
58 nativeBuildInputs = [
59 flit-core
60 ];
61
62 propagatedBuildInputs = [
63 babel
64 alabaster
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 # extra plugins which are otherwise not found by sphinx-build
82 sphinxcontrib-apidoc
83 ] ++ lib.optionals (pythonOlder "3.10") [
84 importlib-metadata
85 ];
86
87 nativeCheckInputs = [
88 cython
89 html5lib
90 pytestCheckHook
91 ] ++ lib.optionals (pythonOlder "3.8") [
92 typed-ast
93 ];
94
95 preCheck = ''
96 export HOME=$(mktemp -d)
97 '';
98
99 disabledTests = [
100 # requires network access
101 "test_anchors_ignored"
102 "test_defaults"
103 "test_defaults_json"
104 "test_latex_images"
105
106 # requires imagemagick (increases build closure size), doesn't
107 # test anything substantial
108 "test_ext_imgconverter"
109
110 # fails with pygments 2.14
111 # TODO remove for sphinx 6
112 "test_viewcode"
113 "test_additional_targets_should_be_translated"
114 "test_additional_targets_should_not_be_translated"
115
116 # sphinx.errors.VersionRequirementError: The alabaster extension
117 # used by this project needs at least Sphinx v1.6; it therefore
118 # cannot be built with this version.
119 "test_needs_sphinx"
120
121 # Likely due to pygments 2.14 update
122 # AssertionError: assert '5:11:17\u202fAM' == '5:11:17 AM'
123 "test_format_date"
124 ] ++ lib.optionals stdenv.isDarwin [
125 # Due to lack of network sandboxing can't guarantee port 7777 isn't bound
126 "test_inspect_main_url"
127 "test_auth_header_uses_first_match"
128 "test_linkcheck_allowed_redirects"
129 "test_linkcheck_request_headers"
130 "test_linkcheck_request_headers_no_slash"
131 "test_follows_redirects_on_HEAD"
132 "test_get_after_head_raises_connection_error"
133 "test_invalid_ssl"
134 "test_connect_to_selfsigned_with_tls_verify_false"
135 "test_connect_to_selfsigned_with_tls_cacerts"
136 "test_connect_to_selfsigned_with_requests_env_var"
137 "test_connect_to_selfsigned_nonexistent_cert_file"
138 "test_TooManyRedirects_on_HEAD"
139 "test_too_many_requests_retry_after_int_del"
140 "test_too_many_requests_retry_after_HTTP_date"
141 "test_too_many_requests_retry_after_without_header"
142 "test_too_many_requests_user_timeout"
143 "test_raises_for_invalid_status"
144 "test_auth_header_no_match"
145 "test_follows_redirects_on_GET"
146 "test_connect_to_selfsigned_fails"
147 ];
148
149 meta = with lib; {
150 description = "Python documentation generator";
151 longDescription = ''
152 A tool that makes it easy to create intelligent and beautiful
153 documentation for Python projects
154 '';
155 homepage = "https://www.sphinx-doc.org";
156 license = licenses.bsd3;
157 maintainers = teams.sphinx.members;
158 };
159}