Skip to main content

A pre-commit hook to generate Python documentation

Project description

Python Documentation Hook

A pre-commit hook that automatically generates documentation for Python files by extracting docstrings and function definitions.

Features

  • Automatically extracts Python docstrings
  • Generates markdown documentation
  • Updates README.md automatically in the same directory as Python files
  • Handles nested function documentation
  • Supports multiple Python files
  • Preserves existing README content

Installation

# Using pip
pip install python_docs_hook

# From source
git clone https://github.com/geek-kb/python_docs_hook.git
cd python_docs_hook
pip install -e .

Usage

Add this to your .pre-commit-config.yaml:

repos:
-   repo: https://github.com/geek-kb/python_docs_hook
    rev: v0.1.1
    hooks:
    -   id: python-docs

Install the pre-commit hook:

pre-commit install

Configuration

The hook will:

  • Look for Python files in your commits

  • Generate documentation from docstrings

  • Create/update README.md in the same directory as the Python files

  • Use markers to update documentation sections:

    <!-- BEGIN_PY_DOCS -->
    

setup.py


## Example Output

<!-- BEGIN_PY_DOCS -->
## setup.py

<!-- END_PY_DOCS -->

## Development

Clone the repository and install in development mode:

```bash
git clone https://github.com/geek-kb/python_docs_hook.git
cd python_docs_hook
python -m venv venv
source venv/bin/activate
pip install -e .

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (`git commit -m 'Add some

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

python_docs_hook-0.1.12.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

python_docs_hook-0.1.12-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file python_docs_hook-0.1.12.tar.gz.

File metadata

  • Download URL: python_docs_hook-0.1.12.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for python_docs_hook-0.1.12.tar.gz
Algorithm Hash digest
SHA256 c639c9e32f7edd7838df9cdb3edfae8c2f9c026ee44e2d4f07ccdc691a97f3db
MD5 6a6617475aad31c1c12bb622c0eed4e4
BLAKE2b-256 6e63e8d146ab1ff6ba5af391efc22c134b9ba57fa7ebcf4199bf4a9ea44efde8

See more details on using hashes here.

File details

Details for the file python_docs_hook-0.1.12-py3-none-any.whl.

File metadata

File hashes

Hashes for python_docs_hook-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 5a92286d211dbd8581dd5f8662d8d27500efd4982f2e6d257988f9f14f849c7a
MD5 079a9e6161be00b59b6ffb7c5c7bae02
BLAKE2b-256 aa81adad21e66fea6dce3150527cc04f3f590e7b3187f005e25024249ca8abe9

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