Extract attributes docstrings defined in various ways
Project description
Class doc
Small set of helpers aimed to extract class attributes documentation from a class definition, closely mimicking sphinx-autodoc behaviour (except instance attributes defined inside __init__
function).
The main motivation for this project is undesirable integration of really heavy sphinx-autodoc dependency, also sphinx is usually used for development purposes. As opposite class-doc is light, serves a specific purpose and might be easily integrated in any project.
Installation
This package available on PyPI
pip install class-doc
Or using Poetry
poetry add class-doc
Examples
Shamely stolen from sphinx-autodoc docs
class Foo:
"""Docstring for class Foo."""
#: Doc comment for class attribute Foo.bar.
#: It can have multiple lines.
bar = 1
flox = 1.5 #: Doc comment for Foo.flox. One line only.
baz = 2
"""Docstring for class attribute Foo.baz."""
import class_doc
assert class_doc.extract_docs_from_cls_obj(Foo) == {
"bar": ["Doc comment for class attribute Foo.bar.", "It can have multiple lines."],
"flox": ["Doc comment for Foo.flox. One line only."],
"baz": ["Docstring for class attribute Foo.baz."],
}
Development setup
Project requires Poetry for development setup.
- If you aren't have it already
pip install poetry
- Install project dependencies
poetry install
- Run tests
poetry run pytest .
- Great, all works!
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
Hashes for class_doc-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d2f077c24607dcdd7c3287f8fe0a111a34793fed4447236595d5d12cb1acacd |
|
MD5 | dec6535c6931be1e3868052a5b1ac4cf |
|
BLAKE2b-256 | 73a9e8f3652b7a938f6ef3fae0999e3d94f6b18115a0aceaf7613fbabf12c73d |