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.9.tar.gz (3.9 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.9-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_docs_hook-0.1.9.tar.gz
  • Upload date:
  • Size: 3.9 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.9.tar.gz
Algorithm Hash digest
SHA256 6c111f11913f1fd7abe14e9a55007d988fcb819fe3abec2b0121044f479527e1
MD5 6b73e0ecf07c29a8f5dd6ce87e51f68e
BLAKE2b-256 08871df8c57a78dc7374793c63940b6d7510a80d3a8cf9dbc4ee7fbecc29f321

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_docs_hook-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 4e15294c3f0758464bed5be08f614adb3e0d5f0d159c543d35ca3762f5a4f07e
MD5 a43c92efd3e92e6312d424ad78ba1e1d
BLAKE2b-256 620c60c2995f7f2735f0564b409fddc24afa0440ec10486b772f3e5993c2f389

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