MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / HTMLGenerator

Class HTMLGenerator

codewiki/cli/html_generator.py:13–283  ·  view source on GitHub ↗

Generates static HTML documentation viewer for GitHub Pages. Creates a self-contained index.html with embedded styles, scripts, and configuration for client-side markdown rendering.

Source from the content-addressed store, hash-verified

11from codewiki.cli.utils.fs import safe_write, safe_read
12from codewiki.src.language import language_tag
13
14
15class HTMLGenerator:
16 """
17 Generates static HTML documentation viewer for GitHub Pages.
18
19 Creates a self-contained index.html with embedded styles, scripts,
20 and configuration for client-side markdown rendering.
21 """
22
23 def __init__(self, template_dir: Optional[Path] = None):
24 """
25 Initialize HTML generator.
26
27 Args:
28 template_dir: Path to template directory (default: package templates)
29 """
30 if template_dir is None:
31 # Use package templates
32 template_dir = Path(__file__).parent.parent / "templates" / "github_pages"
33
34 self.template_dir = Path(template_dir)
35
36 def load_module_tree(self, docs_dir: Path) -> Dict[str, Any]:
37 """
38 Load module tree from documentation directory.
39
40 Args:
41 docs_dir: Documentation directory path
42
43 Returns:
44 Module tree structure
45 """
46 module_tree_path = docs_dir / "module_tree.json"
47 if not module_tree_path.exists():
48 # Fallback to a simple structure
49 return {
50 "Overview": {"description": "Repository overview", "components": [], "children": {}}
51 }
52
53 try:
54 content = safe_read(module_tree_path)
55 return json.loads(content)
56 except Exception as e:
57 raise FileSystemError(f"Failed to load module tree: {e}")
58
59 def load_metadata(self, docs_dir: Path) -> Optional[Dict[str, Any]]:
60 """
61 Load metadata from documentation directory.
62
63 Args:
64 docs_dir: Documentation directory path
65
66 Returns:
67 Metadata dictionary or None if not found
68 """
69 metadata_path = docs_dir / "metadata.json"
70 if not metadata_path.exists():

Callers 1

_run_html_generationMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected