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.versionandsys.platformconditional blocks, will only add docstrings to the correct branch - Able to modify files in-place with
-ior--in-place - Won't overwrite existing docstrings
- With
-bor--builtins-only, will only add docstrings for modules found insys.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
-i, --in-place modify stubs in-place
-o, --output OUTPUT_DIR
directory to write modified stubs to
Project details
Release history Release notifications | RSS feed
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.1.0.tar.gz
(8.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docify-1.1.0.tar.gz.
File metadata
- Download URL: docify-1.1.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9475055a330b4edc31be5854d78704a9c231dcf29b4c6e79421e4ce2adb90aa
|
|
| MD5 |
23a3cba7c43d6192cff86aaad609e5ae
|
|
| BLAKE2b-256 |
5c43b6b3ed504910ce076e6b7b6659aba4d26e51da3d3116393232278df22284
|
File details
Details for the file docify-1.1.0-py3-none-any.whl.
File metadata
- Download URL: docify-1.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b45a82f0da74e97f80d5ace255b417ec289cb2d22d321bfe3124f38a42df68b
|
|
| MD5 |
77fc2433daf07e4a23610d7e6174e558
|
|
| BLAKE2b-256 |
d1b4a5ea211025bf8544a1366e04c57efca6c9d1ba45028e53269ce1182bb49d
|