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