A simple dataclasses wrapper for easier documentation of dataclasses
Project description
This is a work-in-progress library to add documentation functionality to dataclasses introduced in Python 3.7. The library can be used as a drop-in replacement for the standard dataclasses and can be installed from PyPI.
$ pip install literate_dataclasses
Literate dataclasses modify their own class docstrings and add attribute docs in [Google code style](https://google.github.io/styleguide/pyguide.html) with the goal of removing redundant code. The docs can be written as follows:
from literate_dataclasses import dataclass, field
@dataclass(test_arg = "hello")
class Test:
"""My dataclass
Some comment.
Args:
See dataclass signature.
"""
x: int = field(default = 42, doc = \
"""Some value x."""
)
y: int = field(default = 72, doc = \
"""Some value x."""
)
name: int = field(default = 'foo', doc = \
"""The object name.""",
)
test = Test(x = 5, y = 3)
help(Test)
which will generate the output
Help on class Test in module __main__:
class Test(builtins.object)
| Test(x: int = 42, y: int = 72, name: int = 'foo') -> None
|
| My dataclass
|
| Some comment.
|
| Args:
| x: Some value x.
| y: Some value x.
| name: The object name.
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
Close
Hashes for literate_dataclasses-0.0.4a0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9df2358b579bfa3d5e52eb2f70bf9ceaaa123ccf5e1a11e39c8f84fc8b58386 |
|
MD5 | 8e2b632ebf73493084c92ad6b5ebee1f |
|
BLAKE2b-256 | c2f43710085ce2014d5df3c92da331320d9910957ee6a5a71e2197d83539f47b |
Close
Hashes for literate_dataclasses-0.0.4a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 413652fa5cabab6fe4a21d5f51bfea34483a7ad13bd9718702f6aa10a149aa8a |
|
MD5 | 9d62655381e13064a798968f9974cbaf |
|
BLAKE2b-256 | 4156800cfabc2dc4b71fb0e5638e03797725b343c03014e178f33471f7a57fce |