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.13.tar.gz (4.6 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.13-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_docs_hook-0.1.13.tar.gz
  • Upload date:
  • Size: 4.6 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.13.tar.gz
Algorithm Hash digest
SHA256 e72ab1ab5618b83f39aca69a76ada902ceecab16fbac8cf890c547f1a350c158
MD5 924441bb4c05875ba2fe725b7f153cf5
BLAKE2b-256 5633dbb8f0ea1466725679195dc40e12df10afe8c6f1bafcd2ec0fea66211c27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_docs_hook-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 9d682aeb42a5913506f21452b401de884661bd7a40ccfa030333ee296392a61f
MD5 255c23c923bdb5ca46c40bd7c27ec2ae
BLAKE2b-256 81cd0502d7c835fb9950460d0db9fefb53eefcd0fbf2d0786887e81b93b9764d

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