Examples¶
Live demos¶
This page also uses sphinx-autodoc-docutils to document the config-doc
directives themselves, so the page demonstrates both config-value output and
directive documentation.
Render a single demo config value¶
-
demo_debugdemo_debug
- Type:
- Default:
False- Registered by:
Bulk config values demo¶
Renders all config values from a module at once:
-
demo_theme_accent¶demo_theme_accent¶
- Type:
- Default:
{'dark': 'teal', 'light': 'mint'}
- Registered by:
Document one demo builder¶
Builders surface their CLI name, output format, supported image types, and parallel-safety:
-
sphinx_demo_builder.DemoArchiveBuilder¶sphinx_demo_builder.DemoArchiveBuilder¶
Bundle every rendered page into one archive artifact.
- Python path:
- Builder name:
demo-archive- Output format:
archive- Supported image types:
image/svg+xml,image/png- Default translator:
—- Parallel-safe:
False- Epilog:
The demo archive is in %(outdir)s.
Bulk builders demo¶
Renders every builder a module registers via
sphinx_demo_builder.setup():
-
sphinx_demo_builder.DemoArchiveBuildersphinx_demo_builder.DemoArchiveBuilder
Bundle every rendered page into one archive artifact.
- Python path:
- Builder name:
demo-archive- Output format:
archive- Supported image types:
image/svg+xml,image/png- Default translator:
—- Parallel-safe:
False- Epilog:
The demo archive is in %(outdir)s.
Document one demo domain¶
Domains surface their registered name, label, object types, roles, and indices:
Bulk domains demo¶
The bulk form replays a package’s
sphinx_autodoc_docutils.setup() — here documenting the docutils
domain that sphinx-autodoc-docutils itself registers:
-
sphinx_autodoc_docutils.domain.DocutilsDomainsphinx_autodoc_docutils.domain.DocutilsDomain
Sphinx domain for docutils component documentation.
- Python path:
sphinx_autodoc_docutils.domain.DocutilsDomain- Domain name:
docutils- Label:
Docutils- Object types:
node,parser,reader,transform,translator,writer- Roles:
node,parser,reader,transform,translator,writer- Directives:
node,parser,reader,transform,translator,writer- Indices:
componentindex
Cross-referencing components¶
Component entries register targets in the sphinxext domain, so prose
can link to them: DemoArchiveBuilder and
DemoTopicDomain resolve to the entries above.
Demo module reference¶
The demo objects above, as plain Python API — the targets the
entries’ Python path facts link to:
Synthetic config registrations for live autodoc-sphinx demos.
Examples
>>> stub = type("App", (), {"add_config_value": lambda *a, **kw: None})()
>>> metadata = setup(stub)
>>> metadata["parallel_read_safe"]
True
-
sphinx_config_demo.setup(app)¶sphinx_config_demo.setup(app)¶
Register a small config surface for documentation demos.
Single-value config registration for the autoconfigvalue demo.
Examples
>>> stub = type("App", (), {"add_config_value": lambda *a, **kw: None})()
>>> metadata = setup(stub)
>>> metadata["parallel_write_safe"]
True
-
sphinx_config_single_demo.setup(app)¶sphinx_config_single_demo.setup(app)¶
Register one config value for single-entry rendering demos.
Synthetic Sphinx extension components for live autodoc demos.
Grows one demo class per component type so the
docs/packages/sphinx-autodoc-sphinx examples page can exercise the
autobuilder and autodomain directives against realistic
metadata.
Examples
>>> DemoArchiveBuilder.name
'demo-archive'
-
class sphinx_demo_builder.DemoArchiveBuilder¶class sphinx_demo_builder.DemoArchiveBuilder¶
Bases:
BuilderBundle every rendered page into one archive artifact.
A deliberately small builder: it reports all documents as outdated, writes nothing per page, and exists so the autodoc output has a realistic name/format/image-type surface to display.
-
class sphinx_demo_builder.DemoTopicDomain¶class sphinx_demo_builder.DemoTopicDomain¶
Bases:
DomainDescribe demo topics with one object type and matching role.
-
sphinx_demo_builder.setup(app)¶sphinx_demo_builder.setup(app)¶
Register the demo extension components with Sphinx.
Examples
>>> class FakeApp: ... def __init__(self) -> None: ... self.calls: list[tuple[str, object]] = [] ... def add_builder(self, cls: object) -> None: ... self.calls.append(("add_builder", cls)) ... def add_domain(self, cls: object) -> None: ... self.calls.append(("add_domain", cls)) >>> fake = FakeApp() >>> metadata = setup(fake) # type: ignore[arg-type] >>> ("add_builder", DemoArchiveBuilder) in fake.calls True >>> ("add_domain", DemoTopicDomain) in fake.calls True >>> metadata["parallel_read_safe"] True
- Parameters:
app (
Sphinx)- Return type: