1{ stdenv
2, lib
3, buildPythonPackage
4, pythonOlder
5, fetchFromGitHub
6, fetchpatch
7
8# propagatedBuildInputs
9, babel
10, alabaster
11, docutils
12, imagesize
13, importlib-metadata
14, jinja2
15, packaging
16, pygments
17, requests
18, snowballstemmer
19, sphinxcontrib-apidoc
20, sphinxcontrib-applehelp
21, sphinxcontrib-devhelp
22, sphinxcontrib-htmlhelp
23, sphinxcontrib-jsmath
24, sphinxcontrib-qthelp
25, sphinxcontrib-serializinghtml
26, sphinxcontrib-websupport
27
28# check phase
29, cython
30, html5lib
31, pytestCheckHook
32, typed-ast
33}:
34
35buildPythonPackage rec {
36 pname = "sphinx";
37 version = "5.1.1";
38 format = "setuptools";
39
40 disabled = pythonOlder "3.6";
41
42 src = fetchFromGitHub {
43 owner = "sphinx-doc";
44 repo = pname;
45 rev = "refs/tags/v${version}";
46 hash = "sha256-dTgQNMRIn7ETm+1HgviOkWWOCmLX7Ez6DM9ChlI32mY=";
47 postFetch = ''
48 cd $out
49 mv tests/roots/test-images/testimäge.png \
50 tests/roots/test-images/testimæge.png
51 patch -p1 < ${./0001-test-images-Use-normalization-equivalent-character.patch}
52 '';
53 };
54
55 postPatch = ''
56 # remove impurity caused by date inclusion
57 # https://github.com/sphinx-doc/sphinx/blob/master/setup.cfg#L4-L6
58 substituteInPlace setup.cfg \
59 --replace "tag_build = .dev" "" \
60 --replace "tag_date = true" ""
61 '';
62
63 propagatedBuildInputs = [
64 babel
65 alabaster
66 docutils
67 imagesize
68 jinja2
69 packaging
70 pygments
71 requests
72 snowballstemmer
73 sphinxcontrib-applehelp
74 sphinxcontrib-devhelp
75 sphinxcontrib-htmlhelp
76 sphinxcontrib-jsmath
77 sphinxcontrib-qthelp
78 sphinxcontrib-serializinghtml
79 # extra[docs]
80 sphinxcontrib-websupport
81
82 # extra plugins which are otherwise not found by sphinx-build
83 sphinxcontrib-apidoc
84 ] ++ lib.optionals (pythonOlder "3.10") [
85 importlib-metadata
86 ];
87
88 checkInputs = [
89 cython
90 html5lib
91 pytestCheckHook
92 ] ++ lib.optionals (pythonOlder "3.8") [
93 typed-ast
94 ];
95
96 preCheck = ''
97 export HOME=$(mktemp -d)
98 '';
99
100 disabledTests = [
101 # requires network access
102 "test_anchors_ignored"
103 "test_defaults"
104 "test_defaults_json"
105 "test_latex_images"
106
107 # requires imagemagick (increases build closure size), doesn't
108 # test anything substantial
109 "test_ext_imgconverter"
110 ] ++ lib.optionals stdenv.isDarwin [
111 # Due to lack of network sandboxing can't guarantee port 7777 isn't bound
112 "test_inspect_main_url"
113 "test_auth_header_uses_first_match"
114 "test_linkcheck_allowed_redirects"
115 "test_linkcheck_request_headers"
116 "test_linkcheck_request_headers_no_slash"
117 "test_follows_redirects_on_HEAD"
118 "test_get_after_head_raises_connection_error"
119 "test_invalid_ssl"
120 "test_connect_to_selfsigned_with_tls_verify_false"
121 "test_connect_to_selfsigned_with_tls_cacerts"
122 "test_connect_to_selfsigned_with_requests_env_var"
123 "test_connect_to_selfsigned_nonexistent_cert_file"
124 "test_TooManyRedirects_on_HEAD"
125 "test_too_many_requests_retry_after_int_del"
126 "test_too_many_requests_retry_after_HTTP_date"
127 "test_too_many_requests_retry_after_without_header"
128 "test_too_many_requests_user_timeout"
129 "test_raises_for_invalid_status"
130 "test_auth_header_no_match"
131 "test_follows_redirects_on_GET"
132 "test_connect_to_selfsigned_fails"
133 ];
134
135 meta = with lib; {
136 description = "Python documentation generator";
137 longDescription = ''
138 A tool that makes it easy to create intelligent and beautiful
139 documentation for Python projects
140 '';
141 homepage = "https://www.sphinx-doc.org";
142 license = licenses.bsd3;
143 maintainers = teams.sphinx.members;
144 };
145}