##// END OF EJS Templates
Moving configuration to sphinx.toml file (#14427)...
M Bussonnier -
r28772:d72dd7f3 merge
parent child Browse files
Show More
@@ -0,0 +1,70 b''
1 title = "Sphinx configuration"
2
3 [sphinx]
4 templates_path = ["_templates"]
5 master_doc = "index"
6 project = "IPython"
7 copyright = "The IPython Development Team"
8 github_project_url = "https://github.com/ipython/ipython"
9 source_suffix = ".rst"
10 exclude_patterns = ["**.ipynb_checkpoints"]
11 pygments_style = "sphinx"
12 extensions = [
13 "sphinx.ext.autodoc",
14 "sphinx.ext.autosummary",
15 "sphinx.ext.doctest",
16 "sphinx.ext.inheritance_diagram",
17 "sphinx.ext.intersphinx",
18 "sphinx.ext.graphviz",
19 "sphinxcontrib.jquery",
20 "IPython.sphinxext.ipython_console_highlighting",
21 "IPython.sphinxext.ipython_directive",
22 "sphinx.ext.napoleon", # to preprocess docstrings
23 "github", # for easy GitHub links
24 "magics",
25 "configtraits",
26 ]
27 default_role = "literal"
28 modindex_common_prefix = ["IPython."]
29
30 [intersphinx_mapping]
31 python = { url = 'https://docs.python.org/3/', fallback = '' }
32 rpy2 = { url = 'https://rpy2.github.io/doc/latest/html/', fallback = '' }
33 jupyterclient = { url = 'https://jupyter-client.readthedocs.io/en/latest/', fallback = '' }
34 jupyter = { url = 'https://jupyter.readthedocs.io/en/latest/', fallback = '' }
35 jedi = { url = 'https://jedi.readthedocs.io/en/latest/', fallback = '' }
36 traitlets = { url = 'https://traitlets.readthedocs.io/en/latest/', fallback = '' }
37 ipykernel = { url = 'https://ipykernel.readthedocs.io/en/latest/', fallback = '' }
38 prompt_toolkit = { url = 'https://python-prompt-toolkit.readthedocs.io/en/stable/', fallback = '' }
39 ipywidgets = { url = 'https://ipywidgets.readthedocs.io/en/stable/', fallback = '' }
40 ipyparallel = { url = 'https://ipyparallel.readthedocs.io/en/stable/', fallback = '' }
41 pip = { url = 'https://pip.pypa.io/en/stable/', fallback = '' }
42
43 [html]
44 html_theme = "sphinx_rtd_theme"
45 html_static_path = ["_static"]
46 html_favicon = "_static/favicon.ico"
47 html_last_updated_fmt = "%b %d, %Y"
48 htmlhelp_basename = "ipythondoc"
49 html_additional_pages = [
50 ["interactive/htmlnotebook", "notebook_redirect.html"],
51 ["interactive/notebook", "notebook_redirect.html"],
52 ["interactive/nbconvert", "notebook_redirect.html"],
53 ["interactive/public_server", "notebook_redirect.html"]
54 ]
55
56 [numpydoc]
57 numpydoc_show_class_members = "False"
58 numpydoc_class_members_toctree = "False"
59 warning_is_error = "True"
60
61 [latex]
62 latex_documents = [
63 ['index', 'ipython.tex', 'IPython Documentation',
64 'The IPython Development Team', 'manual', 'True'],
65 ['parallel/winhpc_index', 'winhpc_whitepaper.tex',
66 'Using IPython on Windows HPC Server 2008',
67 "Brian E. Granger", 'manual', 'True']
68 ]
69 latex_use_modindex = "True"
70 latex_font_size = "11pt"
@@ -15,14 +15,23 b''
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 import sys, os
19 import sys, os
19 from pathlib import Path
20 from pathlib import Path
20
21
22 if sys.version_info > (3, 11):
23 import tomllib
24 else:
25 import tomli as tomllib
26
27 with open("./sphinx.toml", "rb") as f:
28 config = tomllib.load(f)
29
21 # https://read-the-docs.readthedocs.io/en/latest/faq.html
30 # https://read-the-docs.readthedocs.io/en/latest/faq.html
22 ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'
31 ON_RTD = os.environ.get("READTHEDOCS", None) == "True"
23
32
24 if ON_RTD:
33 if ON_RTD:
25 tags.add('rtd')
34 tags.add("rtd")
26
35
27 # 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.
28 for name in ("config", "api", "magics", "shortcuts"):
37 for name in ("config", "api", "magics", "shortcuts"):
@@ -38,9 +47,6 b' if ON_RTD:'
38 )
47 )
39 import sphinx_rtd_theme
48 import sphinx_rtd_theme
40
49
41 html_theme = "sphinx_rtd_theme"
42 html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
43
44 # Allow Python scripts to change behaviour during sphinx run
50 # Allow Python scripts to change behaviour during sphinx run
45 os.environ["IN_SPHINX_RUN"] = "True"
51 os.environ["IN_SPHINX_RUN"] = "True"
46
52
@@ -52,7 +58,7 b' autodoc_type_aliases = {'
52 # 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
53 # 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
54 # absolute, like shown here.
60 # absolute, like shown here.
55 sys.path.insert(0, os.path.abspath('../sphinxext'))
61 sys.path.insert(0, os.path.abspath("../sphinxext"))
56
62
57 # 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
58 iprelease = {}
64 iprelease = {}
@@ -68,44 +74,120 b' exec('
68 # General configuration
74 # General configuration
69 # ---------------------
75 # ---------------------
70
76
71 # Add any Sphinx extension module names here, as strings. They can be extensions
77 # - template_path: Add any paths that contain templates here, relative to this directory.
72 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
78 # - master_doc: The master toctree document.
73 extensions = [
79 # - project
74 "sphinx.ext.autodoc",
80 # - copyright
75 "sphinx.ext.autosummary",
81 # - github_project_url
76 "sphinx.ext.doctest",
82 # - source_suffix = config["sphinx"]["source_suffix"]
77 "sphinx.ext.inheritance_diagram",
83 # - exclude_patterns:
78 "sphinx.ext.intersphinx",
84 # Exclude these glob-style patterns when looking for source files.
79 "sphinx.ext.graphviz",
85 # They are relative to the source/ directory.
80 "sphinxcontrib.jquery",
86 # - pygments_style: The name of the Pygments (syntax highlighting) style to use.
81 "IPython.sphinxext.ipython_console_highlighting",
87 # - extensions:
82 "IPython.sphinxext.ipython_directive",
88 # Add any Sphinx extension module names here, as strings. They can be extensions
83 "sphinx.ext.napoleon", # to preprocess docstrings
89 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
84 "github", # for easy GitHub links
90 # - default_role
85 "magics",
91 # - modindex_common_prefix
86 "configtraits",
92
93 locals().update(config["sphinx"])
94
95 intersphinx_mapping = config["intersphinx_mapping"]
96 for k, v in intersphinx_mapping.items():
97 intersphinx_mapping[k] = tuple(
98 [intersphinx_mapping[k]["url"], intersphinx_mapping[k]["fallback"]]
99 )
100
101 # numpydoc config
102 numpydoc_show_class_members = config["numpydoc"][
103 "numpydoc_show_class_members"
104 ] # Otherwise Sphinx emits thousands of warnings
105 numpydoc_class_members_toctree = config["numpydoc"]["numpydoc_class_members_toctree"]
106 warning_is_error = config["numpydoc"]["warning_is_error"]
107
108 # Options for HTML output
109 # -----------------------
110 html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
111 # - html_theme
112 # - html_static_path
113 # Add any paths that contain custom static files (such as style sheets) here,
114 # relative to this directory. They are copied after the builtin static files,
115 # so a file named "default.css" will overwrite the builtin "default.css".
116 # Favicon needs the directory name
117 # - html_favicon
118 # - html_last_updated_fmt = config["html"]["html_last_updated_fmt"]
119 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
120 # using the given strftime format.
121 # Output file base name for HTML help builder.
122 # - htmlhelp_basename
123 locals().update(config["html"])
124
125 # Additional templates that should be rendered to pages, maps page names to
126 # template names.
127 html_additional_pages = {}
128 for item in config["html"]["html_additional_pages"]:
129 html_additional_pages[item[0]] = item[1]
130
131 # Options for LaTeX output
132 # ------------------------
133
134 # Grouping the document tree into LaTeX files. List of tuples
135 # (source start file, target name, title, author, document class [howto/manual]).
136 latex_documents = []
137 for item in config["latex"]["latex_documents"]:
138 latex_documents.append(tuple(item))
139 # If false, no module index is generated.
140 latex_use_modindex = config["latex"]["latex_use_modindex"]
141 # The font size ('10pt', '11pt' or '12pt').
142 latex_font_size = config["latex"]["latex_font_size"]
143
144 # Options for texinfo output
145 # --------------------------
146 texinfo_documents = [
147 (
148 master_doc,
149 "ipython",
150 "IPython Documentation",
151 "The IPython Development Team",
152 "IPython",
153 "IPython Documentation",
154 "Programming",
155 1,
156 ),
87 ]
157 ]
88
158
89 # Add any paths that contain templates here, relative to this directory.
159 #########################################################################
90 templates_path = ['_templates']
160 # Custom configuration
161 # The default replacements for |version| and |release|, also used in various
162 # other places throughout the built documents.
163 #
164 # The full version, including alpha/beta/rc tags.
165 release = "%s" % iprelease["version"]
166 # Just the X.Y.Z part, no '-dev'
167 version = iprelease["version"].split("-", 1)[0]
91
168
92 # The suffix of source filenames.
169 # There are two options for replacing |today|: either, you set today to some
93 source_suffix = '.rst'
170 # non-false value, then it is used:
171 # today = ''
172 # Else, today_fmt is used as the format for a strftime call.
173 today_fmt = "%B %d, %Y"
174
175 rst_prolog = ""
94
176
95 rst_prolog = ''
96
177
97 def is_stable(extra):
178 def is_stable(extra):
98 for ext in {'dev', 'b', 'rc'}:
179 for ext in {"dev", "b", "rc"}:
99 if ext in extra:
180 if ext in extra:
100 return False
181 return False
101 return True
182 return True
102
183
103 if is_stable(iprelease['_version_extra']):
184
104 tags.add('ipystable')
185 if is_stable(iprelease["_version_extra"]):
105 print('Adding Tag: ipystable')
186 tags.add("ipystable")
187 print("Adding Tag: ipystable")
106 else:
188 else:
107 tags.add('ipydev')
189 tags.add("ipydev")
108 print('Adding Tag: ipydev')
190 print("Adding Tag: ipydev")
109 rst_prolog += """
191 rst_prolog += """
110 .. warning::
192 .. warning::
111
193
@@ -126,23 +208,9 b' rst_prolog += """'
126
208
127 """
209 """
128
210
129 # The master toctree document.
130 master_doc = 'index'
131
132 # General substitutions.
133 project = 'IPython'
134 copyright = 'The IPython Development Team'
135
136 # ghissue config
137 github_project_url = "https://github.com/ipython/ipython"
138
139 # numpydoc config
140 numpydoc_show_class_members = False # Otherwise Sphinx emits thousands of warnings
141 numpydoc_class_members_toctree = False
142 warning_is_error = True
143
144 import logging
211 import logging
145
212
213
146 class ConfigtraitFilter(logging.Filter):
214 class ConfigtraitFilter(logging.Filter):
147 """
215 """
148 This is a filter to remove in sphinx 3+ the error about config traits being duplicated.
216 This is a filter to remove in sphinx 3+ the error about config traits being duplicated.
@@ -153,178 +221,22 b' class ConfigtraitFilter(logging.Filter):'
153 """
221 """
154
222
155 def filter(self, record):
223 def filter(self, record):
156 if record.args and record.args[0] == 'configtrait' and 'duplicate' in record.msg:
224 if (
225 record.args
226 and record.args[0] == "configtrait"
227 and "duplicate" in record.msg
228 ):
157 return False
229 return False
158 return True
230 return True
159
231
232
160 ct_filter = ConfigtraitFilter()
233 ct_filter = ConfigtraitFilter()
161
234
162 import sphinx.util
235 import sphinx.util
163 logger = sphinx.util.logging.getLogger('sphinx.domains.std').logger
164
236
237 logger = sphinx.util.logging.getLogger("sphinx.domains.std").logger
165 logger.addFilter(ct_filter)
238 logger.addFilter(ct_filter)
166
239
167 # The default replacements for |version| and |release|, also used in various
168 # other places throughout the built documents.
169 #
170 # The full version, including alpha/beta/rc tags.
171 release = "%s" % iprelease['version']
172 # Just the X.Y.Z part, no '-dev'
173 version = iprelease['version'].split('-', 1)[0]
174
175
176 # There are two options for replacing |today|: either, you set today to some
177 # non-false value, then it is used:
178 #today = ''
179 # Else, today_fmt is used as the format for a strftime call.
180 today_fmt = '%B %d, %Y'
181
182 # List of documents that shouldn't be included in the build.
183 #unused_docs = []
184
185 # Exclude these glob-style patterns when looking for source files. They are
186 # relative to the source/ directory.
187 exclude_patterns = ["**.ipynb_checkpoints"]
188
189 # If true, '()' will be appended to :func: etc. cross-reference text.
190 #add_function_parentheses = True
191
192 # If true, the current module name will be prepended to all description
193 # unit titles (such as .. function::).
194 #add_module_names = True
195
196 # If true, sectionauthor and moduleauthor directives will be shown in the
197 # output. They are ignored by default.
198 #show_authors = False
199
200 # The name of the Pygments (syntax highlighting) style to use.
201 pygments_style = 'sphinx'
202
203 # Set the default role so we can use `foo` instead of ``foo``
204 default_role = 'literal'
205
206 # Options for HTML output
207 # -----------------------
208
209 # The style sheet to use for HTML and HTML Help pages. A file of that name
210 # must exist either in Sphinx' static/ path, or in one of the custom paths
211 # given in html_static_path.
212 # html_style = 'default.css'
213
214 # The name for this set of Sphinx documents. If None, it defaults to
215 # "<project> v<release> documentation".
216 #html_title = None
217
218 # The name of an image file (within the static path) to place at the top of
219 # the sidebar.
220 #html_logo = None
221
222 # Add any paths that contain custom static files (such as style sheets) here,
223 # relative to this directory. They are copied after the builtin static files,
224 # so a file named "default.css" will overwrite the builtin "default.css".
225 html_static_path = ['_static']
226
227 # Favicon needs the directory name
228 html_favicon = '_static/favicon.ico'
229 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
230 # using the given strftime format.
231 html_last_updated_fmt = '%b %d, %Y'
232
233 # If true, SmartyPants will be used to convert quotes and dashes to
234 # typographically correct entities.
235 #html_use_smartypants = True
236
237 # Custom sidebar templates, maps document names to template names.
238 #html_sidebars = {}
239
240 # Additional templates that should be rendered to pages, maps page names to
241 # template names.
242 html_additional_pages = {
243 'interactive/htmlnotebook': 'notebook_redirect.html',
244 'interactive/notebook': 'notebook_redirect.html',
245 'interactive/nbconvert': 'notebook_redirect.html',
246 'interactive/public_server': 'notebook_redirect.html',
247 }
248
249 # If false, no module index is generated.
250 #html_use_modindex = True
251
252 # If true, the reST sources are included in the HTML build as _sources/<name>.
253 #html_copy_source = True
254
255 # If true, an OpenSearch description file will be output, and all pages will
256 # contain a <link> tag referring to it. The value of this option must be the
257 # base URL from which the finished HTML is served.
258 #html_use_opensearch = ''
259
260 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
261 #html_file_suffix = ''
262
263 # Output file base name for HTML help builder.
264 htmlhelp_basename = 'ipythondoc'
265
266 intersphinx_mapping = {'python': ('https://docs.python.org/3/', None),
267 'rpy2': ('https://rpy2.github.io/doc/latest/html/', None),
268 'jupyterclient': ('https://jupyter-client.readthedocs.io/en/latest/', None),
269 'jupyter': ('https://jupyter.readthedocs.io/en/latest/', None),
270 'jedi': ('https://jedi.readthedocs.io/en/latest/', None),
271 'traitlets': ('https://traitlets.readthedocs.io/en/latest/', None),
272 'ipykernel': ('https://ipykernel.readthedocs.io/en/latest/', None),
273 'prompt_toolkit' : ('https://python-prompt-toolkit.readthedocs.io/en/stable/', None),
274 'ipywidgets': ('https://ipywidgets.readthedocs.io/en/stable/', None),
275 'ipyparallel': ('https://ipyparallel.readthedocs.io/en/stable/', None),
276 'pip': ('https://pip.pypa.io/en/stable/', None)
277 }
278
279 # Options for LaTeX output
280 # ------------------------
281
282 # The font size ('10pt', '11pt' or '12pt').
283 latex_font_size = '11pt'
284
285 # Grouping the document tree into LaTeX files. List of tuples
286 # (source start file, target name, title, author, document class [howto/manual]).
287
288 latex_documents = [
289 ('index', 'ipython.tex', 'IPython Documentation',
290 u"""The IPython Development Team""", 'manual', True),
291 ('parallel/winhpc_index', 'winhpc_whitepaper.tex',
292 'Using IPython on Windows HPC Server 2008',
293 u"Brian E. Granger", 'manual', True)
294 ]
295
296 # The name of an image file (relative to this directory) to place at the top of
297 # the title page.
298 #latex_logo = None
299
300 # For "manual" documents, if this is true, then toplevel headings are parts,
301 # not chapters.
302 #latex_use_parts = False
303
304 # Additional stuff for the LaTeX preamble.
305 #latex_preamble = ''
306
307 # Documents to append as an appendix to all manuals.
308 #latex_appendices = []
309
310 # If false, no module index is generated.
311 latex_use_modindex = True
312
313
314 # Options for texinfo output
315 # --------------------------
316
317 texinfo_documents = [
318 (master_doc, 'ipython', 'IPython Documentation',
319 'The IPython Development Team',
320 'IPython',
321 'IPython Documentation',
322 'Programming',
323 1),
324 ]
325
326 modindex_common_prefix = ['IPython.']
327
328
240
329 def setup(app):
241 def setup(app):
330 app.add_css_file("theme_overrides.css")
242 app.add_css_file("theme_overrides.css")
@@ -61,17 +61,18 b' black = ['
61 "black",
61 "black",
62 ]
62 ]
63 doc = [
63 doc = [
64 "docrepr",
65 "exceptiongroup",
64 "ipykernel",
66 "ipykernel",
67 "ipython[test]",
68 "matplotlib",
65 "setuptools>=18.5",
69 "setuptools>=18.5",
66 "sphinx>=1.3",
67 "sphinx-rtd-theme",
70 "sphinx-rtd-theme",
71 "sphinx>=1.3",
68 "sphinxcontrib-jquery",
72 "sphinxcontrib-jquery",
69 "docrepr",
70 "matplotlib",
71 "stack_data",
73 "stack_data",
74 "tomli ; python_version<'3.11'",
72 "typing_extensions",
75 "typing_extensions",
73 "exceptiongroup",
74 "ipython[test]",
75 ]
76 ]
76 kernel = [
77 kernel = [
77 "ipykernel",
78 "ipykernel",
General Comments 0
You need to be logged in to leave comments. Login now