sphinx-autodoc-api-style¶
Sphinx extension that adds type and modifier badges to standard Python domain entries (functions, classes, methods, properties, attributes, data, exceptions). Mirrors the badge system from sphinx-autodoc-pytest-fixtures so API pages and fixture pages share a consistent visual language.
$ pip install sphinx-autodoc-api-style
Features¶
Type badges (rightmost):
function,class,method,property,attribute,data,exception— each with a distinct colorModifier badges (left of type):
async,classmethod,staticmethod,abstract,final,deprecatedCard containers: bordered cards with secondary-background headers
Dark mode: full light/dark theming via CSS custom properties
Accessibility: keyboard-focusable badges with tooltip popups
Non-invasive: hooks into
doctree-resolvedwithout replacing directives
How it works¶
Add sphinx_autodoc_api_style to your Sphinx extensions. With gp-sphinx,
use extra_extensions:
conf = merge_sphinx_config(
project="my-project",
version="1.0.0",
copyright="2026, Your Name",
source_repository="https://github.com/your-org/my-project/",
extra_extensions=["sphinx_autodoc_api_style"],
)
Or without merge_sphinx_config:
extensions = ["sphinx_autodoc_api_style"]
No special directives are needed — existing .. autofunction::,
.. autoclass::, .. automodule:: directives automatically receive badges.
Live demo¶
Functions¶
- gas_demo_api.demo_function(name, count=1)¶
Plain function. Shows
functiontype badge.
- async gas_demo_api.demo_async_function(url)¶
Asynchronous function. Shows
async+functionbadges.
- gas_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¶
Exceptions¶
Classes¶
- class gas_demo_api.DemoClass¶
Bases:
objectDemonstration class with various method types.
Shows
classtype badge on the class itself, and per-method badges for each method kind.- Parameters:
value (str) – Initial value for the demo instance.
- regular_method(x)¶
Regular instance method. Shows
methodtype badge.
- classmethod from_int(n)¶
Class method. Shows
classmethod+methodbadges.
- static utility(a, b)¶
Add two integers. Shows
staticmethod+methodbadges.
- property computed: str¶
Computed property. Shows
propertytype badge.- Returns:
The uppercased value.
- Return type:
- deprecated_method()¶
Do nothing (deprecated placeholder).
Shows
deprecated+methodbadges.Deprecated since version 1.5: Use
regular_method()instead.- Return type:
Abstract base classes¶
Badge reference¶
Type badges¶
Object type |
CSS class |
Color |
|---|---|---|
|
|
Blue |
|
|
Indigo |
|
|
Cyan |
|
|
Teal |
|
|
Slate |
|
|
Grey |
|
|
Rose |
Modifier badges¶
Modifier |
CSS class |
Style |
|---|---|---|
|
|
Purple outlined |
|
|
Amber outlined |
|
|
Grey outlined |
|
|
Indigo outlined |
|
|
Emerald outlined |
|
|
Red/grey outlined |
CSS prefix¶
All CSS classes use the gas- prefix (gp-sphinx api style) to avoid
collision with spf- (sphinx pytest fixtures) or other extensions.
Copyable config snippet
extensions = [
"sphinx_autodoc_api_style",
]
Package metadata
Source on GitHub: sphinx-autodoc-api-style
PyPI: sphinx-autodoc-api-style
Maturity:
Alpha
Registered Surface
sphinx_autodoc_api_style