title: README author: Jan-Michael Rye
Synopsis
A Python package and command-line utility to automate documentation of Python dataclasses. It can generate the following:
- Commented YAML input files which can be used as user configuration files.
- Markdown output for README files which contain the dataclass docstring and commented YAML.
Links
GitLab
Other Repositories
Usage
Command-Line Utility
The package installs the dataclass_documenter which can be used to generate the output from the command-line.
usage: dataclass_documenter [-h] [-m] [-l LEVEL] dataclass
Generate Markdown or YAML for a dataclass. Note that this will load the module
containing the target dataclass and thus execute any top-level code within
that module.
positional arguments:
dataclass The target dataclass, specified as
"<module|file>:<class>", e.g. "mypkg.mod1:MyDataclass" or
"path/to/src.py:MyDataclass".
options:
-h, --help show this help message and exit
-m, --markdown Output Markdown documentation instead of just the YAML
input file.
-l, --level LEVEL Nesting level of output. For YAML this defines the
indentation level. For Markdown this defines the header
level.
Python API
The package can also be used directly via its API.
# Import the documenter class.
from dataclass_documenter import DataclassDocumenter
# Initialize it with a custom dataclass. Here we assume that MyDataclass is a
defined dataclass.
dado = DataclassDocumenter(MyDataclass)
# Retrieve YAML and/or Markdown text.
yaml_output = dado.get_yaml()
markdown_output = dado.get_markdown()
Example
The following is an example using the dataclasses defined for the unit tests.
Dataclass Definitions
Example dataclasses to show the correpondence between the definition and the generated documentation.
@dataclasses.dataclass
class NestedExampleDataclass:
"""
Nested dataclass to test recursive documentation.
Parameters:
nested_string:
A string parameter of the nested dataclass.
nested_number:
A numerical parameter of the nested dataclass
"""
nested_string: str = "Another string value."
nested_number: int | float = 5
@dataclasses.dataclass
class ExampleDataclass: # pylint: disable=too-many-instance-attributes
"""
Brief description for example dataclass.
This is a longer description. This dataclass is used for testing and
generating an example in the README.
Parameters:
string:
A string parameter.
nested_dataclass:
A nested dataclass that encapsulates its own parameters.
integer:
An integer parameter.
floats:
A list of floats.
opt_string:
An optional string that may be None.
nested_dataclass_list:
List of nested dataclass objects for testing composite types.
"""
string: str
nested_dataclass: NestedExampleDataclass
integer: int = 7
floats: list[float] = dataclasses.field(default_factory=list)
opt_string: Optional[str] = None
undocumented_string: str = "Intentionally undocumented string."
nested_dataclass_list: list[NestedExampleDataclass] = dataclasses.field(
default_factory=list
)
nested_dataclass_dict: dict[str, NestedExampleDataclass] = dataclasses.field(
default_factory=dict
)
Markdown Output
The following is the Markdowna and YAML output automatically generated from the example dataclasses.
ExampleDataclass
Brief description for example dataclass.
This is a longer description. This dataclass is used for testing and generating an example in the README.
Input
# ExampleDataclass
# A string parameter.
# Type: str [REQUIRED]
string: ...
# A nested dataclass that encapsulates its own parameters.
nested_dataclass:
# A string parameter of the nested dataclass.
# Type: str [OPTIONAL]
nested_string: Another string value.
# A numerical parameter of the nested dataclass
# Type: UnionType[int, float] [OPTIONAL]
nested_number: 5
# An integer parameter.
# Type: int [OPTIONAL]
integer: 7
# A list of floats.
# Type: list[float] [OPTIONAL]
floats: []
# An optional string that may be None.
# Type: str [OPTIONAL]
opt_string: null
# Undocumented.
# Type: str [OPTIONAL]
undocumented_string: Intentionally undocumented string.
# List of nested dataclass objects for testing composite types.
# Type: list[NestedExampleDataclass] [OPTIONAL]
nested_dataclass_list: []
# NestedExampleDataclass
# A string parameter of the nested dataclass.
# Type: str [OPTIONAL]
# - nested_string: Another string value.
# A numerical parameter of the nested dataclass
# Type: UnionType[int, float] [OPTIONAL]
# nested_number: 5
# Undocumented.
# Type: dict[str, NestedExampleDataclass] [OPTIONAL]
nested_dataclass_dict: {}
# String key
# key:
# NestedExampleDataclass
# A string parameter of the nested dataclass.
# Type: str [OPTIONAL]
# nested_string: Another string value.
# A numerical parameter of the nested dataclass
# Type: UnionType[int, float] [OPTIONAL]
# nested_number: 5
Metadata
Release files for Dataclass-Documenter 2026.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dataclass_documenter-2026.1.tar.gz | 14.9 kB | Without provenance | Details for dataclass_documenter-2026.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dataclass_documenter-2026.1-py3-none-any.whl | Python 3 | none | any | Details for dataclass_documenter-2026.1-py3-none-any.whl |
Total release size: 26.4 kB
Release files / dataclass_documenter-2026.1.tar.gz
| Download URL | dataclass_documenter-2026.1.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e50660d330b30f4d09cba5443646ae48f9824fb6e2c4a96b271cd66d6d3bfc5
|
|
BLAKE2b-256 checksum How to use checksums |
d9ffd30360b22ed7e61daf7d613bb5094b82a32367f2f03b4373255851e87502
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / dataclass_documenter-2026.1-py3-none-any.whl
| Download URL | dataclass_documenter-2026.1-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
092685362b091b9a440f5bf28469ab729db7b79d6012a29623b5e92405d9452c
|
|
BLAKE2b-256 checksum How to use checksums |
dd124a02ec8df1e73405e483127cf7f8c793e222f875695f781a2c91f3218eaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for Dataclass-Documenter 2026.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.