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