Skip to main content

Sphinx extension to autodoc for apischema annotated classes/functions

Project description

Code CI Docs CI Test Coverage Latest PyPI version Apache License

Sphinx extension to autodoc for apischema annotated classes/functions

PyPI pip install sphinx-apischema
Source code https://github.com/dls-controls/sphinx-apischema
Documentation https://dls-controls.github.io/sphinx-apischema
Changelog https://github.com/dls-controls/sphinx-apischema/blob/master/CHANGELOG.rst

If you have a class that looks like this:

from dataclasses import dataclass
from apischema import schema
from typing_extensions import Annotated as A

@dataclass
class MyClass:
    """Holds some very useful information about an object.

    We might use this in a registry of all the objects we have
    """

    name: A[str, schema(description="The name of the object")]
    age: A[float, schema(description="How old it is", min=0.0, max=1000.0)] = 5

    def summary(
        self,
        hide_age: A[bool, schema(description="Be secretive about the true age")] = True,
    ) -> str:
        """Return a nicely formatted summary of the object"""
        age = "***" if hide_age else self.age
        return f"{self.name}: {age}"

Generates documenation that looks like this:

MyClass

See https://dls-controls.github.io/sphinx-apischema for more detailed documentation.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx-apischema-0.1.tar.gz (5.9 kB view hashes)

Uploaded source

Built Distribution

sphinx_apischema-0.1-py3-none-any.whl (10.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page