Main documentation generation orchestrator.
| 29 | from codewiki.src.be.overview_support import ( |
| 30 | bounded_overview_prompt, |
| 31 | overview_content, |
| 32 | overview_error, |
| 33 | preserve_incomplete_overviews, |
| 34 | reusable_overview, |
| 35 | save_overview, |
| 36 | ) |
| 37 | from codewiki.src.be.module_naming import ( |
| 38 | dedupe_module_tree_names, |
| 39 | find_missing_module_docs, |
| 40 | resolve_module_doc_path, |
| 41 | ) |
| 42 | from codewiki.src.be.module_scope import ( |
| 43 | complete_file_candidates, |
| 44 | get_module_token_count, |
| 45 | validate_module_file_coverage, |
| 46 | ) |
| 47 | from codewiki.src.be.prompt_template import ( |
| 48 | MODULE_OVERVIEW_PROMPT, |
| 49 | REPO_OVERVIEW_ARTIFACT_ADDENDUM, |
| 50 | REPO_OVERVIEW_PROMPT, |
| 51 | format_overview_system_prompt, |
| 52 | ) |
| 53 | from codewiki.src.config import ( |
| 54 | FIRST_MODULE_TREE_FILENAME, |
| 55 | MODULE_TREE_FILENAME, |
| 56 | OVERVIEW_FILENAME, |
| 57 | Config, |
| 58 | ) |
| 59 | from codewiki.src.utils import file_manager |
| 60 | |
| 61 | # Configure logging and monitoring |
| 62 | logger = logging.getLogger(__name__) |
| 63 | |
| 64 | |
| 65 | class IncompleteDocumentationError(Exception): |
| 66 | """Raised when generation finishes but some modules have no doc file on disk.""" |
| 67 | |
| 68 | def __init__(self, missing_modules: list[str]): |
| 69 | self.missing_modules = missing_modules |
| 70 | super().__init__( |
| 71 | f"Documentation generation finished but {len(missing_modules)} module doc(s) " |
| 72 | f"are missing: {', '.join(missing_modules)}" |
| 73 | ) |
| 74 | |
| 75 | |
| 76 | class DocumentationGenerator: |
| 77 | """Main documentation generation orchestrator.""" |
| 78 | |
| 79 | def __init__( |
| 80 | self, config: Config, commit_id: str | None = None, backend: LLMBackend | None = None |
| 81 | ): |
| 82 | self.config = config |
| 83 | self.commit_id = commit_id |
| 84 | self.graph_builder = DependencyGraphBuilder(config) |
| 85 | self.backend: LLMBackend = backend or get_backend(config) |
| 86 | |
| 87 | @property |
| 88 | def usage_ledger(self) -> UsageLedger: |
no outgoing calls
no test coverage detected