attributes-doc
Hacky implementation of PEP 224.
Usage
This package provides the following functions:
attributes_docget_attributes_docenum_docget_doc
Decorator attributes_doc
This function is a class decorator, and using it on a class will set class attributes called __doc_ATTRNAME__ for each existing attribute.
from attributes_doc import attributes_doc
@attributes_doc
class Foo:
bar = 1
"""This is the docstring for the bar attribute.
It will be stored in `Foo.__doc_bar__` and will be accessible at runtime.
"""
baz = 2
"""This is the docstring for the baz attribute."""
print(Foo.__doc_bar__)
print(getattr(Foo, "__doc_baz__"))
Function get_attributes_doc
This function will return a dictionary with the docstrings for all attributes of a class without setting them.
from attributes_doc import get_attributes_doc
class Goo:
"""This class doesn't use attributes_doc and we don't want to modify it at all."""
bar = 1
"""This is the docstring for the bar attribute."""
baz = 2
"""This is the docstring for the baz attribute."""
docs = get_attributes_doc(Goo)
print(docs["bar"])
print(docs["baz"])
Decorator enum_doc
This is also a class decorator, but it is intended for Enum classes. Instead of setting one doc attribute per attribute to the containing class, it will set the __doc__ attribute for each enum value.
from attributes_doc import enum_doc
from enum import Enum
@enum_doc
class Foo(Enum):
bar = 1
"""This is the docstring for the bar attribute."""
baz = 2
"""This is the docstring for the baz attribute."""
print(Foo.bar.__doc__)
Function get_doc
This function will return the docstring of an attribute of a class.
from attributes_doc import get_doc
print(get_doc(Foo, "baz")) # Instead of getattr(Foo, "__doc_baz__") above
Metadata
Release files for attributes-doc 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| attributes_doc-0.5.0.tar.gz | 37.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| attributes_doc-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.6 kB
Release files / attributes_doc-0.5.0.tar.gz
| Download URL | attributes_doc-0.5.0.tar.gz |
|---|---|
| Size | 37.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b29ceb27ccaa85748df19b1c955c7675afca66bc3b1442181d0019b0a79a33a
|
|
BLAKE2b-256 checksum How to use checksums |
92ff2eab11806e8b0cc7163994617ac78e8548f024b2e1d93d967c6a3cc3a713
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / attributes_doc-0.5.0-py3-none-any.whl
| Download URL | attributes_doc-0.5.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
153c62f0e175e8e4697802f201683356abdb83b1bd2e9aa2737f972fec2a13eb
|
|
BLAKE2b-256 checksum How to use checksums |
0a7e91130f0b88af2ef58734cae8e645bf64a2e3de87f8b474a1d2a7a9936aac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|