notfound.extension
Module Contents
Classes
Force the 404 page to be |
Functions
|
Create a |
|
Point media files at our media server. |
|
Generate and override URLs for |
|
Handle deprecated configurations. |
|
Validate configs. |
|
- exception notfound.extension.BaseURIError(message: str, orig_exc: Exception | None = None, modname: str | None = None)
Bases:
sphinx.errors.ExtensionErrorException for malformed base URI.
- notfound.extension.html_collect_pages(app)
Create a
404.htmlpage.Uses
notfound_templateas a template to be rendered withnotfound_contextfor its context. The resulting file generated isnotfound_pagename.html.If the user already defined a page with pagename title
notfound_pagename, we don’t generate this page.- Parameters:
app (sphinx.application.Sphinx) – Sphinx Application
- notfound.extension.finalize_media(app, pagename, templatename, context, doctree)
Point media files at our media server.
Generate absolute URLs for resources (js, images, css, etc) to point to the right URL. For example, if a URL in the page is
_static/js/custom.jsit will be replaced by<notfound_urls_prefix>/_static/js/custom.js.On the other hand, if
notfound_no_urls_prefixis set, it will be replaced by/_static/js/custom.js.Also, all the links from the sidebar (toctree) are replaced with their absolute version. For example,
../section/pagename.htmlwill be replaced by/section/pagename.html.It handles a special case for Read the Docs and URLs starting with
/_/. These URLs have a special meaning under Read the Docs and don’t have to be changed. (e.g./_/static/javascript/readthedocs-doc-embed.js)- Parameters:
app (sphinx.application.Sphinx) – Sphinx Application
pagename (str) – name of the page being rendered
templatename (str) – template used to render the page
context (dict) – context used to render the page
doctree (docutils.nodes.document) – doctree of the page being rendered
- notfound.extension.doctree_resolved(app, doctree, docname)
Generate and override URLs for
.. image::Sphinx directive.When
.. image::is used in the404.rstfile, this function will override the URLs to point to the right place.- Parameters:
app (sphinx.application.Sphinx) – Sphinx Application
doctree (docutils.nodes.document) – doctree representing the document
docname (str) – name of the document
- class notfound.extension.OrphanMetadataCollector
Bases:
sphinx.environment.collectors.EnvironmentCollectorForce the 404 page to be
orphan.This way we remove the WARNING that Sphinx raises saying the page is not included in any toctree.
This collector has the same effect than
:orphan:at the top of the page.- clear_doc(self, app, env, docname)
Remove specified data of a document.
This method is called on the removal of the document.
- process_doc(self, app, doctree)
Process a document and gather specific data from it.
This method is called after the document is read.
- merge_other(self, app, env, docnames, other)
Merge in specified data regarding docnames from a different BuildEnvironment object which coming from a subprocess in parallel builds.
- notfound.extension.handle_deprecated_configs(app, *args, **kwargs)
Handle deprecated configurations.
Looks for old deprecated configurations, define the new ones and triggers warnings for old configs.
- notfound.extension.validate_configs(app, *args, **kwargs)
Validate configs.
Shows a warning if one of the configs is not valid.
- notfound.extension.setup(app)