Docstring Parser Fork
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
- gotcha This library is a fork of `docstring_parser` and shares the same import path (`from docstring_parser import ...`). If both the original `docstring_parser` and `docstring-parser-fork` are installed, unexpected behavior or conflicts may occur due to Python's import resolution order.
- breaking The fork explicitly fixes bugs and offers additional functionalities compared to the upstream `docstring_parser`. While intended as improvements, users migrating from the original library should review the `CHANGELOG.md` file for entries marked '(Fork)' to understand specific behavioral changes that might affect existing code relying on previous `docstring_parser` quirks or omissions.
- gotcha When parsing attribute docstrings, the `parse_from_object` function currently only supports attributes defined at class and module levels. Attribute docstrings defined within `__init__` methods are not supported. Additionally, when given a class, only attribute docstrings of that specific class are parsed, not inherited ones.
Install
-
pip install docstring-parser-fork -
conda install -c conda-forge docstring_parser
Imports
- parse
from docstring_parser import parse
- DocstringStyle
from docstring_parser import DocstringStyle
Quickstart
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}")