##// END OF EJS Templates
Fix compatibility with the latest Sphinx 8 (#14596)...
M Bussonnier -
r28971:c1628686 merge
parent child Browse files
Show More
@@ -1,272 +1,272
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 #
2 #
3 # IPython documentation build configuration file.
3 # IPython documentation build configuration file.
4
4
5 # NOTE: This file has been edited manually from the auto-generated one from
5 # NOTE: This file has been edited manually from the auto-generated one from
6 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
6 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
7 # needed, generate a scratch one and merge by hand any new fields needed.
7 # needed, generate a scratch one and merge by hand any new fields needed.
8
8
9 #
9 #
10 # This file is execfile()d with the current directory set to its containing dir.
10 # This file is execfile()d with the current directory set to its containing dir.
11 #
11 #
12 # The contents of this file are pickled, so don't put values in the namespace
12 # The contents of this file are pickled, so don't put values in the namespace
13 # that aren't pickleable (module imports are okay, they're removed automatically).
13 # that aren't pickleable (module imports are okay, they're removed automatically).
14 #
14 #
15 # All configuration values have a default value; values that are commented out
15 # All configuration values have a default value; values that are commented out
16 # serve to show the default value.
16 # serve to show the default value.
17
17
18
18
19 import sys, os
19 import sys, os
20 from pathlib import Path
20 from pathlib import Path
21
21
22 if sys.version_info > (3, 11):
22 if sys.version_info > (3, 11):
23 import tomllib
23 import tomllib
24 else:
24 else:
25 import tomli as tomllib
25 import tomli as tomllib
26
26
27 with open("./sphinx.toml", "rb") as f:
27 with open("./sphinx.toml", "rb") as f:
28 config = tomllib.load(f)
28 config = tomllib.load(f)
29
29
30 # https://read-the-docs.readthedocs.io/en/latest/faq.html
30 # https://read-the-docs.readthedocs.io/en/latest/faq.html
31 ON_RTD = os.environ.get("READTHEDOCS", None) == "True"
31 ON_RTD = os.environ.get("READTHEDOCS", None) == "True"
32
32
33 if ON_RTD:
33 if ON_RTD:
34 tags.add("rtd")
34 tags.add("rtd")
35
35
36 # RTD doesn't use the Makefile, so re-run autogen_{things}.py here.
36 # RTD doesn't use the Makefile, so re-run autogen_{things}.py here.
37 for name in ("config", "api", "magics", "shortcuts"):
37 for name in ("config", "api", "magics", "shortcuts"):
38 fname = Path("autogen_{}.py".format(name))
38 fname = Path("autogen_{}.py".format(name))
39 fpath = (Path(__file__).parent).joinpath("..", fname)
39 fpath = (Path(__file__).parent).joinpath("..", fname)
40 with open(fpath, encoding="utf-8") as f:
40 with open(fpath, encoding="utf-8") as f:
41 exec(
41 exec(
42 compile(f.read(), fname, "exec"),
42 compile(f.read(), fname, "exec"),
43 {
43 {
44 "__file__": fpath,
44 "__file__": fpath,
45 "__name__": "__main__",
45 "__name__": "__main__",
46 },
46 },
47 )
47 )
48 import sphinx_rtd_theme
48 import sphinx_rtd_theme
49
49
50 # Allow Python scripts to change behaviour during sphinx run
50 # Allow Python scripts to change behaviour during sphinx run
51 os.environ["IN_SPHINX_RUN"] = "True"
51 os.environ["IN_SPHINX_RUN"] = "True"
52
52
53 autodoc_type_aliases = {
53 autodoc_type_aliases = {
54 "Matcher": " IPython.core.completer.Matcher",
54 "Matcher": " IPython.core.completer.Matcher",
55 "MatcherAPIv1": " IPython.core.completer.MatcherAPIv1",
55 "MatcherAPIv1": " IPython.core.completer.MatcherAPIv1",
56 }
56 }
57
57
58 # If your extensions are in another directory, add it here. If the directory
58 # If your extensions are in another directory, add it here. If the directory
59 # is relative to the documentation root, use os.path.abspath to make it
59 # is relative to the documentation root, use os.path.abspath to make it
60 # absolute, like shown here.
60 # absolute, like shown here.
61 sys.path.insert(0, os.path.abspath("../sphinxext"))
61 sys.path.insert(0, os.path.abspath("../sphinxext"))
62
62
63 # We load the ipython release info into a dict by explicit execution
63 # We load the ipython release info into a dict by explicit execution
64 iprelease = {}
64 iprelease = {}
65 exec(
65 exec(
66 compile(
66 compile(
67 open("../../IPython/core/release.py", encoding="utf-8").read(),
67 open("../../IPython/core/release.py", encoding="utf-8").read(),
68 "../../IPython/core/release.py",
68 "../../IPython/core/release.py",
69 "exec",
69 "exec",
70 ),
70 ),
71 iprelease,
71 iprelease,
72 )
72 )
73
73
74 # General configuration
74 # General configuration
75 # ---------------------
75 # ---------------------
76
76
77 # - template_path: Add any paths that contain templates here, relative to this directory.
77 # - template_path: Add any paths that contain templates here, relative to this directory.
78 # - master_doc: The master toctree document.
78 # - master_doc: The master toctree document.
79 # - project
79 # - project
80 # - copyright
80 # - copyright
81 # - github_project_url
81 # - github_project_url
82 # - source_suffix = config["sphinx"]["source_suffix"]
82 # - source_suffix = config["sphinx"]["source_suffix"]
83 # - exclude_patterns:
83 # - exclude_patterns:
84 # Exclude these glob-style patterns when looking for source files.
84 # Exclude these glob-style patterns when looking for source files.
85 # They are relative to the source/ directory.
85 # They are relative to the source/ directory.
86 # - pygments_style: The name of the Pygments (syntax highlighting) style to use.
86 # - pygments_style: The name of the Pygments (syntax highlighting) style to use.
87 # - extensions:
87 # - extensions:
88 # Add any Sphinx extension module names here, as strings. They can be extensions
88 # Add any Sphinx extension module names here, as strings. They can be extensions
89 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
89 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
90 # - default_role
90 # - default_role
91 # - modindex_common_prefix
91 # - modindex_common_prefix
92
92
93 locals().update(config["sphinx"])
93 locals().update(config["sphinx"])
94
94
95 try:
95 try:
96 from intersphinx_registry import get_intersphinx_mapping
96 from intersphinx_registry import get_intersphinx_mapping
97
97
98 intersphinx_mapping = get_intersphinx_mapping(
98 intersphinx_mapping = get_intersphinx_mapping(
99 packages={
99 packages={
100 "python",
100 "python",
101 "rpy2",
101 "rpy2",
102 "jupyterclient",
102 "jupyterclient",
103 "jupyter",
103 "jupyter",
104 "jedi",
104 "jedi",
105 "traitlets",
105 "traitlets",
106 "ipykernel",
106 "ipykernel",
107 "prompt_toolkit",
107 "prompt_toolkit",
108 "ipywidgets",
108 "ipywidgets",
109 "ipyparallel",
109 "ipyparallel",
110 "pip",
110 "pip",
111 }
111 }
112 )
112 )
113
113
114 except ModuleNotFoundError:
114 except ModuleNotFoundError:
115 # In case intersphinx_registry is not yet packages on current platform
115 # In case intersphinx_registry is not yet packages on current platform
116 # as it is quite recent.
116 # as it is quite recent.
117 print("/!\\ intersphinx_registry not installed, relying on local mapping.")
117 print("/!\\ intersphinx_registry not installed, relying on local mapping.")
118 intersphinx_mapping = config["intersphinx_mapping"]
118 intersphinx_mapping = config["intersphinx_mapping"]
119 for k, v in intersphinx_mapping.items():
119 for k, v in intersphinx_mapping.items():
120 intersphinx_mapping[k] = tuple(
120 intersphinx_mapping[k] = tuple(
121 [intersphinx_mapping[k]["url"], intersphinx_mapping[k]["fallback"]]
121 [intersphinx_mapping[k]["url"], intersphinx_mapping[k]["fallback"] or None]
122 )
122 )
123
123
124
124
125 # numpydoc config
125 # numpydoc config
126 numpydoc_show_class_members = config["numpydoc"][
126 numpydoc_show_class_members = config["numpydoc"][
127 "numpydoc_show_class_members"
127 "numpydoc_show_class_members"
128 ] # Otherwise Sphinx emits thousands of warnings
128 ] # Otherwise Sphinx emits thousands of warnings
129 numpydoc_class_members_toctree = config["numpydoc"]["numpydoc_class_members_toctree"]
129 numpydoc_class_members_toctree = config["numpydoc"]["numpydoc_class_members_toctree"]
130 warning_is_error = config["numpydoc"]["warning_is_error"]
130 warning_is_error = config["numpydoc"]["warning_is_error"]
131
131
132 # Options for HTML output
132 # Options for HTML output
133 # -----------------------
133 # -----------------------
134 # - html_theme
134 # - html_theme
135 # - html_static_path
135 # - html_static_path
136 # Add any paths that contain custom static files (such as style sheets) here,
136 # Add any paths that contain custom static files (such as style sheets) here,
137 # relative to this directory. They are copied after the builtin static files,
137 # relative to this directory. They are copied after the builtin static files,
138 # so a file named "default.css" will overwrite the builtin "default.css".
138 # so a file named "default.css" will overwrite the builtin "default.css".
139 # Favicon needs the directory name
139 # Favicon needs the directory name
140 # - html_favicon
140 # - html_favicon
141 # - html_last_updated_fmt = config["html"]["html_last_updated_fmt"]
141 # - html_last_updated_fmt = config["html"]["html_last_updated_fmt"]
142 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
142 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
143 # using the given strftime format.
143 # using the given strftime format.
144 # Output file base name for HTML help builder.
144 # Output file base name for HTML help builder.
145 # - htmlhelp_basename
145 # - htmlhelp_basename
146 locals().update(config["html"])
146 locals().update(config["html"])
147
147
148 # Additional templates that should be rendered to pages, maps page names to
148 # Additional templates that should be rendered to pages, maps page names to
149 # template names.
149 # template names.
150 html_additional_pages = {}
150 html_additional_pages = {}
151 for item in config["html"]["html_additional_pages"]:
151 for item in config["html"]["html_additional_pages"]:
152 html_additional_pages[item[0]] = item[1]
152 html_additional_pages[item[0]] = item[1]
153
153
154 # Options for LaTeX output
154 # Options for LaTeX output
155 # ------------------------
155 # ------------------------
156
156
157 # Grouping the document tree into LaTeX files. List of tuples
157 # Grouping the document tree into LaTeX files. List of tuples
158 # (source start file, target name, title, author, document class [howto/manual]).
158 # (source start file, target name, title, author, document class [howto/manual]).
159 latex_documents = []
159 latex_documents = []
160 for item in config["latex"]["latex_documents"]:
160 for item in config["latex"]["latex_documents"]:
161 latex_documents.append(tuple(item))
161 latex_documents.append(tuple(item))
162 # If false, no module index is generated.
162 # If false, no module index is generated.
163 latex_use_modindex = config["latex"]["latex_use_modindex"]
163 latex_use_modindex = config["latex"]["latex_use_modindex"]
164 # The font size ('10pt', '11pt' or '12pt').
164 # The font size ('10pt', '11pt' or '12pt').
165 latex_font_size = config["latex"]["latex_font_size"]
165 latex_font_size = config["latex"]["latex_font_size"]
166
166
167 # Options for texinfo output
167 # Options for texinfo output
168 # --------------------------
168 # --------------------------
169 texinfo_documents = [
169 texinfo_documents = [
170 (
170 (
171 master_doc,
171 master_doc,
172 "ipython",
172 "ipython",
173 "IPython Documentation",
173 "IPython Documentation",
174 "The IPython Development Team",
174 "The IPython Development Team",
175 "IPython",
175 "IPython",
176 "IPython Documentation",
176 "IPython Documentation",
177 "Programming",
177 "Programming",
178 1,
178 1,
179 ),
179 ),
180 ]
180 ]
181
181
182 #########################################################################
182 #########################################################################
183 # Custom configuration
183 # Custom configuration
184 # The default replacements for |version| and |release|, also used in various
184 # The default replacements for |version| and |release|, also used in various
185 # other places throughout the built documents.
185 # other places throughout the built documents.
186 #
186 #
187 # The full version, including alpha/beta/rc tags.
187 # The full version, including alpha/beta/rc tags.
188 release = "%s" % iprelease["version"]
188 release = "%s" % iprelease["version"]
189 # Just the X.Y.Z part, no '-dev'
189 # Just the X.Y.Z part, no '-dev'
190 version = iprelease["version"].split("-", 1)[0]
190 version = iprelease["version"].split("-", 1)[0]
191
191
192 # There are two options for replacing |today|: either, you set today to some
192 # There are two options for replacing |today|: either, you set today to some
193 # non-false value, then it is used:
193 # non-false value, then it is used:
194 # today = ''
194 # today = ''
195 # Else, today_fmt is used as the format for a strftime call.
195 # Else, today_fmt is used as the format for a strftime call.
196 today_fmt = "%B %d, %Y"
196 today_fmt = "%B %d, %Y"
197
197
198 rst_prolog = ""
198 rst_prolog = ""
199
199
200
200
201 def is_stable(extra):
201 def is_stable(extra):
202 for ext in {"dev", "b", "rc"}:
202 for ext in {"dev", "b", "rc"}:
203 if ext in extra:
203 if ext in extra:
204 return False
204 return False
205 return True
205 return True
206
206
207
207
208 if is_stable(iprelease["_version_extra"]):
208 if is_stable(iprelease["_version_extra"]):
209 tags.add("ipystable")
209 tags.add("ipystable")
210 print("Adding Tag: ipystable")
210 print("Adding Tag: ipystable")
211 else:
211 else:
212 tags.add("ipydev")
212 tags.add("ipydev")
213 print("Adding Tag: ipydev")
213 print("Adding Tag: ipydev")
214 rst_prolog += """
214 rst_prolog += """
215 .. warning::
215 .. warning::
216
216
217 This documentation covers a development version of IPython. The development
217 This documentation covers a development version of IPython. The development
218 version may differ significantly from the latest stable release.
218 version may differ significantly from the latest stable release.
219 """
219 """
220
220
221 rst_prolog += """
221 rst_prolog += """
222 .. important::
222 .. important::
223
223
224 This documentation covers IPython versions 6.0 and higher. Beginning with
224 This documentation covers IPython versions 6.0 and higher. Beginning with
225 version 6.0, IPython stopped supporting compatibility with Python versions
225 version 6.0, IPython stopped supporting compatibility with Python versions
226 lower than 3.3 including all versions of Python 2.7.
226 lower than 3.3 including all versions of Python 2.7.
227
227
228 If you are looking for an IPython version compatible with Python 2.7,
228 If you are looking for an IPython version compatible with Python 2.7,
229 please use the IPython 5.x LTS release and refer to its documentation (LTS
229 please use the IPython 5.x LTS release and refer to its documentation (LTS
230 is the long term support release).
230 is the long term support release).
231
231
232 """
232 """
233
233
234 import logging
234 import logging
235
235
236
236
237 class ConfigtraitFilter(logging.Filter):
237 class ConfigtraitFilter(logging.Filter):
238 """
238 """
239 This is a filter to remove in sphinx 3+ the error about config traits being duplicated.
239 This is a filter to remove in sphinx 3+ the error about config traits being duplicated.
240
240
241 As we autogenerate configuration traits from, subclasses have lots of
241 As we autogenerate configuration traits from, subclasses have lots of
242 duplication and we want to silence them. Indeed we build on travis with
242 duplication and we want to silence them. Indeed we build on travis with
243 warnings-as-error set to True, so those duplicate items make the build fail.
243 warnings-as-error set to True, so those duplicate items make the build fail.
244 """
244 """
245
245
246 def filter(self, record):
246 def filter(self, record):
247 if (
247 if (
248 record.args
248 record.args
249 and record.args[0] == "configtrait"
249 and record.args[0] == "configtrait"
250 and "duplicate" in record.msg
250 and "duplicate" in record.msg
251 ):
251 ):
252 return False
252 return False
253 return True
253 return True
254
254
255
255
256 ct_filter = ConfigtraitFilter()
256 ct_filter = ConfigtraitFilter()
257
257
258 import sphinx.util
258 import sphinx.util
259
259
260 logger = sphinx.util.logging.getLogger("sphinx.domains.std").logger
260 logger = sphinx.util.logging.getLogger("sphinx.domains.std").logger
261 logger.addFilter(ct_filter)
261 logger.addFilter(ct_filter)
262
262
263
263
264 def setup(app):
264 def setup(app):
265 app.add_css_file("theme_overrides.css")
265 app.add_css_file("theme_overrides.css")
266
266
267
267
268 # Cleanup
268 # Cleanup
269 # -------
269 # -------
270 # delete release info to avoid pickling errors from sphinx
270 # delete release info to avoid pickling errors from sphinx
271
271
272 del iprelease
272 del iprelease
General Comments 0
You need to be logged in to leave comments. Login now