Skip to main content

docsource: Parse, check and update doc-string documentation

docsource parses Python documentation strings (a.k.a. doc-string) for (data) classes and functions.

A doc-string is broken down into the following components:

  • A short description, which is the first block of text in the documentation string, and ends with a double newline or a parameter block.
  • A long description, which is the optional block of text following the short description, and ends with a parameter block.
  • A structured signature specification block, either in reST or Google style.

reST-style specification blocks consist of the following:

  • A parameter block of named parameter and description string pairs each declared with param.
  • A returns declaration, which adds explanation to the return value.
  • A raises declaration, which adds explanation to the exception type raised by the function on error.
class SampleClass:
    def instance_method(self, a: str, b: int | None) -> str:
        """
        Short description of an instance method.

        :param a: Short description for `a`.
        :param b: Short description for `b`.
        :returns: A return value.
        :raise TypeError: A type exception rarely raised.
        :raise ValueError: A value exception rarely raised.
        :raise CustomException: A custom exception.
        """
        return ""

In contrast, Google-style specification blocks consist of:

  • The label Arguments:, followed by an indented list of parameters, each with their description.
  • The label Returns:, which captures the return value description in an indented block.
  • The label Raises:, followed by an indented list of exception types, each with their description.
class SampleClass:
    def instance_method(self, a: str, b: int | None) -> str:
        """
        Short description of an instance method.

        Arguments:
            a: Short description for `a`.
            b: Short description for `b`.
        Returns:
            A return value.
        Raises:
            TypeError: A type exception rarely raised.
            ValueError: A value exception rarely raised.
            CustomException: A custom exception.
        """
        return ""

When the doc-string is attached to a data class, it is understood as the documentation string of the class __init__ method.

Compliance

docsource verifies if

  • parameters listed in the function doc-string have corresponding parameters in the function signature,
  • parameters declared in a function signature have corresponding doc-string entries (strict mode only),
  • data-class members listed in the function doc-string have corresponding member variables in the data-class definition,
  • members declared in a data-class have corresponding doc-string entries (strict mode only).

Enumerations

Python's own doc-string mechanism doesn't allow attaching a description to enumeration members. However, documentation toolchains such as Sphinx's autodoc support this with a string literal immediately following the enumeration member value assignment:

@enum.unique
class EnumType(enum.Enum):
    ENABLED = "enabled"
    "Documents the enumeration member `ENABLED`."

    DISABLED = "disabled"
    "Documents the enumeration member `DISABLED`."

docsource can parse source code with Python's ast module to extract these description text strings.

Documentation style

docsource can normalize code documentation by reading source code (with Python's ast), identifying doc-string literals, parsing doc-string text, and producing a standardized doc-string with short description, and reST-style parameter, return value and exception declarations.

Refer to the source

  • The function parse_type parses a reST-style doc-string attached to a class or function into doc-string components, encapsulated in the class Docstring.
  • The function parse_text parses raw doc-string text into its components.
  • check_docstring verifies data-class and function doc-string text.
  • enum_labels extracts textual description for enumeration members.
  • update_docstring standardizes doc-string literals in Python source code.

Metadata

Release files for docsource 0.1.1

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

Source distribution (sdist)

Source distribution for docsource 0.1.1
File Size Uploaded Provenance Actions
docsource-0.1.1.tar.gz 15.7 kB With provenance Details for docsource-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for docsource 0.1.1
File Interpreter ABI Platform Actions
docsource-0.1.1-py3-none-any.whl Python 3 none any Details for docsource-0.1.1-py3-none-any.whl

Total release size: 29.6 kB

Release files / docsource-0.1.1.tar.gz

Download URL docsource-0.1.1.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fc98f310b9b121568871e6412c50adf124cc2cc67d77dbf30c2496c8c688148e
BLAKE2b-256 checksum
How to use checksums
7c2610f49dac39be0883e7bc81282efb04d4ad4b97a751c7867ca7ecd518720a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / docsource-0.1.1-py3-none-any.whl

Download URL docsource-0.1.1-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2453e47e6e008b97cd186c680675d546578eb26c0a0825fbaf81229b2e9fa954
BLAKE2b-256 checksum
How to use checksums
c5f65c2df806983bde48d5f6683fc6d21988791179b3afc5ae28503c4062ed75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for docsource 0.1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for docsource-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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