|
| 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. |
0 commit comments