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.10.tar.gz (4.4 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.10-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_docs_hook-0.1.10.tar.gz
  • Upload date:
  • Size: 4.4 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.10.tar.gz
Algorithm Hash digest
SHA256 c207d72cfe0153b1f5b7da497b82569cf228c6ef68ef63ee0f0047463f212826
MD5 e699ba34181465300110c654f562791d
BLAKE2b-256 74622f904e1ecda6587d01e0064e71d7c771cad64aff5577ece7444f19311c2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_docs_hook-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 7e8327afced808f645e4f898efb2903ea462f06f395bf30502ad228f101867f7
MD5 a0d55c67f30e8b5a21c09b8eec8fdf36
BLAKE2b-256 7449c75affe51dbd53eb77711a716326be97ee21eede2b00ea2224b0da1b444c

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