Skip to main content

PyDocEnhancer

AI-powered Python plugin to enhance documentation with summaries, code explanations, examples, semantic search, automated example testing, and multilingual documentation.

Features

  • Auto-Generated Summaries: Summarize modules, classes, and functions.
  • Code Explanations: Plain-English explanations of code logic.
  • Semantic Search: Query documentation with natural language (e.g., "find data processing functions").
  • Auto-Generated Examples: Create working code examples from docstrings.
  • Automated Example Testing: Extracts and runs code examples from docstrings, reporting results in the docs.
  • Multilingual Documentation: Generate documentation in multiple languages (e.g., English, French, Spanish, Chinese) using LLM translation.
  • Local LLM Support: Privacy-first processing with local models (e.g., LLaMA 3.2, ctransformers backend).
  • Integrations: Works with Sphinx, MkDocs, and Jupyter Notebooks.
  • README Generation: Automatically generate a project-level README summarizing your module, classes, and functions.

LLM Requirement

PyDocEnhancer requires a real LLM provider and model.

  • Specify a valid provider (local for ctransformers/Ollama, or openai for OpenAI API) and a model (e.g., ollama/llama3.2:latest).
  • Mock mode is not supported.
  • This is enforced in both the Python API and CLI.

Installation

pip install pydocenhancer[local]

For most users, the [local] extra is recommended. This uses the ctransformers backend, which does not require C++ build tools and works on most platforms. Only use the base install or cloud extras if you specifically need those features.

If you want to use the llama-cpp-python backend, install with:

pip install pydocenhancer[llama]

Note: This requires C++ build tools on Windows (see Troubleshooting below).

Quick Start

from pydocenhancer import DocEnhancer

# Initialize with a real LLM (Ollama or LLaMA)
enhancer = DocEnhancer(provider="local", model="ollama/llama3.2:latest", language="en")
enhancer.generate_docs(module_path="my_project/utils.py", output_dir="docs", language="en")

# Generate a README for your project
enhancer.generate_readme(module_path="my_project/utils.py", output_path="README.generated.md", language="en")

# Search documentation
results = enhancer.search_docs("file handling functions", "docs")
print(results)

Note: You must specify a real LLM provider and model. The tool will not work without a valid provider (e.g., local or openai) and model (e.g., ollama/llama3.2:latest).

CLI Usage

# Generate documentation with Ollama in English, with example testing
pydocenhancer enhance --module my_project/utils.py --output docs/ --provider local --model ollama/llama3.2:latest --language en

# Generate a project-level README
pydocenhancer generate-readme --module my_project/utils.py --output README.generated.md --provider local --model ollama/llama3.2:latest --language en

# Search documentation
pydocenhancer search --query "data processing functions" --docs-dir docs/

Requirements

  • Python 3.8+
  • Local LLM (e.g., LLaMA 3.2 via ctransformers)
  • Optional: Sphinx or MkDocs for integration

Windows Users

If you want to use local LLMs, install with:

pip install pydocenhancer[local]

No C++ build tools required for ctransformers wheels.

Troubleshooting Installation (Windows)

Some features (such as local LLMs using llama-cpp-python) require compiling native code. If you see errors like:

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error at CMakeLists.txt:3 (project):
  Running 'nmake' '-?' failed with: no such file or directory

This means your system is missing the required C/C++ build tools for compiling Python packages with native code.

How to Fix (Windows)

  1. Install Visual Studio Build Tools
  2. Restart your terminal (or use the "Developer Command Prompt for VS").
  3. Retry installation:
    pip install pydocenhancer
    

Debugging Tips

  • If you see errors about missing nmake or C/C++ compilers, the build tools are not installed or not in your PATH.
  • Try installing llama-cpp-python directly to see detailed errors:
    pip install llama-cpp-python
    
  • If you want to avoid C++ build tools, use the [local] extra to install with ctransformers backend (pre-built wheels):
    pip install pydocenhancer[local]
    
  • For advanced debugging, check the full error log and search for the first error message.

Alternative: Use WSL

If you have trouble with Windows build tools, consider using Windows Subsystem for Linux (WSL) for easier compilation of native code.

Common Errors & Solutions

Error Message Cause Solution
ImportError: ctransformers is required for local LLMs. You tried to use a local LLM without installing ctransformers. Run pip install pydocenhancer[local]
FileNotFoundError: [Errno 2] No such file or directory The module path you provided does not exist. Check the path and try again.
RuntimeError: Local LLM is not initialized. The local model failed to load or is not available. Check your model name and installation.
requests.exceptions.ConnectionError Ollama is not running or not reachable. Start Ollama and ensure the model is pulled.
Error: ... in Example Test Result The example code in the docstring is invalid or raises an exception. Fix the example code in your docstring.
CMake Error: CMAKE_C_COMPILER not set... Missing C++ build tools on Windows. See Troubleshooting Installation (Windows) above.
ModuleNotFoundError: No module named 'llama_cpp_python' You tried to use the llama backend without installing it. Run pip install pydocenhancer[llama]

Additional Debugging Steps

  • Verbose Output: Run with -v or --verbose if available, or set environment variable PYTHONVERBOSE=1 for more details.
  • Check Python Version: Ensure you are using Python 3.8+.
  • Check Dependencies: Run pip check to see if any dependencies are missing or incompatible.
  • Update pip: Sometimes, upgrading pip helps: python -m pip install --upgrade pip.

Packaging Note for Windows Users

  • If you want to use local LLMs without C++ build tools, install with:
    pip install pydocenhancer[local]
    
    This uses the ctransformers

Release files for pydocenhancer 3.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydocenhancer 3.3.0
File Size Uploaded
pydocenhancer-3.3.0.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydocenhancer 3.3.0
File Interpreter ABI Platform
pydocenhancer-3.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.7 kB

Release files / pydocenhancer-3.3.0.tar.gz

Download URL pydocenhancer-3.3.0.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
25d85b3d1e371de6982fd89e43ea571c1d2b0a2517560ce22074de35bc8e50ee
BLAKE2b-256 checksum
How to use checksums
b214b7259de47fa601f1c6327cbb482d7ad07f5584b9c6ceab2b6d1b81f80b44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / pydocenhancer-3.3.0-py3-none-any.whl

Download URL pydocenhancer-3.3.0-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
952187a20a1db3e0cf62ce43b5dbf4cfb36ec1f7c10b9b8d7e954436d5693238
BLAKE2b-256 checksum
How to use checksums
010c145edc45041f92e1bec7dd402052fa129dce94f1e13823c7c323db45c9d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

3.3.0 This release

2 release files

3.2.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page