Skip to content

Commit d13c7f9

Browse files
committed
feat: add enhanced documentation system with call trees and architecture diagrams
🚀 Major enhancement to documentation generation: 📊 New Features: - Function call tree generation and visualization - System architecture diagrams with component relationships - AST-based code analysis for accurate dependency mapping - Interactive documentation with modern UI components - Code complexity analysis and reporting 🛠️ Technical Improvements: - Advanced Sphinx extensions (graphviz, inheritance diagrams) - Enhanced Python documentation generator script - Automated diagram generation with Graphviz - Local development build script for easy testing - CI/CD integration with artifact generation 📁 New Components: - scripts/generate-docs.py: Comprehensive documentation generator - scripts/build-docs-local.sh: Local build automation - Enhanced requirements-docs.txt with visualization tools - Updated Sphinx configuration with advanced extensions - Comprehensive documentation README with usage examples 🎯 Benefits: - Visual understanding of codebase architecture - Function dependency analysis for better code maintenance - Interactive documentation with copy buttons and responsive design - Automated generation reduces documentation maintenance overhead - Improved developer onboarding with architectural insights
1 parent 2962e27 commit d13c7f9

File tree

7 files changed

+711
-26
lines changed

7 files changed

+711
-26
lines changed

.github/workflows/python-docs.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ jobs:
2424
python-version: '3.11'
2525
install-dev-reqs: 'false'
2626
install-docs-reqs: 'true'
27-
- name: Generate Sphinx docs
27+
- name: Install system dependencies
2828
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y graphviz
31+
- name: Generate enhanced documentation
32+
run: |
33+
# Run our enhanced documentation generator
34+
python scripts/generate-docs.py --src src --output doc/codeDocs
2935
# Generate API documentation, excluding conf.py
3036
sphinx-apidoc -o doc/codeDocs/ src/ --force --no-toc --module-first
31-
# Build the documentation
37+
# Build the enhanced documentation
3238
sphinx-build -W -b html doc/codeDocs/ doc/codeDocs/_build/html
3339
- name: Upload documentation artifact
3440
uses: actions/upload-artifact@v4

doc/CodeDocs/README.md

Lines changed: 122 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,141 @@
1-
# Code Documentation (codeDocs)
1+
# Enhanced Code Documentation (codeDocs)
22

3-
This directory contains the auto-generated API documentation for the unstructuredDataHandler project using Sphinx.
3+
This directory contains the **enhanced** auto-generated API documentation for the unstructuredDataHandler project using Sphinx, featuring advanced code analysis, call trees, and architectural diagrams.
44

5-
## Contents
5+
## 🚀 Enhanced Features
66

7-
- `conf.py` - Sphinx configuration file
8-
- `index.rst` - Main documentation index
9-
- `_static/` - Static files for documentation (CSS, images, etc.)
7+
### 📊 Code Analysis & Visualization
8+
- **System Architecture Diagrams**: High-level component relationships
9+
- **Function Call Trees**: Visual representation of function dependencies
10+
- **Class Hierarchy Diagrams**: Inheritance and composition relationships
11+
- **Module Dependency Graphs**: Inter-module import analysis
12+
- **Complexity Analysis**: Code complexity metrics and reports
13+
14+
### 🎨 Advanced Documentation Features
15+
- **Interactive Elements**: Tabs, toggles, and collapsible sections
16+
- **Copy Code Buttons**: Easy code copying with syntax highlighting
17+
- **Responsive Design**: Modern, mobile-friendly documentation
18+
- **Enhanced Navigation**: Deep linking and improved search
19+
20+
## 📁 Enhanced Directory Structure
21+
22+
- `conf.py` - Enhanced Sphinx configuration with advanced extensions
23+
- `index.rst` - Main documentation index with architecture overview
24+
- `overview.rst` - **NEW**: System overview with architectural diagrams
25+
- `_static/` - Static files including:
26+
- `diagrams/` - **NEW**: Generated call trees and architecture diagrams
27+
- `custom.css` - **NEW**: Enhanced styling
1028
- `_templates/` - Custom documentation templates
11-
- `_build/` - Generated HTML documentation (auto-generated, not committed)
12-
- `*.rst` - Auto-generated API documentation files (not committed)
29+
- `_build/` - Generated HTML documentation (auto-generated)
30+
- `*.rst` - Enhanced API documentation with call tree analysis
1331

