Skip to main content

sphinxcontrib-enum

License: MIT Ruff PyPI version PyPI pyversions PyPI status Documentation Status Code Cov Test Status Lint Status OpenSSF Scorecard

Sphinx directive for documenting dataclass enums in tabular format, with support for enum-properties.

Render dataclass enums as tables with a row for each member and a column for every field. Tables can optionally offer CSV and JSON download buttons. Enums with dataclass values, named tuple values and plain enums work too, and enum-properties enums are also supported!

Installation

pip install sphinxcontrib-enum

To document enum-properties enums, install the properties extra to get a supported version of enum-properties:

pip install "sphinxcontrib-enum[properties]"

Add the extension to your conf.py:

extensions = [
    ...
    "sphinxcontrib_enum",
]

Quick Start

Dataclass Enums

Each dataclass field becomes a column. Field docstrings can describe the columns in an optional legend:

from dataclasses import dataclass
from enum import Enum


@dataclass(frozen=True)
class PlanetData:
    mass: float
    """Mass in kilograms."""

    radius: float
    """Radius in meters."""

    #: Number of known moons.
    moons: int


class Planet(PlanetData, Enum):
    MERCURY = 3.303e23, 2.4397e6, 0
    VENUS = 4.869e24, 6.0518e6, 0
    EARTH = 5.976e24, 6.37814e6, 1
    MARS = 6.421e23, 3.3972e6, 2
.. enum-table:: mypackage.Planet
   :legend:
   :download:
The Planet enum rendered as a table with name, mass, radius and moons columns, a legend describing each column and CSV and JSON download buttons

Member Docstrings

Member docstrings are rendered in a doc column. They are parsed as reStructuredText:

from enum import IntEnum


class Severity(IntEnum):
    DEBUG = 10
    """Diagnostic detail, usually disabled in production."""

    INFO = 20
    """Routine operational messages."""

    #: Something unexpected happened that the application **recovered** from.
    WARNING = 30

    ERROR = 40
    """A failure that needs attention.

    See :ref:`usage` for how to render these tables."""

    CRITICAL = 50
.. enum-table:: mypackage.Severity
   :download:
The Severity enum rendered as a table with name, value and doc columns, the doc column holding each member's rendered docstring

enum-properties

enum-properties properties become columns, described by their annotation docstrings:

import typing as t

from enum_properties import EnumProperties, Symmetric


class Shade(EnumProperties):
    label: t.Annotated[str, Symmetric()]
    """A human readable label."""

    hex: t.Annotated[str, Symmetric(case_fold=True)]
    """The hex color code, without a leading ``#``."""

    RED = 1, "Red", "ff0000"
    GREEN = 2, "Green", "00ff00"
    BLUE = 3, "Blue", "0000ff"
.. enum-table:: mypackage.Shade
   :legend:
   :download:
The Shade enum rendered as a table with name, value, label and hex columns and a legend describing the label and hex columns

Columns, members, headers, widths, captions, download formats and cell formatting can all be customized:

.. enum-table:: mypackage.Planet
   :columns: name, radius
   :members: EARTH, MERCURY
   :headers: name=Planet, radius=Radius (m)
   :caption: The inner planets.

Documentation

Full documentation is available at sphinxcontrib-enum.readthedocs.io.

Development

git clone https://github.com/bckohan/sphinxcontrib-enum.git
cd sphinxcontrib-enum
just setup
just install
just test

Contributing

Contributions are welcome! Please see CONTRIBUTING.md.

Release files for sphinxcontrib-enum 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinxcontrib-enum 0.2.0
File Size Uploaded
sphinxcontrib_enum-0.2.0.tar.gz 520.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sphinxcontrib-enum 0.2.0
File Interpreter ABI Platform
sphinxcontrib_enum-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 538.3 kB

Release files / sphinxcontrib_enum-0.2.0.tar.gz

Download URL sphinxcontrib_enum-0.2.0.tar.gz
Size 520.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1b1d31dc880d717a556f2ca12b7b34e152c3773ce5d0f707756926e29b9899eb
BLAKE2b-256 checksum
How to use checksums
5047acc4715f28c44fc8141d350ace0278b82979e097535cad024cf9b2fb5f8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release files / sphinxcontrib_enum-0.2.0-py3-none-any.whl

Download URL sphinxcontrib_enum-0.2.0-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63528ab06734e8b674b936780bfe814aa369a7eb26392a5aaa3e53ddb0357e92
BLAKE2b-256 checksum
How to use checksums
105834bc612d2fbe59c175180cb58f14606cfdd3b0addefbd26379c13d63cec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page