Documentation Consolidation System
This document describes the automated documentation consolidation system that creates a single DOCX file containing all documentation from the /readme/
folder.
Overview
The KAI platform includes an automated system that consolidates all Markdown documentation files into a single Microsoft Word (DOCX) document. This makes it easier to share comprehensive documentation with stakeholders who prefer traditional document formats over browsing multiple Markdown files.
How It Works
The system uses a GitHub Action workflow that:
- Runs automatically after each deployment to the main branch
- Runs on a weekly schedule (Monday at 00:00 UTC)
- Can be triggered manually via GitHub Actions interface
The workflow performs the following steps:
- Checks out the repository code
- Sets up Python environment
- Installs required dependencies (python-docx, markdown, beautifulsoup4)
- Creates and executes a Python script that:
- Scans the
/readme/
directory for all Markdown (.md
) files - Converts each Markdown file to HTML and then to DOCX format
- Combines all content into a single DOCX document with proper formatting
- Adds a title page, table of contents, and processing summary
- Saves the consolidated document as
/readme/readme.docx
- Scans the
- Commits and pushes the generated DOCX file back to the repository
Generated Document Structure
The consolidated DOCX document includes:
- Title Page: Contains the title "KAI Platform Documentation" and generation timestamp
- Table of Contents: Automatically generated when opened in Microsoft Word
- Content Sections: Each Markdown file is converted to a section with:
- Section title (derived from filename)
- Source file reference
- Original content with preserved formatting (headings, lists, code blocks, etc.)
- Processing Summary: Statistics about the number of files processed
Formatting Details
The conversion process handles various Markdown elements:
- Headings: Converted to Word headings with appropriate levels
- Lists: Converted to bulleted or numbered lists
- Code blocks: Formatted with Courier New font
- Tables: Converted to text representation
- Text formatting: Basic formatting (bold, italic) is preserved
Usage
Accessing the Consolidated Documentation
The consolidated documentation is available in two ways:
-
In the repository: The file is located at
/readme/readme.docx
and is automatically updated after each deployment to the main branch or on the weekly schedule. -
As a GitHub Actions artifact: Each time the workflow runs, the documentation is also uploaded as an artifact named "kai-documentation" that can be downloaded directly from the GitHub Actions interface. These artifacts are retained for 90 days.
Manual Triggering
To manually trigger the documentation generation:
- Go to the GitHub repository
- Navigate to Actions → Generate Consolidated Documentation
- Click "Run workflow"
- Select the branch (usually main)
- Click "Run workflow"
Troubleshooting
If the documentation generation fails or produces unexpected results:
- Check the GitHub Actions logs for error messages
- Verify that all Markdown files in the
/readme/
directory are properly formatted - Ensure that the required dependencies are available and up-to-date
Future Improvements
Potential future enhancements to the documentation consolidation system:
- Support for more complex Markdown elements (nested tables, advanced formatting)
- PDF generation in addition to DOCX
- Custom styling options
- Automatic distribution of generated documentation to stakeholders
- Integration with the existing monitoring dashboard