14-
## Building Documentation
32+
## 🛠️ Building Enhanced Documentation
1533

16-
To build the documentation locally:
34+
### Quick Local Build
35+
```bash
36+
# Use the enhanced build script (recommended)
37+
./scripts/build-docs-local.sh
38+
```
1739

40+
### Manual Build Process
1841
```bash
19-
# Install documentation dependencies
42+
# Install enhanced documentation dependencies
2043
pip install -r requirements-docs.txt
2144

22-
# Generate API documentation
23-
sphinx-apidoc -o doc/codeDocs/ src/
45+
# Generate enhanced analysis and diagrams
46+
python scripts/generate-docs.py --src src --output doc/codeDocs
2447

25-
# Build HTML documentation
48+
# Generate API documentation
49+
sphinx-apidoc -o doc/codeDocs/ src/ --force --no-toc --module-first
50+
51+
# Build enhanced HTML documentation
2652
sphinx-build -b html doc/codeDocs/ doc/codeDocs/_build/html
2753
```
2854

29-
The built documentation will be available in `doc/codeDocs/_build/html/index.html`.
55+
### System Requirements
56+
- **Graphviz**: Required for diagram generation
57+
```bash
58+
# Ubuntu/Debian
59+
sudo apt-get install graphviz
60+
61+
# macOS
62+
brew install graphviz
63+
```
64+
65+
## 📊 Generated Outputs
66+
67+
### Architecture Diagrams
68+
- `architecture.png` - Overall system component architecture
69+
- `*_calls.png` - Module-specific function call trees
70+
- Interactive diagrams embedded in documentation
71+
72+
### Enhanced Documentation
73+
- **Overview Section**: System architecture and component relationships
74+
- **Call Tree Analysis**: Function dependency visualization per module
75+
- **Complexity Reports**: Code quality metrics and analysis
76+
- **Interactive API Reference**: Enhanced with call flow information
77+
78+
## 🔧 Configuration & Customization
79+
80+
### Enhanced Sphinx Extensions
81+
- `sphinx.ext.graphviz` - Diagram generation support
82+
- `sphinx.ext.inheritance_diagram` - Class hierarchy diagrams
83+
- `sphinx_design` - Modern UI components and layouts
84+
- `sphinx_copybutton` - Copy code functionality
85+
- `sphinx_autodoc_typehints` - Enhanced type hint documentation
86+
87+
### Custom Analysis Features
88+
The documentation generator (`scripts/generate-docs.py`) provides:
89+
- **AST-based code analysis** for accurate call tree generation
90+
- **Module dependency mapping** for architecture visualization
91+
- **Complexity analysis integration** with pylint
92+
- **Extensible analysis framework** for custom insights
93+
94+
## 🔄 Automated CI/CD Builds
95+
96+
Enhanced documentation is automatically built via GitHub Actions:
97+
- **Workflow**: `.github/workflows/python-docs.yml`
98+
- **Triggers**: Any Python file changes
99+
- **Artifacts**: Complete documentation package with diagrams
100+
- **Dependencies**: Automatic installation of Graphviz and enhanced packages
101+
102+
## 🎯 Integration with Main Documentation
103+
104+
This enhanced codeDocs integrates with the broader documentation structure:
105+
106+
- **Architecture Documentation** (`doc/architecture/`) ← **Enhanced with generated diagrams**
107+
- **API Reference****Enhanced with call trees and complexity analysis**
108+
- **Business Documentation** (`doc/business/`)
109+
- **Development Guides** (`doc/`) ← **Enhanced with architectural insights**
110+
111+
## 🚀 Getting Started
112+
113+
1. **Install dependencies**: `pip install -r requirements-docs.txt`
114+
2. **Run enhanced build**: `./scripts/build-docs-local.sh`
115+
3. **View documentation**: Open `doc/codeDocs/_build/html/index.html`
116+
4. **Explore features**: Navigate to "Overview" for architecture diagrams
117+
118+
## 🔍 Advanced Features
30119

31-
## Automated Builds
120+
### Call Tree Analysis
121+
Each module includes:
122+
- Visual call tree diagrams
123+
- Function dependency lists
124+
- Cross-reference linking
125+
- Complexity indicators
32126

33-
The documentation is automatically built and updated via GitHub Actions on every push that modifies Python files. See `.github/workflows/python-docs.yml` for the CI configuration.
127+
### Architecture Insights
128+
- Component relationship diagrams
129+
- Data flow visualization
130+
- Module coupling analysis
131+
- System overview dashboard
34132

35-
## Relationship to Main Documentation
133+
### Interactive Elements
134+
- Expandable code sections
135+
- Copy-to-clipboard functionality
136+
- Responsive diagram viewing
137+
- Enhanced navigation
36138

37-
This codeDocs directory focuses specifically on API documentation generated from source code docstrings. For other types of documentation:
139+
---
38140

39-
- Architecture documentation → `doc/architecture/`
40-
- Business documentation → `doc/business/`
41-
- General guides and specs → `doc/`
42-
- Images and references → `doc/images/`, `doc/reference/`
141+
**📈 This enhanced documentation system provides comprehensive insights into codebase structure, making it significantly easier for developers to understand, maintain, and extend the unstructuredDataHandler project.**

doc/CodeDocs/conf.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,24 @@
1919
'sphinx.ext.viewcode',
2020
'sphinx.ext.napoleon',
2121
'sphinx.ext.intersphinx',
22+
'sphinx.ext.graphviz',
23+
'sphinx.ext.inheritance_diagram',
2224
'sphinx_autodoc_typehints',
2325
]
2426

27+
# Enhanced documentation features
28+
try:
29+
import sphinx_design
30+
extensions.append('sphinx_design')
31+
except ImportError:
32+
pass
33+
34+
try:
35+
import sphinx_copybutton
36+
extensions.append('sphinx_copybutton')
37+
except ImportError:
38+
pass
39+
2540
templates_path = ['_templates']
2641
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
2742

doc/CodeDocs/index.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@ Getting Started
2222

2323
.. toctree::
2424
:maxdepth: 2
25-
:caption: API Reference:
25+
:caption: Documentation:
2626

27+
overview
2728
modules
2829

30+
.. toctree::
31+
:maxdepth: 1
32+
:caption: Code Analysis:
33+
34+
Call Trees & Architecture <overview>
35+
API Reference <modules>
36+
2937
Indices and tables
3038
==================
3139

requirements-docs.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# Core Sphinx documentation tools
12
sphinx==7.3.7
23
sphinx-autodoc-typehints==2.2.0
34
sphinx-rtd-theme==2.0.0
5+
6+
# Advanced documentation extensions
7+
sphinx-design==0.5.0
8+
sphinx-copybutton==0.5.2
9+
myst-parser==2.0.0
10+
11+
# Call tree and code analysis tools
12+
pycallgraph2==1.1.3
13+
ast-monitor==0.4.3
14+
code2flow==2.5.1
15+
16+
# Architecture diagram generation
17+
graphviz==0.20.1
18+
plantuml==0.3.0
19+
pylint==3.0.3
20+
21+
# Enhanced documentation features
22+
sphinx-tabs==3.4.5
23+
sphinx-togglebutton==0.3.2
24+
furo==2023.9.10

scripts/build-docs-local.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
# Local documentation generation script
3+
# This script generates enhanced documentation locally
4+
5+
set -e
6+
7+
echo "🚀 Starting local documentation generation..."
8+
9+
# Check if we're in the right directory
10+
if [ ! -d "src" ]; then
11+
echo "❌ Error: Please run this script from the repository root"
12+
exit 1
13+
fi
14+
15+
# Create output directory
16+
mkdir -p doc/codeDocs/_static/diagrams
17+
18+
echo "📦 Installing documentation requirements..."
19+
pip install -r requirements-docs.txt
20+
21+
echo "🔍 Generating enhanced documentation..."
22+
python scripts/generate-docs.py --src src --output doc/codeDocs
23+
24+
echo "📚 Generating Sphinx API documentation..."
25+
sphinx-apidoc -o doc/codeDocs/ src/ --force --no-toc --module-first
26+
27+
echo "🏗️ Building HTML documentation..."
28+
sphinx-build -b html doc/codeDocs/ doc/codeDocs/_build/html
29+
30+
echo "✅ Documentation generation complete!"
31+
echo "📁 Open doc/codeDocs/_build/html/index.html to view the documentation"
32+
33+
# Open documentation in browser (macOS)
34+
if [[ "$OSTYPE" == "darwin"* ]]; then
35+
echo "🌐 Opening documentation in browser..."
36+
open doc/codeDocs/_build/html/index.html
37+
fi

0 commit comments

Comments
 (0)