# runtime-docstrings
Runtime access to Python class attribute docstrings (PEP 224)
## Installation
```bash
pip install runtime-docstrings
```
## Usage
### Class
```python
from runtime_docstrings import docstrings, get_docstrings
@docstrings
class Person:
"""A person with various attributes."""
name: str
"""The person's full name."""
email: str
"""Contact email address."""
age: int = 0
"""The person's age in years."""
# Access docstrings map directly on class (IDE style)
docs = get_docstrings(Person)
print(docs["name"]) # "The person's full name."
print(docs["age"]) # "The person's age in years."
print(docs["email"]) # "Contact email address."
# Access via PEP 224 style attributes (uses Python MRO lookup)
print(Person.__doc_name__) # "The person's full name."
print(Person.__doc_age__) # "The person's age in years."
print(Person.__doc_email__) # "Contact email address."
```
### Enum
```python
from enum import Enum
from runtime_docstrings import docstrings
@docstrings
class Status(Enum):
"""Status enumeration for task tracking."""
PENDING = "pending"
"""Task is waiting to be processed."""
RUNNING = "running"
"""Task is currently being executed."""
COMPLETED = "completed"
"""Task has finished successfully."""
FAILED = "failed"
"""Task encountered an error."""
# Supports all the standard class access patterns
# Access via enum member __doc__ attribute
print(Status.PENDING.__doc__) # "Task is waiting to be processed."
print(Status.COMPLETED.__doc__) # "Task has finished successfully."
# Iterate through all members with their documentation
for member in Status:
if member.__doc__:
print(f"{member.name}: {member.__doc__}")
```
### Dataclass
```python
from dataclasses import dataclass, fields
from runtime_docstrings import docstrings, get_docstrings
@docstrings
@dataclass
class Product:
"""A product in an e-commerce system."""
name: str
"""Product name."""
price: float
"""Price in USD."""
category: str = ""
"""Product category."""
description: str = ""
"""Detailed product description."""
# Supports all the standard class access patterns
# Access via dataclass field metadata
for field in fields(Product):
if field.metadata.get("__doc__"):
print(f"{field.name}: {field.metadata['__doc__']}")
```
Raw data
{
"_id": null,
"home_page": null,
"name": "runtime-docstrings",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "docstrings, PEP 224, pep224, class attributes, error reporting, enum, dataclasses, ast, sphinx, autodoc",
"author": "gesslerpd",
"author_email": "gesslerpd <gesslerpd@users.noreply.github.com>",
"download_url": "https://files.pythonhosted.org/packages/99/0c/57c4ad1eb05400116583ebc2521e77d873c00988b3428e55a157d685429e/runtime_docstrings-0.1.2.tar.gz",
"platform": null,
"description": "\n# runtime-docstrings\n\nRuntime access to Python class attribute docstrings (PEP 224)\n\n## Installation\n\n```bash\npip install runtime-docstrings\n```\n\n## Usage\n\n### Class\n\n```python\nfrom runtime_docstrings import docstrings, get_docstrings\n\n@docstrings\nclass Person:\n \"\"\"A person with various attributes.\"\"\"\n \n name: str\n \"\"\"The person's full name.\"\"\"\n\n email: str\n \"\"\"Contact email address.\"\"\"\n\n age: int = 0\n \"\"\"The person's age in years.\"\"\"\n\n# Access docstrings map directly on class (IDE style)\ndocs = get_docstrings(Person)\nprint(docs[\"name\"]) # \"The person's full name.\"\nprint(docs[\"age\"]) # \"The person's age in years.\"\nprint(docs[\"email\"]) # \"Contact email address.\"\n\n# Access via PEP 224 style attributes (uses Python MRO lookup)\nprint(Person.__doc_name__) # \"The person's full name.\"\nprint(Person.__doc_age__) # \"The person's age in years.\"\nprint(Person.__doc_email__) # \"Contact email address.\"\n```\n\n### Enum\n\n```python\nfrom enum import Enum\nfrom runtime_docstrings import docstrings\n\n@docstrings\nclass Status(Enum):\n \"\"\"Status enumeration for task tracking.\"\"\"\n \n PENDING = \"pending\"\n \"\"\"Task is waiting to be processed.\"\"\"\n \n RUNNING = \"running\"\n \"\"\"Task is currently being executed.\"\"\"\n \n COMPLETED = \"completed\"\n \"\"\"Task has finished successfully.\"\"\"\n \n FAILED = \"failed\"\n \"\"\"Task encountered an error.\"\"\"\n\n# Supports all the standard class access patterns\n\n# Access via enum member __doc__ attribute\nprint(Status.PENDING.__doc__) # \"Task is waiting to be processed.\"\nprint(Status.COMPLETED.__doc__) # \"Task has finished successfully.\"\n\n# Iterate through all members with their documentation\nfor member in Status:\n if member.__doc__:\n print(f\"{member.name}: {member.__doc__}\")\n```\n\n### Dataclass\n\n```python\nfrom dataclasses import dataclass, fields\nfrom runtime_docstrings import docstrings, get_docstrings\n\n@docstrings\n@dataclass\nclass Product:\n \"\"\"A product in an e-commerce system.\"\"\"\n \n name: str\n \"\"\"Product name.\"\"\"\n \n price: float\n \"\"\"Price in USD.\"\"\"\n\n category: str = \"\"\n \"\"\"Product category.\"\"\"\n \n description: str = \"\"\n \"\"\"Detailed product description.\"\"\"\n\n# Supports all the standard class access patterns\n\n# Access via dataclass field metadata\nfor field in fields(Product):\n if field.metadata.get(\"__doc__\"):\n print(f\"{field.name}: {field.metadata['__doc__']}\")\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Runtime access to Python class attribute docstrings (PEP 224)",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/gesslerpd/runtime-docstrings",
"Issues": "https://github.com/gesslerpd/runtime-docstrings/issues",
"Repository": "https://github.com/gesslerpd/runtime-docstrings"
},
"split_keywords": [
"docstrings",
" pep 224",
" pep224",
" class attributes",
" error reporting",
" enum",
" dataclasses",
" ast",
" sphinx",
" autodoc"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "1178420392fa107c823ac610890a27b2914a59881152728169b3489f67a58f99",
"md5": "b908e4925b7b4cc213662aaecf16bd98",
"sha256": "62b472efeac32026bdbd1fad5712275055964d5228f4029899998c649a399c42"
},
"downloads": -1,
"filename": "runtime_docstrings-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b908e4925b7b4cc213662aaecf16bd98",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 3868,
"upload_time": "2025-07-28T22:43:08",
"upload_time_iso_8601": "2025-07-28T22:43:08.011439Z",
"url": "https://files.pythonhosted.org/packages/11/78/420392fa107c823ac610890a27b2914a59881152728169b3489f67a58f99/runtime_docstrings-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "990c57c4ad1eb05400116583ebc2521e77d873c00988b3428e55a157d685429e",
"md5": "c2d1d715c21b5138ac471a2b4a87825f",
"sha256": "a49b74d537ede417124e9b93cefd8791b63106c5e98add827716146f96e8b9b9"
},
"downloads": -1,
"filename": "runtime_docstrings-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "c2d1d715c21b5138ac471a2b4a87825f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 2870,
"upload_time": "2025-07-28T22:43:09",
"upload_time_iso_8601": "2025-07-28T22:43:09.003486Z",
"url": "https://files.pythonhosted.org/packages/99/0c/57c4ad1eb05400116583ebc2521e77d873c00988b3428e55a157d685429e/runtime_docstrings-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-28 22:43:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gesslerpd",
"github_project": "runtime-docstrings",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "runtime-docstrings"
}