Registry / serialization / class-doc

class-doc

JSON →
library0.2.6pypypi✓ verified 85d ago

A library to extract attributes docstrings defined in various ways, such as class attributes, NamedTuple fields, or dataclass fields. Current version 0.2.6, released 2025-01-29, maintained infrequently.

pip install class-doc
INSTALL
IMPORT
SIG · CLASS-DOC
C
class-doc
serializationpythonv0.2.6
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

extract_docs
from class_doc import extract_docs
from class_doc import attr_doc
extract_all_attr_docstrings
from class_doc import extract_all_attr_docstrings
UniversalAssign
from class_doc import UniversalAssign

Basic usage: annotate class attributes with a comment after a type annotation, then call attr_doc to extract them.

from class_doc import attr_doc class Employee: name: str = 'default' # Employee name age: int = 0 # Age in years # Extract docstrings docs = attr_doc(Employee) print(docs) # {'name': 'Employee name', 'age': 'Age in years'}
Debug
Known issues
gotchaAttribute docstrings must be on the same line as the type annotation and value, after the comma or default value. They are not standard docstrings but trailing comments.
fix
Ensure each attribute is defined as 'name: type = default  # docstring'. The comment must be at the end of the line.
affects: all
gotchaOnly works with type-annotated attributes (PEP 526). Attributes without type hints or with only a comment before the variable will be ignored.
fix
Add type annotations to all attributes you want to extract docstrings from.
affects: all
deprecatedThe library may not be actively maintained; last release was in 2025. No known deprecations.
fix
Consider alternative libraries like 'docstring_parser' or using 'typing.get_type_hints' with comments manually.
affects: 0.2.6
Upgrade
Version history
0.2.6latest on PyPI · released Feb 5, 2021
Audit
Dependencies
typing_extensionsoptionalUsed for Literal type in older Python versions
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
class-doc — pip install class-doc · libregistry