Skip to main content

runtime-docstrings

Runtime access to Python class attribute docstrings (PEP 224)

Installation

pip install runtime-docstrings

Usage

Class

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

Enums support lazy parsing of member docstrings, the decorator will not add overhead until you access the docstring of a member for the first time.

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 these standard class access patterns
docs = get_docstrings(Status)
print(docs["COMPLETED"])   # "Task has finished successfully."

# 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

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__']}")

Release files for runtime-docstrings 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for runtime-docstrings 0.2.0
File Size Uploaded
runtime_docstrings-0.2.0.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for runtime-docstrings 0.2.0
File Interpreter ABI Platform
runtime_docstrings-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 kB

Release files / runtime_docstrings-0.2.0.tar.gz

Download URL runtime_docstrings-0.2.0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a14a2adea1572e59b18f6987cafdf8f1926a4ebd9ef26184bc30fb534669c39f
BLAKE2b-256 checksum
How to use checksums
9ef5e6f48310b710024a28b78a5f9929c325c04b509b89cc2eed10b59ea2dd53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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 / runtime_docstrings-0.2.0-py3-none-any.whl

Download URL runtime_docstrings-0.2.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1eaecb3307db53e3f4e0dc494ee68d566812ae836117a8f689df2e5b21462873
BLAKE2b-256 checksum
How to use checksums
d6e51f4b5245d445b7917e540d1946ddc6de8839191c5e013157a10c2b598b4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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 history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page