click_extra.sphinx package¶
classDiagram
StatelessDomain <|-- ClickDomain
StatelessDomain <|-- PythonDomain
Helpers and utilities for Sphinx.
Note
The MkDocs counterpart lives in click_extra.mkdocs, which achieves the same
ANSI color rendering by patching pymdownx.highlight’s formatter classes.
Todo
Split the documentation stack into a standalone extra-docs project, should it
keep growing away from the CLI framework hosting it. It would take this package,
click_extra.pygments, click_extra.mkdocs, the
click_extra.markdown package with its MyST converters and marker-region
primitives, and the ones repomatic keeps in its own docs/docs_update.py. The
open question is the click:source and click:run directives: they invoke a
Click CLI, so either they stay here, or extra-docs depends on click-extra.
- click_extra.sphinx.EXEC_DIRECTIVES_OPT_IN = 'click_extra_enable_exec_directives'¶
Name of the
conf.pyconfig flag that gates every code-execution directive.Default is
False. A project that addsclick_extra.sphinxto itsextensionslist gets the ANSI Pygments formatter unconditionally, but does not gain access to either theclick:*or thepython:*directive families until the maintainer opts in explicitly. Both familiesexecuser-supplied Python at build time with full Sphinx-process privileges: gating them behind a single explicit flag keeps a transitive import or a doc-only pull request from silently expanding the build’s attack surface.
- click_extra.sphinx.setup(app)[source]¶
Register extensions to Sphinx.
Always-on features (no execution surface):
The ANSI-capable HTML formatter for Pygments (replaces
sphinx.highlighting.PygmentsBridgewith one that renders ANSI colors in code blocks).The
matrixdirective, which renders a package’s compatibility grid ({matrix} pythonor{matrix} <distribution>) from its git tag history. It runs a canned generator rather than user-supplied Python, so it carries no execution surface and needs no opt-in. Seeclick_extra.sphinx.matrix.Deduplication of the
todolistpage, whichsphinx.ext.todofills with one entry per rendering of a:todo:directive rather than one per directive. Inert on a project that enables neither the extension nor atodolist, and switched off withclick_extra.sphinx.todos.DEDUPE_TODOS_CONFIG. Seeclick_extra.sphinx.todos.A
click_extra.sphinx.todos.UNRENDERED_TODO_WARNINGwarning for each:todo:in a docstring that no page renders, which notodolistcan list. Inert on a project that does not enablesphinx.ext.todo, and silenced throughsuppress_warnings. Seeclick_extra.sphinx.todos.The
todolistentries in the order of their pages, which a parallel read otherwise shuffles, and with links that reach their targets after a serial read. Inert on a project that does not enablesphinx.ext.todo. Seeclick_extra.sphinx.todos.A one-line first column for every table whose top-left cell names both axes, like the
matrixtables: a narrow screen scrolls the table instead of wrapping its labels. Seeclick_extra.sphinx.tables.A crosshair on the same tables, which highlights the row and the column under the pointer, and makes a cell holding a single link clickable over its whole area. See
click_extra.sphinx.crosshair.A vertical layout for a sphinx-design
tab-setmarked with:class: tabs-vertical: its labels stack down a left rail. Deprecated for the:orientation: verticaloption of sphinx-design0.8.0, with a warning on each tab-set that carries the class. Inert without sphinx-design. Seeclick_extra.sphinx.tabs.Class diagrams of
autoclasstreethat let the mouse wheel scroll the page, where the d3 zoom of sphinxcontrib-mermaid would catch it. Inert without sphinxcontrib-mermaid, or withmermaid_d3_zoomoff. Seeclick_extra.sphinx.mermaid.The
linkcheckrequests to github.com signed with the token ofGITHUB_TOKEN, release downloads excepted. Inert until the variable is set. Seeclick_extra.sphinx.linkcheck.No
sphinx.ext.viewcodepage for a module that no documented object links to, so a parallel read publishes the pages of a serial one, and no index link to a module whose source viewcode could not read. Inert withoutsphinx.ext.viewcode. Seeclick_extra.sphinx.viewcode.Each
[docs]link of asphinx.ext.viewcodepage pointed at the anchor of its object, where a documented instance can lend the page the module path of another module. Inert withoutsphinx.ext.viewcode. Seeclick_extra.sphinx.viewcode.The Python objects of a parallel read indexed as a serial read indexes them: the alias of an object that a re-exporting page declares never replaces its definition. Inert in a serial read. See
click_extra.sphinx.parallel.The same autodoc members on a page, whatever the pages read before it: the names that only the source of a module annotates, in an
if TYPE_CHECKING:block or asself.x: Tin a method. Inert withoutsphinx.ext.autodoc. Seeclick_extra.sphinx.parallel.A
click_extra.sphinx.internal_links.DEAD_LINK_WARNINGwarning for each internal link of the built HTML that leads to no page, or to no anchor of its page, once per page. Inert with a builder that writes no HTML, and silenced throughsuppress_warnings. Seeclick_extra.sphinx.internal_links.An
og:titlewithout the space a leading title icon leaves. Inert without sphinxext-opengraph. Seeclick_extra.sphinx.opengraph.Every node of a page pointed at the page’s own document before Sphinx pickles it, which keeps the build environment out of the doctree of a page with an
{eval-rst}block. Seeclick_extra.sphinx.doctrees.Changelog releases anchored on their version, like
#v1-4-2, in place of a positional#idN. Inert until a project setsclick_extra.sphinx.changelog.RELEASE_ANCHORS_CONFIG. Seeclick_extra.sphinx.changelog.The man-page hook, which writes roff man pages for the CLIs a project lists in
click_extra.sphinx.manpages.MANPAGES_CONFIG_KEYon every HTML build. Inert until a project lists one. Seeclick_extra.sphinx.manpages.A failed build on the warning types a project lists in
click_extra.sphinx.fail_on_warnings.FAIL_ON_WARNINGS_CONFIG, where Sphinx can only fail on every warning at once. Inert until a project lists one. Seeclick_extra.sphinx.fail_on_warnings.
Opt-in features (gated behind
click_extra_enable_exec_directives):click:source/click:runto define and execute Click CLIs at build time.click:tree/click:configto render the command reference and the configuration reference of a Click CLI at build time.python:source/python:runto execute arbitrary Python at build time and render its source or capturedstdout.python:render/python:render-myst/python:render-rstto execute arbitrary Python and parse the capturedstdoutas live document content.
All directives in the opt-in group execute user-supplied Python with the same privileges as the Sphinx process. They are therefore disabled by default. Set
click_extra_enable_exec_directives = Trueinconf.pyto register them.Caution
This function replaces the HTML formatter of
sphinx.highlighting.PygmentsBridgewithAnsiHtmlFormatter, for every Sphinx app of the process, so that code blocks render ANSI colors.- Return type:
Submodules¶
click_extra.sphinx.announcementmoduleclick_extra.sphinx.changelogmoduleclick_extra.sphinx.clickmoduleRST_INDENTDEFAULT_SCREENSHOT_DIRRUN_CAPTURE_CONFIGSCREENSHOT_DIR_CONFIGSCREENSHOT_PRESET_CONFIGSCREENSHOT_SYNTAX_STYLE_CONFIGSCREENSHOT_WATERMARK_CONFIGSCREENSHOT_MARKER_STARTSCREENSHOT_MARKER_ENDregister_config()ClickDirectiveClickDirective.has_contentClickDirective.required_argumentsClickDirective.optional_argumentsClickDirective.final_argument_whitespaceClickDirective.option_specClickDirective.default_languageClickDirective.source_languageClickDirective.screenshots_sourceClickDirective.show_source_by_defaultClickDirective.show_results_by_defaultClickDirective.show_prompt_by_defaultClickDirective.runner_methodClickDirective.runner_attrClickDirective.runner_factoryClickDirective.runnerClickDirective.languageClickDirective.code_block_options()ClickDirective.show_sourceClickDirective.show_resultsClickDirective.show_promptClickDirective.evaluate()ClickDirective.render_code_block()ClickDirective.screenshotClickDirective.screenshot_backgroundClickDirective.screenshot_columnsClickDirective.resolve_animation()ClickDirective.refuse_cuts()ClickDirective.screenshot_animationClickDirective.emphasis_specClickDirective.screenshot_emphasis()ClickDirective.numbered()ClickDirective.screenshot_hold()ClickDirective.screenshot_syntax_styleClickDirective.screenshot_schemeClickDirective.screenshot_paletteClickDirective.screenshot_lines()ClickDirective.screenshot_frameClickDirective.invocationClickDirective.closed()ClickDirective.opened()ClickDirective.render_animation()ClickDirective.write_screenshot()ClickDirective.run()
SourceDirectiveRunDirectiverewrite_screenshot_regions()update_screenshot_blocks()cleanup_runner()
click_extra.sphinx.click_referencemoduleclick_extra.sphinx.click_runnermoduleclick_extra.sphinx.crosshairmoduleclick_extra.sphinx.doctreesmoduleclick_extra.sphinx.fail_on_warningsmoduleclick_extra.sphinx.internal_linksmoduleclick_extra.sphinx.linkcheckmoduleclick_extra.sphinx.manpagesmoduleclick_extra.sphinx.matrixmodulePYTHON_RELEASE_DATESSUPPORTED_CELLFORBIDDEN_CELLUNDECLARED_CELLDEFAULT_TAG_PATTERNDEFAULT_TAGS_SORTNEWEST_FIRSTOLDEST_FIRSTORDER_CHOICESPYPI_JSON_URLPYPI_TIMEOUTPOETRY_VERSION_PATTERNPOETRY_CARET_REPOETRY_TILDE_REPOETRY_WILDCARD_REPythonMatrixGrouppython_versions_released_by()parse_python_spec()memoized_history()python_matrix_groups()python_matrix_table()DependencyMatrixGroupReleasesUnreadabledependency_matrix_groups()dependency_matrix_table()EnvelopeBoundenvelope_bounds()envelope_list()MatrixDirectivesetup()rewrite_matrix_blocks()update_matrix_blocks()
click_extra.sphinx.mermaidmoduleclick_extra.sphinx.myst_docstringsmoduleclick_extra.sphinx.opengraphmoduleclick_extra.sphinx.parallelmoduleclick_extra.sphinx.pythonmoduleMIRROR_MARKER_STARTMIRROR_MARKER_ENDMIRROR_SRC_MARKER_ENDPythonRunnerPythonDirectivePythonSourceDirectivePythonRunDirectivePythonRenderBaseDirectivePythonRenderDirectivePythonRenderMystDirectivePythonRenderRstDirectiverewrite_mirrors()update_mirror_blocks()rewrite_python_mirror_regions()PythonDomaincleanup_python_runner()
click_extra.sphinx.tablesmoduleclick_extra.sphinx.tabsmoduleclick_extra.sphinx.theme_docsmoduleclick_extra.sphinx.todosmoduleclick_extra.sphinx.viewcodemodule