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