Gallery¶
Every example on this page is rendered live from the same extensions and theme your project gets out of the box. Nothing is mocked — the output below is the real autodoc pipeline.
Python API¶
Badges, type hints, and card layout working together on standard Python domain directives.
Functions¶
-
gp_demo_api.demo_function(name, count=1)
Plain function. Shows
functiontype badge.
-
async gp_demo_api.demo_async_function(url)
Asynchronous function. Shows
async+functionbadges.
-
gp_demo_api.demo_deprecated_function()
Do nothing (deprecated placeholder).
Shows
deprecated+functionbadges.Deprecated since version 2.0: Use
demo_function()instead.- Return type:
Module data¶
-
Module-level constant. Shows
datatype badge.
Exceptions¶
-
exception gp_demo_api.DemoError
Bases:
ExceptionCustom exception class. Shows
exceptiontype badge.Raised when a demo operation fails unexpectedly.
Classes¶
Abstract base classes¶
-
class gp_demo_api.DemoAbstractBase
Bases:
ABCAbstract base class. Shows
classtype badge.Subclass this to provide concrete implementations.
Layout regions and parameter folding¶
Large parameter lists fold automatically. The class below has 13 parameters (above the default threshold of 10), so its field list is collapsed into a disclosure widget.
Class with members (regions + fold)¶
-
class api_demo_layout.LayoutDemo
Bases:
objectA class demonstrating all layout regions.
The class docstring forms the narrative region. The parameter field list below forms the fields region (folded if large enough). Nested methods form the members region.
Parameters (13)
- Parameters:
host (str) – Server hostname.
port (int) – Server port number.
username (str) – Authentication username.
password (str) – Authentication password.
database (str) – Database name.
timeout (float) – Connection timeout in seconds.
retries (int) – Number of connection retries.
ssl (bool) – Enable SSL/TLS.
pool_size (int) – Connection pool size.
pool_timeout (float) – Pool checkout timeout.
echo (bool) – Log all SQL statements.
encoding (str) – Character encoding.
isolation_level (str) – Transaction isolation level.
Small function (no fold)¶
-
api_demo_layout.compact_function(name, value=0)
Format a name-value pair.
This should render without any fold – just a narrative region followed by a fields region.
Badge palette¶
The full badge system — types, modifiers, sizes, and variants — rendered by
the real build_badge / build_badge_group / build_toolbar API:
No icon
label build_badge("label")
With icon — left (default, gp-sphinx-badge[data-icon])
readonly mutating build_badge("readonly", icon="🔍")
With icon — right (gp-sphinx-badge–icon-right)
build_badge("readonly", icon="🔍", classes=[SAB.ICON_RIGHT])
Icon-only — 16x16 coloured box (gp-sphinx-badge–icon-only)
build_badge("", style="icon-only", icon="🔍")
Inline-icon — bare emoji inside code chip (gp-sphinx-badge–inline-icon)
some_function() other_func() build_badge("", style="inline-icon", icon="✏️")
Outline (gp-sphinx-badge–outline)
outline outline + icon build_badge("outline", fill="outline")
Dense (gp-sphinx-badge–dense) — compact bordered, dotted underline
dense dense + icon left SAB.DENSE + icon variants
Dense + outline
dense outline dense outline + icon left SAB.DENSE + outline
Underline control modifiers
dense default no underline solid dotted (opt-in) solid (opt-in) SAB.NO_UNDERLINE / SAB.UNDERLINE_SOLID / SAB.UNDERLINE_DOTTED
All sizes — standard pill
xxs xxs+icon xs xs+icon sm sm+icon md md+icon default default+icon lg lg+icon xl xl+icon xxs / xs / sm / md / default / lg / xl
All sizes — dense
xxs xxs+icon xs xs+icon sm sm+icon md md+icon default default+icon lg lg+icon xl xl+icon xxs / xs / sm / md / default / lg / xl (gp-sphinx-badge--dense)
Icon positions — standard (no icon / left / right / icon-only)
function function function: none / left / right / icon-only
fixture fixture fixture: none / left / right / icon-only
config config config: none / left / right / icon-only
directive directive directive: none / left / right / icon-only
Icon positions — dense
function function function (dense): none / left / right
fixture fixture fixture (dense): none / left / right
config config config (dense): none / left / right
directive directive directive (dense): none / left / right
Badge group
alpha beta gamma build_badge_group([...badges...])
Toolbar (push-right in flex heading)
build_toolbar(build_badge_group([...]))
Python API types (gp-sphinx-badge–type-*)
function class method property attribute data exception type alias module
Python API types — dense variant (gp-sphinx-badge–dense)
function class method property attribute data exception type alias module
Python API modifiers (gp-sphinx-badge–mod-*, outlined)
async classmethod staticmethod abstract final
Python API modifiers — dense variant
async classmethod staticmethod abstract final
pytest fixture types (gp-sphinx-badge–type-fixture)
fixture SAB.TYPE_FIXTURE — standard
fixture SAB.TYPE_FIXTURE — dense
pytest fixture scopes (gp-sphinx-badge–scope-*)
session module class
session module class
pytest fixture kinds / states (outlined)
factory override auto deprecated
factory override auto deprecated
Sphinx config (gp-sphinx-badge–type-config / gp-sphinx-badge–mod-rebuild)
config env html standard
config env html dense
docutils (gp-sphinx-badge–type-directive / role / option)
directive role option standard
directive role option dense
Package metadata — maturity
gp-sphinx-badge--meta-alpha / gp-sphinx-badge--meta-beta (filled)
Package metadata — link badges (outline)
GitHub PyPI _link_badge(label, url) — gp-sphinx-badge gp-sphinx-badge--outline gp-sphinx-badge--meta-link <a>
Package metadata — full header row
FastMCP tool cards¶
Tool documentation with safety badges and parameter tables.
list_sessions¶
create_session¶
delete_session¶
Parameter table¶
Parameters
Tool summary¶
Inspect¶
Read state without changing anything.
Tool |
Description |
|---|---|
List active sessions for one server. |
Act¶
Create or modify objects.
Tool |
Description |
|---|---|
Create one session and return the created record. |
Destroy¶
Remove objects; not reversible.
Tool |
Description |
|---|---|
Delete one session from the server. |
pytest fixtures¶
Fixture index¶
Fixture |
Flags |
Returns |
Description |
|---|---|---|---|
auto fixture |
|
Autouse fixture. |
|
class fixture |
Class-scoped resource. |
||
fixture |
Return a value (deprecated since 1.0, replaced by demo_plain). |
||
factory fixture |
Return a callable (factory kind). |
||
module fixture |
Module-scoped resource. |
||
fixture |
Override hook — customise in conftest.py. |
||
fixture |
Plain function-scope resource. |
||
session fixture |
Session-scoped resource. |
||
session auto fixture |
|
Session-scoped autouse. |
|
session factory fixture |
Session-scoped factory. |
Fixture reference¶
-
Plain function-scope resource. Shows FIXTURE badge only.
-
Session-scoped resource. Shows SESSION + FIXTURE badges.
Note
Created once per test session and shared across all tests. Requesting this fixture does not create a new instance per test.
-
Module-scoped resource. Shows MODULE + FIXTURE badges.
-
Class-scoped resource. Shows CLASS + FIXTURE badges.
Return a callable (factory kind). Shows FACTORY + FIXTURE badges.
def test_example(demo_factory: type[str]) -> None: obj = demo_factory() assert obj is not None
-
Override hook — customise in conftest.py. Shows OVERRIDE + FIXTURE badges.
-
Autouse fixture. Shows AUTO + FIXTURE badges.
- Autouse:
yes — runs automatically for every test
Note
No request needed — this fixture runs automatically for every test.
-
Return a value (deprecated since 1.0, replaced by demo_plain).
This fixture is documented with the
deprecatedRST option so the demo page can show the DEPRECATED + FIXTURE badge combination.
Session-scoped factory. Shows SESSION + FACTORY + FIXTURE badges.
Note
Created once per test session and shared across all tests. Requesting this fixture does not create a new instance per test.
def test_example(demo_session_factory: type[str]) -> None: obj = demo_session_factory() assert obj is not None
-
Session-scoped autouse. Shows SESSION + AUTO + FIXTURE badges.
Note
Created once per test session and shared across all tests. Requesting this fixture does not create a new instance per test.
- Autouse:
yes — runs automatically for every test
Note
No request needed — this fixture runs automatically for every test.
Sphinx config values¶
Config Value Index
Name |
Type |
Default |
Rebuild |
|---|---|---|---|
|
|
|
|
|
|
|
|
-
demo_theme_accent
- Type:
dict- Default:
{'light': 'mint', 'dark': 'teal'}- Registered by:
sphinx_config_demo.setup()
-
demo_show_callouts
- Type:
bool- Default:
True- Registered by:
sphinx_config_demo.setup()
docutils directives and roles¶
Directives¶
Directive Index
Name |
Python path |
Summary |
|---|---|---|
|
|
Render a short badge-like paragraph for directive demos. |
|
|
Render a simple titled container for directive demos. |
-
.. demobadge::
Render a short badge-like paragraph for directive demos.
Options:
- Python path:
docutils_demo.DemoBadgeDirective- Required arguments:
1- Optional arguments:
0- Final argument whitespace:
True- Has content:
False
Roles¶
Role Index
Name |
Python path |
Summary |
|---|---|---|
|
|
Return a literal node with badge-style classes. |
-
:demo-badge:
Return a literal node with badge-style classes.
- Python path:
docutils_demo.demo_badge_role- Accepts role content:
True