Refactoring Plan: Modular OOP & SOLID Architecture
This document describes the architectural transition of the Universal Documentation Engine (UDE) from a monolithic, conditional-heavy MVP implementation into a modular, highly cohesive, and SOLID-compliant design system.
πΊοΈ Architectural Target Designβ
ποΈ Refactoring Milestonesβ
π Phase 1: Base Parsing Layer Extraction (BaseDoxygenParser)β
- Goal: Isolate Doxygen XML file reading, catalog tree assembling, and generic node parsing from language-specific logic.
- Tasks:
- Define
BaseDoxygenParser(BaseParser)inude/parsers/base.py. - Implement shared XML navigation helper methods (
_find_nodes,_parse_common_blocks,_extract_brief). - Move metadata storage, logging initialization, and XML parsing loop orchestration to the base class.
- Define
π Phase 2: Concrete Language-Specific Parsers Extractionβ
- Goal: Isolate language-specific parsing constraints into individual, highly cohesive classes.
- Tasks:
- Implement
CppDoxygenParser(BaseDoxygenParser):- Handle double-colon (
::) scoping. - Strip export/linkage macros (
REQ-FUN-19). - Escape angle brackets (
< >) for C++ templates (REQ-FUN-02).
- Handle double-colon (
- Implement
CsharpDoxygenParser(BaseDoxygenParser):- Handle C# dot namespace resolution.
- Filter SWIG internal boilerplate (
swigCPtr,Dispose) (REQ-FUN-20). - Apply C# pointer type cleaning mapping (
REQ-FUN-40).
- Implement
JavaDoxygenParser(BaseDoxygenParser):- Parse Javadoc parameters and packages.
- Filter SWIG internal boilerplate (
REQ-FUN-20). - Apply Java pointer type cleaning mapping (
REQ-FUN-40).
- Implement
PythonDoxygenParser(BaseDoxygenParser):- Filter SWIG internal boilerplate (
REQ-FUN-20). - Parse Sphinx/RST comment structures (
REQ-FUN-14). - Reconstruct dynamic function signatures and map parameter types from docstrings.
- Filter SWIG internal boilerplate (
- Build
DoxygenParserFactoryto dynamically resolve and instantiate the target parser based on the config.
- Implement
π Phase 3: Layout Signature Formatters (Strategy Pattern)β
- Goal: Decouple visual rendering code from raw signature compilation.
- Tasks:
- Define the
SignatureFormatterabstract interface. - Implement
CppSignatureFormatter,CsharpSignatureFormatter,JavaSignatureFormatter, andPythonSignatureFormatter. - Relocate type delimiter transformations (
::to.) and class declaration text generation from HTML/Markdown templates into the formatters.
- Define the
π Phase 4: Specializing Templates & Upgrading Renderersβ
- Goal: Simplify template structures by removing nested conditional blocks (
{% if language %}). - Tasks:
- Structure the template layouts into specialized subdirectories:
ude/templates/common/(Shared styles and scripts).ude/templates/cpp/(C++ specific layout).ude/templates/csharp/(C# specific layout).
ude/templates/java/(Java specific layout).ude/templates/python/(Python specific layout).
- Update
HtmlRendererandHugoMarkdownRendererto load the appropriate template dynamically based onlanguageconfig. - Inject the designated
SignatureFormatterinstance into Jinja2 templates, replacing complex conditional markup with simple, clean method calls:{{ formatter.format_class_prototype(entity) }}.
- Structure the template layouts into specialized subdirectories:
π‘οΈ Regression Testing & Quality Gatesβ
To guarantee that the refactoring is 100% safe and introduces zero behavioral bugs or broken layouts:
-
Unit Test Alignment:
- Refactor existing test suites (
tests/test_doxygen_parser.py) to verify that the split language-specific parsers handle their designated tasks independently. - Maintain a strict total statement coverage target of
>= 98%usingpytest-cov.
- Refactor existing test suites (
-
Snapshot Testing (Golden Master / Sandbox):
- Prior to refactoring, compile documentation for all 11 test reference projects and save the entire generated
ude_output/output structure as a "Golden Master" reference snapshot. - Post-refactoring, re-compile the identical targets and execute a recursive automated file-by-file text comparison (using a custom python script or
diff -r) to guarantee that the generated HTML help and Markdown documents remain 100% physically identical.
- Prior to refactoring, compile documentation for all 11 test reference projects and save the entire generated
-
CI/CD Integration Checks:
- Run the operational documentation verification suite (
verify_pages.py) to confirm that all cross-links, sidebars, and external tabs continue to function without errors on local development servers.
- Run the operational documentation verification suite (