Skip to main content

A script to add docstrings to Python type stubs using reflection

Project description

docify

A script to add docstrings to Python type stubs using reflection

Features

  • Uses LibCST to parse and modify the stub file
  • Dynamically imports the actual module to get the runtime docstring
  • Handles most sys.version and sys.platform conditional blocks, will only add docstrings to the correct branch
  • Able to modify files in-place with -i or --in-place
  • Won't overwrite existing docstrings
  • With -b or --builtins-only, will only add docstrings for modules found in sys.builtin_module_names (stdlib modules written in C).
  • With --if-needed, will only add docstrings if the object's (Python) source code is unavailable. Useful for language servers like basedpyright that are able to extract docstrings from source code.

Installation

Install from PyPI:

pip install docify

docify
# or
python -m docify

Or from conda-forge:

conda install conda-forge::docify

docify
# or
python -m docify

Or just download and run the script directly:

# Install dependencies
pip install libcst tqdm  # tqdm is optional, and is only used if not running with -q

python docify.py
# or
python -m docify
# or
chmod +x docify.py
./docify.py

Usage

docify [-h] [-V] [-v] [-q] [-b] [--if-needed] (-i | -o OUTPUT_DIR) INPUT_DIR [INPUT_DIR ...]

A script to add docstrings to Python type stubs using reflection

positional arguments:
  INPUT_DIR             directory to read stubs from

options:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -v, --verbose         increase verbosity
  -q, --quiet           decrease verbosity
  -b, --builtins-only   only add docstrings to modules found in `sys.builtin_module_names`
  --if-needed           only add a docstring if the object's source code cannot be found
  --workers WORKERS     set the number of worker processes to use. Use 1 to disable multiple processes, and 0 to auto-detect using the number of processors (default)
  -i, --in-place        modify stubs in-place
  -o, --output OUTPUT_DIR
                        directory to write modified stubs to

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

docify-1.2.1.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docify-1.2.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file docify-1.2.1.tar.gz.

File metadata

  • Download URL: docify-1.2.1.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for docify-1.2.1.tar.gz
Algorithm Hash digest
SHA256 ed565259a3b20cd754438405b7830e12579f2223bb3c3f13c8e9318c258bc0a8
MD5 8fcf4c9b040aaf73713325a8f96b4ef0
BLAKE2b-256 f7658df7c9dbddefd5bc31474a9f2cdaa75b9f56a0c4d4b196957ef4b9aaf509

See more details on using hashes here.

File details

Details for the file docify-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: docify-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for docify-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f5527e54b3b6c4e6ce13b31a0e68756e6a2fc01840a5247b457e49d88d87f9fa
MD5 1bc42ff7ffaee981e8e25839f70a2019
BLAKE2b-256 856dc7fc3387a7c91d57e1350d6c4b7ac0093b266eb4f0e78030622d2807e483

See more details on using hashes here.

Supported by

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