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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file docstring-utils-1.0.0.tar.gz.

File metadata

  • Download URL: docstring-utils-1.0.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.13

File hashes

Hashes for docstring-utils-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ecbafb71ed041c63a3ba906d600fc564b90bc25b580b63a6c0d9f85d6075eda5
MD5 818c37af8a0e74cee962acc73de57435
BLAKE2b-256 734b58b1ca65a59840aea1b068660798f5eb370f6c6f3f7da465940e74b49aed

See more details on using hashes here.

File details

Details for the file docstring_utils-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for docstring_utils-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3eb2eaa6a7824e4b32204e0e1dbce057fe91e101a53f128836bcfbc2a7020460
MD5 fe5a1705da8fdea0826073bdf8f978a1
BLAKE2b-256 676f31a220cb9097961292f4868a37670c32c450b7019ef9f7cb65fdabd3c958

See more details on using hashes here.

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