You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: Extract MarkdownGenerator from DiffStix class
Extracted markdown generation logic into a dedicated MarkdownGenerator class
to improve maintainability and reduce DiffStix class complexity.
**New File Created:**
- mitreattack/diffStix/formatters/markdown_generator.py (234 lines)
- MarkdownGenerator class with 4 methods
- generate() - Main markdown generation orchestration
- placard() - Generate placard string for STIX objects
- get_markdown_section_data() - Format section data
- get_md_key() - Generate markdown key section
**Changes to DiffStix:**
- Reduced from 1,462 lines to 1,317 lines (145 lines removed, 10% reduction)
- Added MarkdownGenerator import and initialization
- Replaced 4 methods with simple delegation:
- placard() - 80 lines → 1 line delegation
- get_markdown_section_data() - 19 lines → 1 line delegation
- get_md_key() - 29 lines → 1 line delegation
- get_markdown_string() - 58 lines → 1 line delegation
**Design Pattern:**
- Uses Facade pattern for backward compatibility
- MarkdownGenerator receives DiffStix instance for access to data/methods
- All public APIs remain unchanged
- Uses constants from utils/constants.py instead of instance variables
**Benefits:**
- Single Responsibility: Markdown generation is now isolated
- Reduced complexity in DiffStix class
- Easier to test markdown generation independently
- Improved code organization and readability
- No breaking changes to public API
**Test Results:**
- 132/133 tests passing (99.2%)
- Only failure: test_get_new_changelog_md_file_write_error (known permission issue)
- All markdown-related tests pass
- No test modifications required
**Next Steps:**
This is the first of 7 planned extractions to decompose the DiffStix God Object.
Remaining extractions: LayerGenerator, JsonGenerator, StatisticsCollector,
HierarchyBuilder, ChangeDetector, DataLoader.
0 commit comments