Debian Codegraph @

docs/source/conf.py

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 # IPython documentation build configuration file.
2
3 # NOTE: This file has been edited manually from the auto-generated one from
4 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
5 # needed, generate a scratch one and merge by hand any new fields needed.
6
7 import sys, os
8 from pathlib import Path
9
10 import tomllib
11
12 from sphinx_toml import load_into_locals
13 from intersphinx_registry import get_intersphinx_mapping
14 import sphinx_rtd_theme
15 import sphinx.util
16 import logging
17
18 load_into_locals(locals())
19 # https://read-the-docs.readthedocs.io/en/latest/faq.html
20 ON_RTD = os.environ.get("READTHEDOCS", None) == "True"
21
22 if ON_RTD:
23 tags.add("rtd")
24
25 # RTD doesn't use the Makefile, so re-run autogen_{things}.py here.
26 for name in ("config", "api", "magics", "shortcuts"):
27 fname = Path("autogen_{}.py".format(name))
28 fpath = (Path(__file__).parent).joinpath("..", fname)
29 with open(fpath, encoding="utf-8") as f:
30 exec(
31 compile(f.read(), fname, "exec"),
32 {
33 "__file__": fpath,
34 "__name__": "__main__",
35 },
36 )
37
38 # Allow Python scripts to change behaviour during sphinx run
39 os.environ["IN_SPHINX_RUN"] = "True"
40
41 autodoc_type_aliases = {
42 "Matcher": " IPython.core.completer.Matcher",
43 "MatcherAPIv1": " IPython.core.completer.MatcherAPIv1",
44 }
45
46 # If your extensions are in another directory, add it here. If the directory
47 # is relative to the documentation root, use os.path.abspath to make it
48 # absolute, like shown here.
49 sys.path.insert(0, os.path.abspath("../sphinxext"))
50
51 # We load the ipython release info into a dict by explicit execution
52 iprelease = {}
53 exec(
54 compile(
55 open("../../IPython/core/release.py", encoding="utf-8").read(),
56 "../../IPython/core/release.py",
57 "exec",
58 ),
59 iprelease,
60 )
61
62 # General configuration
63 # ---------------------
64
65 # - template_path: Add any paths that contain templates here, relative to this directory.
66 # - master_doc: The master toctree document.
67 # - project
68 # - copyright
69 # - github_project_url
70 # - source_suffix = config["sphinx"]["source_suffix"]
71 # - exclude_patterns:
72 # Exclude these glob-style patterns when looking for source files.
73 # They are relative to the source/ directory.
74 # - pygments_style: The name of the Pygments (syntax highlighting) style to use.
75 # - default_role
76 # - modindex_common_prefix
77
78
79 intersphinx_mapping = get_intersphinx_mapping(
80 packages={
81 "python",
82 "rpy2",
83 "jupyterclient",
84 "jupyter",
85 "jedi",
86 "traitlets",
87 "ipykernel",
88 "prompt_toolkit",
89 "ipywidgets",
90 "ipyparallel",
91 "pip",
92 }
93 )
94
95 # External links configuration (replaces custom github extension)
96 extlinks = {
97 "ghissue": ("https://github.com/ipython/ipython/issues/%s/", "#%s"),
98 "ghpull": ("https://github.com/ipython/ipython/pull/%s/", "PR #%s"),
99 }
100
101
102 # Options for HTML output
103 # -----------------------
104 # - html_theme
105 # - html_static_path
106 # Add any paths that contain custom static files (such as style sheets) here,
107 # relative to this directory. They are copied after the builtin static files,
108 # so a file named "default.css" will overwrite the builtin "default.css".
109 # Favicon needs the directory name
110 # - html_favicon
111 # - html_last_updated_fmt = config["html"]["html_last_updated_fmt"]
112 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
113 # using the given strftime format.
114 # Output file base name for HTML help builder.
115 # - htmlhelp_basename
116
117 # Additional templates that should be rendered to pages, maps page names to
118 # template names.
119
120 # Options for LaTeX output
121 # ------------------------
122
123 # Grouping the document tree into LaTeX files. List of tuples
124 # (source start file, target name, title, author, document class [howto/manual]).
125 latex_documents = []
126
127
128 # Options for texinfo output
129 # --------------------------
130 texinfo_documents = [
131 (
132 master_doc,
133 "ipython",
134 "IPython Documentation",
135 "The IPython Development Team",
136 "IPython",
137 "IPython Documentation",
138 "Programming",
139 1,
140 ),
141 ]
142
143 #########################################################################
144 # Custom configuration
145 # The default replacements for |version| and |release|, also used in various
146 # other places throughout the built documents.
147 #
148 # The full version, including alpha/beta/rc tags.
149 release = "%s" % iprelease["version"]
150 # Just the X.Y.Z part, no '-dev'
151 version = iprelease["version"].split("-", 1)[0]
152
153 # There are two options for replacing |today|: either, you set today to some
154 # non-false value, then it is used:
155 # today = ''
156 # Else, today_fmt is used as the format for a strftime call.
157 today_fmt = "%B %d, %Y"
158
159 rst_prolog = ""
160
161
162 def is_stable(extra):
163 for ext in {"dev", "b", "rc"}:
164 if ext in extra:
165 return False
166 return True
167
168
169 if is_stable(iprelease["_version_extra"]):
170 tags.add("ipystable")
171 print("Adding Tag: ipystable")
172 else:
173 tags.add("ipydev")
174 print("Adding Tag: ipydev")
175 rst_prolog += """
176 .. warning::
177
178 This documentation covers a development version of IPython. The development
179 version may differ significantly from the latest stable release.
180 """
181
182
183
184 class ConfigtraitFilter(logging.Filter):
185 """
186 This is a filter to remove in sphinx 3+ the error about config traits being duplicated.
187
188 As we autogenerate configuration traits from, subclasses have lots of
189 duplication and we want to silence them. Indeed we build on travis with
190 warnings-as-error set to True, so those duplicate items make the build fail.
191 """
192
193 def filter(self, record):
194 if (
195 record.args
196 and record.args[0] == "configtrait"
197 and "duplicate" in record.msg
198 ):
199 return False
200 return True
201
202
203 ct_filter = ConfigtraitFilter()
204
205
206 logger = sphinx.util.logging.getLogger("sphinx.domains.std").logger
207 logger.addFilter(ct_filter)
208
209
210 def setup(app):
211 app.add_css_file("theme_overrides.css")
212
213
214 # Cleanup
215 # -------
216 # delete release info to avoid pickling errors from sphinx
217
218 del iprelease