feat: implement modular theme system with file-based theme organization

Transform theme system from large inline dictionaries to maintainable YAML files:

**Architecture:**
- File-based themes organized by scope: mode/, ui/, document/, branding/
- Dynamic theme loading with automatic discovery
- Hybrid system maintaining 100% backward compatibility
- Rich metadata support with theme documentation

**Implementation:**
- Created markitect/themes/ directory with organized structure
- Added ThemeRegistry for dynamic YAML theme loading
- Extracted ChatGPT and Substack themes to separate files
- Added mode themes (light.yaml, dark.yaml) as examples
- Integrated with existing LAYERED_THEMES system seamlessly

**Benefits:**
- Improved maintainability: each theme is a separate file
- Better collaboration: multiple contributors can work simultaneously
- Enhanced discoverability: clear organization shows available themes
- Rich documentation: each theme file includes design notes and metadata
- Schema validation potential with YAML format

**Quality Assurance:**
- Comprehensive 12-test suite for modular system (12/12 passing)
- Backward compatibility verified with existing 15 theme tests (15/15 passing)
- CLI integration tested and working with file-based themes
- Theme combination and scoping functionality preserved

**Files Created:**
- markitect/themes/__init__.py - Theme registry and dynamic loader
- markitect/themes/README.md - Complete documentation and usage guide
- markitect/themes/document/{chatgpt,substack}.yaml - Modular theme files
- markitect/themes/mode/{light,dark}.yaml - Mode theme examples
- tests/test_modular_theme_system.py - Comprehensive test coverage

Addresses maintainability concerns while preserving all existing functionality.
No breaking changes - all existing code, CLI commands, and API calls work unchanged.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-10 11:43:25 +01:00
parent afe6bcf6fe
commit d1e129c9b8
8 changed files with 712 additions and 0 deletions

View File

@@ -19,6 +19,12 @@ from markitect.plugins.decorators import register_plugin
# DocumentManager removed - using CleanDocumentManager directly
from markitect.serializer import ASTSerializer
# Try to load themes from the new modular system
try:
from markitect.themes import get_layered_themes
_MODULAR_THEMES = get_layered_themes()
except ImportError:
_MODULAR_THEMES = {}
# Simple helper function - avoiding circular imports
def get_default_format(available_formats=['table', 'json', 'yaml', 'simple'], fallback='simple'):
@@ -247,6 +253,11 @@ LAYERED_THEMES = {
}
}
# Merge modular themes with inline themes
# Modular themes take precedence over inline themes
if _MODULAR_THEMES:
LAYERED_THEMES.update(_MODULAR_THEMES)
# Legacy compatibility - map old theme names to new layered equivalents
LEGACY_THEME_MAPPING = {
'basic': ['light', 'standard', 'basic'],