Skip to main content

Add structured information to the end of your python docstrings.

Project description

Docdata

Tests Cookiecutter template from @cthoyt PyPI PyPI - Python Version PyPI - License Documentation Status DOI

Add structured information to the end of your python docstrings.

💪 Getting Started

Use this package to add structured data to your docstrings in YAML. Just add a --- delimiter at the bottom, and the rest is parsed as YAML.

from docdata import parse_docdata, get_docdata


@parse_docdata
class MyClass:
    """This is my class.

    ---
    author: Charlie
    motto:
    - docs
    - are
    - cool
    """


assert get_docdata(MyClass) == {
    'author': 'Charlie',
    'motto': ['docs', 'are', 'cool'],
}

If you want to get the data directly, go for MyClass.__docdata__. If you want to change the way docdata is parsed, like changing the delimiter, use keyword arguments like in:

from docdata import parse_docdata, get_docdata


@parse_docdata(delimiter='****')
class MyClass:
    """This is my class.

    ****
    author: Charlie
    motto:
    - docs
    - are
    - cool
    """


assert get_docdata(MyClass) == {
    'author': 'Charlie',
    'motto': ['docs', 'are', 'cool'],
}

⬇️ Installation

The most recent release can be installed from PyPI with:

$ pip install docdata

The most recent code and data can be installed directly from GitHub with:

$ pip install git+https://github.com/cthoyt/docdata.git

To install in development mode, use the following:

$ git clone git+https://github.com/cthoyt/docdata.git
$ cd docdata
$ pip install -e .

⚖️ License

The code in this package is licensed under the MIT License.

🙏 Contributing

Contributions, whether filing an issue, making a pull request, or forking, are appreciated. See CONTRIBUTING.rst for more information on getting involved.

🍪 Cookiecutter Acknowledgement

This package was created with @audreyr's cookiecutter package using @cthoyt's cookiecutter-python-package template.

🛠️ Development

The final section of the README is for if you want to get involved by making a code contribution.

❓ Testing

After cloning the repository and installing tox with pip install tox, the unit tests in the tests/ folder can be run reproducibly with:

$ tox

Additionally, these tests are automatically re-run with each commit in a GitHub Action.

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

docdata-0.0.3.tar.gz (11.8 kB view hashes)

Uploaded Source

Built Distribution

docdata-0.0.3-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

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