sphinxcontrib-autoyaml
This Sphinx autodoc extension documents YAML files from comments. Documentation is returned as reST definitions, e.g.:
This document:
###
# Enable Nginx web server.
enable_nginx: true
###
# Enable Varnish caching proxy.
enable_varnish: true
would be turned into text:
enable_nginx
Enable Nginx web server.
enable_varnish
Enable Varnish caching proxy.
See tests/examples/output/*.yml and tests/examples/output/*.txt for
more examples.
autoyaml will take into account only comments which first line starts with
autoyaml_doc_delimiter.
Usage
You can use autoyaml directive, where you want to extract comments
from YAML file, e.g.:
Some title
==========
Documenting single YAML file.
.. autoyaml:: some_yml_file.yml
Options
# Look for YAML files relatively to this directory.
autoyaml_root = ".."
# Character(s) which start a documentation comment.
autoyaml_doc_delimiter = "###"
# Comment start character(s).
autoyaml_comment = "#"
# Parse comments from nested structures n-levels deep.
autoyaml_level = 1
# Whether to use YAML SafeLoader
autoyaml_safe_loader = False
Installing
Issue command:
pip install sphinxcontrib-autoyaml
And add extension in your project's conf.py:
extensions = ["sphinxcontrib.autoyaml"]
Caveats
Mapping keys nested in sequences
Sequences are traversed as well, but they are not represented in output documentation. This extension focuses only on documenting mapping keys. It means that structure like this:
key:
###
# comment1
- - inner_key1: value
###
# comment2
inner_key2: value
###
# comment3
- inner_key3: value
will be flattened, so it will appear as though inner keys exist directly under
key. Duplicated key documentation will be duplicated in output as well. See
tests/examples/output/comment-in-nested-sequence.txt and
tests/examples/output/comment-in-nested-sequence.yml to get a better
understanding how sequences are processed.
Complex mapping keys
YAML allows for complex mapping keys like so:
[1, 2]: value
These kind of keys won't be documented in output, because it's unclear how they should be represented as a string.
Flow-style entries
YAML allows writing complex data structures in single line like JSON. Documentation is generated only for the first key in such entry, so this:
###
# comment
key: {key1: value, key2: value, key3: value}
would yield documentation only for key.
Release files for sphinxcontrib-autoyaml 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sphinxcontrib_autoyaml-1.2.0.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sphinxcontrib_autoyaml-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.2 kB
Release files / sphinxcontrib_autoyaml-1.2.0.tar.gz
| Download URL | sphinxcontrib_autoyaml-1.2.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c6cb45afac75ee7e8f9d23ca3dbd26ce276589e75ba98d67dc661befbdfde5a
|
|
BLAKE2b-256 checksum How to use checksums |
d206821cc7828c78d3b9e94b95834998990d9906e43294c944f3c43c0c7b4d8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / sphinxcontrib_autoyaml-1.2.0-py3-none-any.whl
| Download URL | sphinxcontrib_autoyaml-1.2.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df0318b81e742b42b4b8af1a2694fd5777d87b8822006f026b79efb9083264bb
|
|
BLAKE2b-256 checksum How to use checksums |
9f113fdf841032a99f5cc1a7c9632955591c0b4706b0e04e48bf1fc994cc30c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|