Skip to main content

Sphinx DocumentedList extension

Project description

This file provides a Sphinx extension to convert a Python list into a table in the generated documentation. The intended application of this extension is to document the items of essentially list-like objects of immutable data (possibly enums, though python 3.4 enums are not supported yet).

In the source code, each list item, instead of being just it’s native data type, should be replaced by a tuple of two elements. The second element of the tuple should be a string which provides a description for the item.

In the first use of this extension, the aim is to document a list of supported device classes (each of which is a string). This was originally specified in the python code as a list, and the same list with descriptions was manually maintained (or, in reality, left unmaintained) in the corresponding documentation. The list is now replaced with a tuple containing both the recognized strings and the description for each, and Sphinx is able to use this extension to ‘autogenerate’ the table in the documentation.

Based heavily on slides from Doug Hellman’s PyCon talk, http://www.slideshare.net/doughellmann/better-documentation-through-automation-creating-docutils-sphinx-extensions

Installation & Usage

To use this module, place the documentedlist.py file somewhere in the PYTHONPATH that Sphinx is configured to use, or add the git checkout folder to the PYTHONPATH in Sphinx’s conf.py.

In the .rst file where the table should appear, insert the Sphinx directive provided by this module :

.. documentedlist::
    :listobject: full.importable.path.of.thelist

This extension will import the list as :

from full.importable.path.of import thelist

Optionally, the headers to be displayed in the table can also be specified. The number of columns displayed is 2 by default, and if more columns are desired, the headers should be manually specified with as many columns as needed, for example

foo.py :

lst = [
   ["John", "Doe", "john@example.com"]
]

example.rst :

.. documentedlist::
    :listobject: foo.lst
    :header: "First Name" "Last Name" Email

For a usage example, see:

https://github.com/chintal/tendril/blob/public/tendril/conventions/electronics.py#L28

and the corresponding documentation generated at:

http://tendril.chintal.in/doc/userdoc/conventions/gedasymbols/#device-classes

License

This Sphinx Extension is made available under the BSD 2-clause License. See sphinxcontrib’s LICENSE file for the full text.

Project details


Download files

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

Source Distribution

sphinxcontrib-documentedlist-0.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file sphinxcontrib-documentedlist-0.2.tar.gz.

File metadata

File hashes

Hashes for sphinxcontrib-documentedlist-0.2.tar.gz
Algorithm Hash digest
SHA256 4736dbca0c0e17e1633659726eaba6817e74d21bd4cb4d67cfbe540588fdb6b3
MD5 30cc25ccf4ed88b9f1c2c2dd264867ee
BLAKE2b-256 050a00fc1a06dae66e4ef76ba11b0387e47fb8be703ff4106a8689da94e42181

See more details on using hashes here.

Provenance

File details

Details for the file sphinxcontrib_documentedlist-0.2-py2-none-any.whl.

File metadata

File hashes

Hashes for sphinxcontrib_documentedlist-0.2-py2-none-any.whl
Algorithm Hash digest
SHA256 f50c6b48ee7cad7a9f4701992d8b23131726438f717a0890f3cda6070ff05de7
MD5 8f73811dcc65760d6eefd3c9d60edfc3
BLAKE2b-256 34ebb4725baccd75b5dd76e94d92dbf41f1b4d34c80ad5e32dcfaa8108a3e4db

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page