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

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

Callers 1

_run_html_generationMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected