Skip to content

Parse Python docstrings in various flavors.

License

Notifications You must be signed in to change notification settings

OmarAlJarrah/docstring_parser

 
 

Repository files navigation

docstring_parser

Build

Parse Python docstrings. Currently support ReST, Google, Numpydoc-style and Epydoc docstrings.

Example usage:

>>> from docstring_parser import parse
>>>
>>>
>>> docstring = parse(
...     '''
...     Short description
...
...     Long description spanning multiple lines
...     - First line
...     - Second line
...     - Third line
...
...     :param name: description 1
...     :param int priority: description 2
...     :param str sender: description 3
...     :raises ValueError: if name is invalid
...     ''')
>>>
>>> docstring.long_description
'Long description spanning multiple lines\n- First line\n- Second line\n- Third line'
>>> docstring.params[1].arg_name
'priority'
>>> docstring.raises[0].type_name
'ValueError'

Read API Documentation.

Installation

Installation using pip

pip install docstring_parser

# or if you want to install it in a virtual environment

python -m venv venv # create environment
source venv/bin/activate # activate environment
python -m pip install docstring_parser

Installation using conda

  1. Download and install miniconda or anaconda
  2. Install the package from the conda-forge channel via:
  • conda install -c conda-forge docstring_parser
  • or create a new conda environment via conda create -n my-new-environment -c conda-forge docstring_parser

Contributing

To set up the project:

pip install --user poetry

git clone https://github.com/rr-/docstring_parser.git
cd docstring_parser

poetry install
poetry run pre-commit install

To run tests:

poetry run pytest

About

Parse Python docstrings in various flavors.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%