A comprehensive toolkit for enhancing VTK Python stub files with rich documentation and generating beautiful markdown API documentation.
- VTK Documentation Extraction: Extract comprehensive documentation from installed VTK library using Python introspection
- Enhanced Python Stubs: Enhance VTK's official Python stub files with rich docstrings for superior IDE IntelliSense
- Rich Markdown Documentation: Generate beautiful, web-ready markdown documentation organized by modules and classes
- Parallel Processing: High-performance parallel processing with 12 worker threads
- Modular Architecture: Memory-efficient per-module processing for optimal performance
- Comprehensive Verification: Built-in tools to verify pipeline integrity and completeness
- Python 3.7+
- VTK Python package installed
- Standard Python libraries:
json
,re
,ast
,pathlib
,concurrent.futures
,subprocess
,typing
- Clone this repository:
git clone <repository-url>
cd vtk-python-docs
- Run the automated setup script:
./setup_venv.sh
This will create a virtual environment, install VTK, and set up the project.
- Clone this repository:
git clone <repository-url>
cd vtk-python-docs
- Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install requirements:
pip install -r requirements.txt
python setup.py
# Clean and build everything (recommended for testing)
python build.py
# Or step by step:
python clean.py # Clean previous builds
python scripts/extract_all_vtk_docs.py # Extract VTK documentation
python scripts/generate_official_stubs.py # Generate official VTK stubs
python scripts/enhance_all_vtk_stubs.py # Enhance stubs with documentation
python scripts/generate_markdown_docs.py # Generate markdown docs
python tools/verify_vtk_docs.py --all # Verify integrity
# 1. Extract VTK documentation (creates docs/vtk-docs/)
python scripts/extract_all_vtk_docs.py
# 2. Generate official VTK stubs (creates docs/python-stubs-official/)
python scripts/generate_official_stubs.py
# 3. Enhance Python stubs with documentation (creates docs/python-stubs-enhanced/)
python scripts/enhance_all_vtk_stubs.py
# 4. Generate markdown documentation (creates docs/python-api/)
python scripts/generate_markdown_docs.py
# 5. Verify everything works correctly
python tools/verify_vtk_docs.py --all
# Extract all modules in parallel (recommended)
python scripts/extract_all_vtk_docs.py
# Extract single module for testing
python scripts/extract_vtk_docs.py --module vtkCommonCore --output docs/vtk-docs/
# Generate official VTK stubs using VTK's built-in generator
python scripts/generate_official_stubs.py
# Or specify custom output directory
python scripts/generate_official_stubs.py --output docs/python-stubs-official
# Enhance all stubs in parallel (recommended)
python scripts/enhance_all_vtk_stubs.py
# Enhance single module for testing
python scripts/enhance_vtk_stubs.py --module vtkCommonCore --docs-dir docs/vtk-docs/ --output docs/python-stubs-enhanced/
# Generate complete markdown documentation
python scripts/generate_markdown_docs.py
Configure your IDE to use the enhanced stubs by pointing to docs/python-stubs-enhanced/
. The included pyrightconfig.json
is pre-configured for this.
docs/
βββ vtk-docs/ # Extracted VTK documentation (JSON)
β βββ vtkCommonCore.json
β βββ vtkCommonDataModel.json
β βββ ... (150+ modules)
βββ python-stubs-official/ # Official VTK stubs (generated by VTK)
β βββ vtkCommonCore.pyi
β βββ vtkCommonDataModel.pyi
β βββ ... (150+ modules)
βββ python-stubs-enhanced/ # Enhanced Python stubs with documentation
β βββ vtkmodules/
β βββ vtkCommonCore.pyi
β βββ vtkCommonDataModel.pyi
β βββ ... (150+ modules)
βββ python-api/ # Rich markdown documentation
βββ index.md # Main documentation index
βββ classes.md # All classes sorted by 4th character
βββ modules.md # All classes organized by module
βββ vtkCommonCore/ # Module-specific documentation
β βββ index.md
β βββ vtkObject.md
β βββ ... (class files)
βββ ... (150+ module directories)
- Per-module processing: Each VTK module is processed independently for optimal memory usage
- Parallel execution: 12 worker threads for maximum performance
- Clean separation: Documentation extraction, stub enhancement, and markdown generation are separate stages
scripts/extract_all_vtk_docs.py
- Parallel VTK documentation extractionscripts/enhance_all_vtk_stubs.py
- Parallel Python stub enhancementscripts/generate_markdown_docs.py
- Rich markdown documentation generation
scripts/extract_vtk_docs.py
- Extract documentation for one modulescripts/enhance_vtk_stubs.py
- Enhance stubs for one module
tools/verify_vtk_docs.py
- Comprehensive pipeline verification
- Documentation Extraction: ~6 seconds for 2,942 classes across 151 modules
- Stub Enhancement: ~15 seconds for 151 stub files
- Markdown Generation: ~1.5 seconds for complete web documentation
- Total Pipeline: Under 30 seconds for complete enhancement
- Extracts comprehensive class and method documentation from VTK library
- Converts C++ Doxygen tags to Python format (
@param
β:param:
, etc.) - Handles
@overload
signatures correctly (docstring only on final signature) - Adds placeholder docstrings only when no meaningful documentation exists
- Beautiful, web-ready markdown with rich formatting
- Organized by VTK database sections for logical grouping
- Multiple navigation options (by module, by 4th character)
- Cross-references and search-friendly structure
- Automatic VTK version detection and tagging
- Enhanced IntelliSense with comprehensive VTK documentation
- Proper typing support from VTK's official stub generation
- Clean, Pythonic documentation format
- Compatible with PyRight, Pylance, and other language servers
Verify the integrity of your documentation pipeline:
# Verify all components
python tools/verify_vtk_docs.py --all
# Verify specific components
python tools/verify_vtk_docs.py --docs # JSON documentation
python tools/verify_vtk_docs.py --stubs # Enhanced stubs
python tools/verify_vtk_docs.py --markdown # Markdown docs
Based on VTK 9.5.0:
- 151 VTK modules processed
- 2,942 VTK classes documented
- 99.3% success rate (150/151 modules enhanced)
- Comprehensive coverage of VTK Python API
This project provides a complete, production-ready VTK documentation enhancement pipeline. Contributions for improvements, bug fixes, or support for newer VTK versions are welcome.
This project enhances the official VTK Python bindings and documentation. Please refer to VTK's licensing terms for the underlying VTK library.