MCPcopy Index your code
hub / github.com/FSoft-AI4Code/CodeWiki / DocumentationGenerator

Class DocumentationGenerator

codewiki/src/be/documentation_generator.py:31–373  ·  view source on GitHub ↗

Main documentation generation orchestrator.

Source from the content-addressed store, hash-verified

29
30
31class DocumentationGenerator:
32 """Main documentation generation orchestrator."""
33
34 def __init__(self, config: Config, commit_id: str = None, backend: LLMBackend = None):
35 self.config = config
36 self.commit_id = commit_id
37 self.graph_builder = DependencyGraphBuilder(config)
38 self.backend: LLMBackend = backend or get_backend(config)
39
40 def create_documentation_metadata(self, working_dir: str, components: Dict[str, Any], num_leaf_nodes: int):
41 """Create a metadata file with documentation generation information."""
42 from datetime import datetime
43
44 metadata = {
45 "generation_info": {
46 "timestamp": datetime.now().isoformat(),
47 "main_model": self.config.main_model,
48 "generator_version": "1.0.1",
49 "repo_path": self.config.repo_path,
50 "commit_id": self.commit_id
51 },
52 "statistics": {
53 "total_components": len(components),
54 "leaf_nodes": num_leaf_nodes,
55 "max_depth": self.config.max_depth
56 },
57 "files_generated": [
58 "overview.md",
59 "module_tree.json",
60 "first_module_tree.json"
61 ]
62 }
63
64 # Add generated markdown files to the metadata
65 try:
66 for file_path in os.listdir(working_dir):
67 if file_path.endswith('.md') and file_path not in metadata["files_generated"]:
68 metadata["files_generated"].append(file_path)
69 except Exception as e:
70 logger.warning(f"Could not list generated files: {e}")
71
72 metadata_path = os.path.join(working_dir, "metadata.json")
73 file_manager.save_json(metadata, metadata_path)
74
75
76 def get_processing_order(self, module_tree: Dict[str, Any], parent_path: List[str] = []) -> List[tuple[List[str], str]]:
77 """Get the processing order using topological sort (leaf modules first)."""
78 processing_order = []
79
80 def collect_modules(tree: Dict[str, Any], path: List[str]):
81 for module_name, module_info in tree.items():
82 current_path = path + [module_name]
83
84 # If this module has children, process them first
85 if module_info.get("children") and isinstance(module_info["children"], dict) and module_info["children"]:
86 collect_modules(module_info["children"], current_path)
87 # Add this parent module after its children
88 processing_order.append((current_path, module_name))

Callers 4

_process_jobMethod · 0.90
mainFunction · 0.90
_legacy_generate_docsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected