Skip to content

Commit a4be43f

Browse files
docs(KDP): adding some images and API documentation tools
1 parent 2e23b3d commit a4be43f

File tree

6 files changed

+788
-4
lines changed

6 files changed

+788
-4
lines changed

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,20 @@ clean_built:
5858
# Build doc
5959
# ------------------------------------
6060

61+
.PHONY: generate_doc_content
62+
## Generate documentation content from code and model architectures
63+
generate_doc_content:
64+
@echo "Generating API documentation from docstrings"
65+
mkdir -p docs/generated/api
66+
poetry run python scripts/generate_docstring_docs.py
67+
@echo "Generating model architecture diagrams"
68+
mkdir -p docs/imgs/architectures
69+
poetry run python scripts/generate_model_architectures.py
70+
@echo "Documentation content generation complete"
71+
6172
.PHONY: docs_deploy
6273
## Build docs using mike
63-
docs_deploy:
74+
docs_deploy: generate_doc_content
6475
@echo "Starting to build docs"
6576
@echo "more info: https://squidfunk.github.io/mkdocs-material/setup/setting-up-versioning/"
6677
ifdef HAS_POETRY
@@ -84,12 +95,12 @@ docs_version_serve:
8495

8596
.PHONY: docs
8697
## Create or Deploy MkDocs based documentation to GitHub pages.
87-
deploy_doc:
98+
deploy_doc: generate_doc_content
8899
mkdocs gh-deploy
89100

90101
.PHONY: serve_doc
91102
## Test MkDocs based documentation locally.
92-
serve_doc:
103+
serve_doc: generate_doc_content
93104
poetry run mkdocs serve
94105

95106
# ------------------------------------

docs/auto_documentation.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# 🔄 Automatic Documentation Generation
2+
3+
KDP includes tools to automatically generate documentation from code docstrings and visualize model architectures for different configurations. This ensures that the documentation remains up-to-date with the codebase.
4+
5+
## 🛠️ Documentation Tools
6+
7+
The following tools are included in the `scripts/` directory:
8+
9+
1. **`generate_docstring_docs.py`**: Extracts docstrings from classes and functions in the codebase and converts them to Markdown documentation.
10+
2. **`generate_model_architectures.py`**: Creates visualizations of various model architectures for different preprocessing configurations.
11+
12+
## 🚀 Generating Documentation
13+
14+
You can generate the documentation content using the Makefile target:
15+
16+
```bash
17+
make generate_doc_content
18+
```
19+
20+
This will:
21+
- Extract API documentation from docstrings and save it to `docs/generated/api/`
22+
- Generate model architecture diagrams and save them to `docs/imgs/architectures/`
23+
- Create an API index at `docs/generated/api_index.md`
24+
- Generate a model architectures overview at `docs/model_architectures.md`
25+
26+
## 🏗️ Model Architecture Configurations
27+
28+
The script generates visualizations for a variety of model configurations, including:
29+
30+
- Basic models with different output modes (CONCAT and DICT)
31+
- Models with transformer blocks
32+
- Models with tabular attention
33+
- Models with multi-resolution attention
34+
- Models with distribution-aware encoding
35+
- Models with advanced numerical embedding
36+
- Models with global numerical embedding
37+
- Complex models combining multiple features
38+
39+
Each configuration includes:
40+
- Feature specifications
41+
- Model configuration parameters
42+
- A visualization of the generated model architecture
43+
44+
## 📚 API Documentation from Docstrings
45+
46+
The docstring extraction process:
47+
1. Scans key modules in the codebase
48+
2. Extracts docstrings from classes and their methods
49+
3. Converts them to Markdown format
50+
4. Organizes them into a structured API reference
51+
52+
## 🔄 Integration with MkDocs
53+
54+
The generated documentation is automatically included when building the MkDocs site:
55+
56+
```bash
57+
make serve_doc # Test documentation locally
58+
```
59+
60+
or
61+
62+
```bash
63+
make deploy_doc # Deploy to GitHub Pages
64+
```
65+
66+
## 📝 Documenting Your Code
67+
68+
To ensure your code is properly included in the automatic documentation:
69+
70+
1. **Use Google-style docstrings** for all classes and methods:
71+
72+
```python
73+
def my_function(param1, param2):
74+
"""
75+
One-line description of function.
76+
77+
More detailed description if needed.
78+
79+
Args:
80+
param1: Description of param1
81+
param2: Description of param2
82+
83+
Returns:
84+
Description of the return value
85+
86+
Examples:
87+
```python
88+
result = my_function("example", 123)
89+
```
90+
"""
91+
# Function implementation
92+
```
93+
94+
2. **Document parameters and return values** to provide clear usage instructions.
95+
96+
3. **Include examples** to demonstrate usage where appropriate.
97+
98+
## 🔄 Dynamic Preprocessing Pipeline
99+
100+
The `DynamicPreprocessingPipeline` class provides a flexible way to build preprocessing pipelines with optimized execution flow:
101+
102+
```python
103+
class DynamicPreprocessingPipeline:
104+
"""
105+
Dynamically initializes and manages a sequence of Keras preprocessing layers, with selective retention of outputs
106+
based on dependencies among layers, and supports streaming data through the pipeline.
107+
"""
108+
```
109+
110+
This class analyzes dependencies between layers and ensures that each layer receives the outputs it needs from previous layers.

keras-data-processor

Lines changed: 0 additions & 1 deletion
This file was deleted.

mkdocs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,16 @@ nav:
4646
- 🤖 Transformer Blocks: transformer_blocks.md
4747
- 🎯 Tabular Attention: tabular_attention.md
4848
- 🔂 Feature Selection: feature_selection.md
49+
- 📊 Distribution-Aware Encoding: distribution_aware_encoder.md
50+
- 🔢 Advanced Numerical Embeddings: advanced_numerical_embeddings.md
4951
- 🏗️ Usage & Examples:
5052
- 🚀 Quick Start: quick_start.md
5153
- 🧩 Complex Examples: complex_examples.md
54+
- 🔄 Example Usages: example_usages.md
55+
- 📚 Documentation:
56+
- 🔄 Auto-Documentation: auto_documentation.md
57+
- 🏗️ Model Architectures: model_architectures.md
58+
- 📑 API Reference: generated/api_index.md
5259
- 🎯 Motivation & Contribution:
5360
- 🌍 Why KDP? (Motivation): motivation.md
5461
- 🍻 Contributing Guide: contributing.md

0 commit comments

Comments
 (0)