Skip to main content

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

Release files for docify 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docify 1.2.1
File Size Uploaded
docify-1.2.1.tar.gz 30.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for docify 1.2.1
File Interpreter ABI Platform
docify-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size:40.2 kB

Release files / docify-1.2.1.tar.gz

Download URL docify-1.2.1.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ed565259a3b20cd754438405b7830e12579f2223bb3c3f13c8e9318c258bc0a8
BLAKE2b-256 checksum
How to use checksums
f7658df7c9dbddefd5bc31474a9f2cdaa75b9f56a0c4d4b196957ef4b9aaf509
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / docify-1.2.1-py3-none-any.whl

Download URL docify-1.2.1-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5527e54b3b6c4e6ce13b31a0e68756e6a2fc01840a5247b457e49d88d87f9fa
BLAKE2b-256 checksum
How to use checksums
856dc7fc3387a7c91d57e1350d6c4b7ac0093b266eb4f0e78030622d2807e483
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page