Skip to main content

Parser for Numpy, Sphinx, and Google-style docstrings

Project description

docstring-utils

build version license discord

Simple parser for Numpy, Sphinx, and Google-style docstrings

📥 Installation

pip install -U docstring-utils

Requirements: Python 3.7+

🧑‍💻 Usage

Parse docstring

from docstring_utils import parse_docstring

def example(arg1: str, arg2: int) -> int:
    """Example of a Google-style docstring.

    Args:
        arg1 (str): Description of `arg1`.
        arg2 (int): Description of `arg2`.

    Returns:
        int: Description of `return` value.
    """
    return 0

result = parse_docstring(example, filter_args=True)

print(result.description)  # "Example of a Google-style docstring."

args = result.args.values()
print(args[0].name)  # "arg1"
print(args[0].description)  # "Description of `arg1`."
print(args[0].type)  # "str"

print(result.return_value.type)  # "int"
print(result.return_value.description)  # "Description of `return` value."

🧰 Development

Running tests

  1. Install tox with the command pip install -U tox

  2. Run tests with the command tox

Linting

Run the following command to lint with flake8

python setup.py lint

(Note: The exact command may vary depending on your Python version and environment)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docstring-utils-1.0.0.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

docstring_utils-1.0.0-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page