You should have been redirected.
+ If not, click here to continue. + + +""" # noqa: E501 + + +def build_redirects(app: Sphinx, exception: Exception | None) -> None: + # this is a very simple implementation of + # https://github.com/wpilibsuite/sphinxext-rediraffe/blob/main/sphinxext/rediraffe.py + # to re-direct some old pages to new ones + if exception is not None or app.builder.name != 'html': + return + for page, rel_redirect in ( + (('development', 'overview.html'), 'index.html'), + (('development', 'builders.html'), 'howtos/builders.html'), + (('development', 'theming.html'), 'html_themes/index.html'), + (('development', 'templating.html'), 'html_themes/templating.html'), + (('development', 'tutorials', 'helloworld.html'), 'extending_syntax.html'), + (('development', 'tutorials', 'todo.html'), 'extending_build.html'), + (('development', 'tutorials', 'recipe.html'), 'adding_domain.html'), + ): + path = app.outdir.joinpath(*page) + if path.exists(): + continue + path.parent.mkdir(parents=True, exist_ok=True) + with path.open('w', encoding='utf-8') as f: + f.write(REDIRECT_TEMPLATE.replace('{{rel_url}}', rel_redirect)) + + +def setup(app: Sphinx) -> None: from sphinx.ext.autodoc import cut_lines from sphinx.util.docfields import GroupedField app.connect('autodoc-process-docstring', cut_lines(4, what=['module'])) app.connect('source-read', linkify_issues_in_changelog) - app.add_object_type( - 'confval', - 'confval', - objname='configuration value', - indextemplate='pair: %s; configuration value', - ) + app.connect('build-finished', build_redirects) fdesc = GroupedField('parameter', label='Parameters', names=['param'], can_collapse=True) app.add_object_type( - 'event', 'event', 'pair: %s; event', parse_event, doc_field_types=[fdesc] + 'event', + 'event', + 'pair: %s; event', + parse_event, + doc_field_types=[fdesc], ) diff --git a/doc/development/builders.rst b/doc/development/howtos/builders.rst similarity index 100% rename from doc/development/builders.rst rename to doc/development/howtos/builders.rst diff --git a/doc/development/howtos/index.rst b/doc/development/howtos/index.rst new file mode 100644 index 00000000000..9800655d18c --- /dev/null +++ b/doc/development/howtos/index.rst @@ -0,0 +1,8 @@ +How-tos +======= + +.. toctree:: + :maxdepth: 1 + + setup_extension + builders diff --git a/doc/development/overview.rst b/doc/development/howtos/setup_extension.rst similarity index 66% rename from doc/development/overview.rst rename to doc/development/howtos/setup_extension.rst index df8f5bb8b73..bcb4dafae4a 100644 --- a/doc/development/overview.rst +++ b/doc/development/howtos/setup_extension.rst @@ -1,10 +1,5 @@ -Developing extensions overview -============================== - -This page contains general information about developing Sphinx extensions. - -Make an extension depend on another extension ---------------------------------------------- +Depend on another extension +=========================== Sometimes your extension depends on the functionality of another Sphinx extension. Most Sphinx extensions are activated in a @@ -19,12 +14,12 @@ use the :meth:`sphinx.application.Sphinx.setup_extension` method. This will activate another extension at run-time, ensuring that you have access to its functionality. -For example, the following code activates the ``recommonmark`` extension: +For example, the following code activates the :mod:`sphinx.ext.autodoc` extension: .. code-block:: python def setup(app): - app.setup_extension("recommonmark") + app.setup_extension('sphinx.ext.autodoc') .. note:: diff --git a/doc/development/theming.rst b/doc/development/html_themes/index.rst similarity index 99% rename from doc/development/theming.rst rename to doc/development/html_themes/index.rst index 7853e4d74b5..31d6cfdfdbb 100644 --- a/doc/development/theming.rst +++ b/doc/development/html_themes/index.rst @@ -1,3 +1,5 @@ +.. _extension-html-theme: + HTML theme development ====================== @@ -222,6 +224,11 @@ If your theme package contains two or more themes, please call Templating ---------- +.. toctree:: + :hidden: + + templating + The :doc:`guide to templating