|
5 | 5 | import pathlib |
6 | 6 | import sys |
7 | 7 |
|
| 8 | +from docutils import nodes |
| 9 | +from notfound.utils import replace_uris |
| 10 | + |
8 | 11 | _ROOT = pathlib.Path(__file__).resolve().parent.parent |
9 | 12 | sys.path.append(os.fspath(_ROOT)) |
10 | 13 |
|
|
35 | 38 | "sphinx_copybutton", |
36 | 39 | "sphinx_toolbox.collapse", |
37 | 40 | "sphinx-jsonschema", |
| 41 | + "notfound.extension", |
38 | 42 | ] |
39 | 43 |
|
40 | 44 | nitpicky = True |
|
211 | 215 | intersphinx_mapping = { |
212 | 216 | "boltons": ("https://boltons.readthedocs.io/en/latest/", None), |
213 | 217 | "bottle": ("https://bottlepy.org/docs/dev/", None), |
214 | | - "build": ("https://pypa-build.readthedocs.io/en/stable/", None), |
| 218 | + "build": ("https://build.pypa.io/en/stable/", None), |
215 | 219 | "cffi": ("https://cffi.readthedocs.io/en/latest/", None), |
216 | | - "conda": ("https://conda.io/en/latest/", None), |
| 220 | + "conda": ("https://docs.conda.io/en/latest/", None), |
217 | 221 | "devpi": ("https://devpi.net/docs/devpi/devpi/latest/+doc", None), |
218 | 222 | "dh-virtualenv": ("https://dh-virtualenv.readthedocs.io/en/latest/", None), |
219 | 223 | "distlib": ("https://distlib.readthedocs.io/en/latest/", None), |
|
232 | 236 | "python": ("https://docs.python.org/3", None), |
233 | 237 | "python-guide": ("https://docs.python-guide.org", None), |
234 | 238 | "setuptools": ("https://setuptools.pypa.io/en/latest/", None), |
235 | | - "setuptools-scm": ("https://setuptools-scm.rtfd.io/latest", None), |
| 239 | + "setuptools-scm": ("https://setuptools-scm.readthedocs.io/latest", None), |
236 | 240 | "spack": ("https://spack.readthedocs.io/en/latest/", None), |
237 | 241 | "sphinx": ("https://www.sphinx-doc.org/en/master", None), |
238 | 242 | "tox": ("https://tox.wiki/en/latest/", None), |
|
250 | 254 |
|
251 | 255 | copybutton_prompt_text = r">>> |\.\.\. |\$ |> " |
252 | 256 | copybutton_prompt_is_regexp = True |
| 257 | + |
| 258 | +# -- Options for sphinx-notfound-page -------------------------------------------------- |
| 259 | +# https://sphinx-notfound-page.readthedocs.io/en/latest/configuration.html |
| 260 | + |
| 261 | +# Local builds are served from the root, RtD seves from /<language>/<version>/ |
| 262 | +if not RTD_BUILD: |
| 263 | + notfound_urls_prefix = "/" |
| 264 | + |
| 265 | + |
| 266 | +def fix_notfound_links(app, doctree, docname): |
| 267 | + # The extension only makes theme links absolute, not links in the page body |
| 268 | + if app.builder.format == "html" and docname == app.config.notfound_pagename: |
| 269 | + replace_uris(app, doctree, nodes.reference, "refuri") |
| 270 | + |
| 271 | + |
| 272 | +def setup(app): |
| 273 | + app.connect("doctree-resolved", fix_notfound_links) |
0 commit comments