Sphinx extension to autodoc traitlets
Project description
autodoc-traits
autodoc-traits
is a Sphinx extension that influences
sphinx.ext.autodoc
's provided Sphinx directives, specifically
autoclass
and autoattribute
, to better document classes with
Traitlets based configuration.
The autoclass
directive is updated to document class attributes inheriting
from traitlets.TraitType
by default. The autoattribute
directive is
updated to provide a header looking like default_url c.KubeSpawner.default_url = Unicode('')
.
The extension also provides the autoconfigurable
directive mapping to the
autoclass
directive, and the autotrait
directive mapping to the
autoattributes
directive.
How to use it
-
Install
autodoc-traits
:pip install autodoc-traits
-
Configure Sphinx to use the
autodoc_traits
andsphinx.ext.autodoc
extensions in a Sphinx projectsconf.py
file:# -- General Sphinx configuration -------------------------------------------- # ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration # extensions = [ "autodoc_traits", "sphinx.ext.autodoc", # ... ]
-
Make use of a
sphinx.ext.autodoc
Sphinx directive likeautoclass
, orautomodule
that make use ofautoclass
:From a .rst document:
.. autoclass:: KubeSpawner
Use with MyST Parser
While you can use myst-parser
, sphinx.ext.autodoc
's directives emits
unparsed rST, forcing us to parse the autodoc directives in a rST context.
From a .md document, with myst-parser
:
```{eval-rst}
.. autoclass:: KubeSpawner
```
Due to this, also the Python docstrings are required to be in rST as well. Addressing this can be tracked from executablebooks/team-compass issue #6.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file autodoc-traits-1.0.0.tar.gz
.
File metadata
- Download URL: autodoc-traits-1.0.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 624cf1ef6619921a19e197bbe41c99b645bfd545c2863178d973ce1ddd33f74d |
|
MD5 | c89b95b37054461752bd7f9bb267c04d |
|
BLAKE2b-256 | 81600ec6c5830c06290f95afd55aedc764fe83125495924c804ee315b48039cd |
Provenance
File details
Details for the file autodoc_traits-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: autodoc_traits-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 716ff4979383ebec192de230d6aaba8f71bac09b9a6a34bde37ff8be39224fd0 |
|
MD5 | ebe22b46b9c68bcce4aaf09d61632c88 |
|
BLAKE2b-256 | 7de5b1a3c492cfd4f9cb39cfb6e3957af3fcdbecbb70106351aa685c5e52e368 |