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.

Requirements

  • Python 3.8+
  • LibCST, and tqdm for a progress bar if running without -q

Usage

docify.py [-h] [-v] [-q] [-b] [--if-needed] (-i | -o OUTPUT_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, --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_DIR, --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.0.0.tar.gz (7.2 kB view hashes)

Uploaded Source

Built Distribution

docify-1.0.0-py3-none-any.whl (7.9 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