Extract attributes docstrings defined in various ways
Project description
Class doc
Small set of helpers aimed to extract class attributes documentation from the class definition. This stuff tries to mimic sphinx-autodoc behaviour as closely as possible (except instance attributes defined inside __init__
function).
The main advantage of this project over sphinx-autodoc is that it is lightweight single-purpose dependency, while autodoc just a small part of really heavy project.
Installation
This package is available on PyPI
pip install 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."""
baf = 3
"""
Even
multiline
docstrings
handled
properly
"""
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."],
"baf": ["Even", "multiline", "docstrings", "handled", "properly"]
}
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
File details
Details for the file class-doc-0.2.6.tar.gz
.
File metadata
- Download URL: class-doc-0.2.6.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.9.0 Linux/5.4.0-62-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5e036ed9b7f6de528affdd9f038851910b342d4c1c1252983a55ff080b530e0 |
|
MD5 | e624e059fd5d2b6f6e5a6c479f1f9208 |
|
BLAKE2b-256 | 891e4378f484ba489255a8f523feb381f792eb195745a709b56efc46a22a333d |
File details
Details for the file class_doc-0.2.6-py3-none-any.whl
.
File metadata
- Download URL: class_doc-0.2.6-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.9.0 Linux/5.4.0-62-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6f2cea2dfbe93f76dee25de13d70dc0d2269698e8b849f751d98dc894c52ea5 |
|
MD5 | 8a80851dc87a51f9f8eb4683ad40856e |
|
BLAKE2b-256 | a6336b4051860e772581f59f671e878178cab4c115b5a6e3df1921d5a2384518 |