Docstring Parser Fork

0.0.14 · active · verified Sun Apr 12

This is a fork of `docstring_parser`, designed to address bugs and introduce additional functionalities not present in the upstream library. It supports parsing docstrings in reStructuredText, Google, Numpydoc, and Epydoc formats. The project appears to have an irregular release cadence, with the latest version 0.0.14 published in September 2025.

Warnings

Install

Imports

Quickstart

This example demonstrates how to parse a function's docstring using the `parse` function and access its components like short description, long description, parameters, and raised exceptions. The `DocstringStyle.AUTO` option attempts to automatically detect the docstring format.

from docstring_parser import parse, DocstringStyle

def example_function(name: str, priority: int = 1) -> None:
    """
    Short description.

    Long description spanning multiple lines
    - First line
    - Second line
    - Third line

    :param name: description 1
    :param int priority: description 2
    :raises ValueError: if name is invalid
    """
    pass

docstring = parse(example_function.__doc__, style=DocstringStyle.AUTO)

print(f"Short description: {docstring.short_description}")
print(f"Long description: {docstring.long_description}")
for param in docstring.params:
    print(f"Param: {param.arg_name}, Type: {param.type_name}, Description: {param.description}")
for rais in docstring.raises:
    print(f"Raises: {rais.type_name}, Description: {rais.description}")

view raw JSON →