(self, sub_module_specs: dict[str, list[str]])
| 269 | # ------------------------------------------------------------------ |
| 270 | |
| 271 | def _run_sub_modules(self, sub_module_specs: dict[str, list[str]]) -> str: |
| 272 | deps = self._deps |
| 273 | previous_module_name = deps.current_module_name |
| 274 | |
| 275 | # Add sub-modules to the in-memory module tree. |
| 276 | value = deps.module_tree |
| 277 | for key in deps.path_to_current_module: |
| 278 | value = value[key]["children"] |
| 279 | for sub_name, core_ids in sub_module_specs.items(): |
| 280 | value[sub_name] = {"components": core_ids, "children": {}} |
| 281 | |
| 282 | try: |
| 283 | for sub_name, core_ids in sub_module_specs.items(): |
| 284 | indent = " " * deps.current_depth |
| 285 | arrow = "└─" if deps.current_depth > 0 else "→" |
| 286 | logger.info("%s%s Generating documentation for sub-module: %s", indent, arrow, sub_name) |
| 287 | |
| 288 | deps.current_module_name = sub_name |
| 289 | deps.path_to_current_module.append(sub_name) |
| 290 | deps.current_depth += 1 |
| 291 | try: |
| 292 | # Spawn a fresh caw session for the sub-module. We already |
| 293 | # run inside a worker thread (started by the parent tool |
| 294 | # call), so call the sync entry point directly to avoid |
| 295 | # double-wrapping. ``start_depth`` carries the parent's |
| 296 | # depth so the sub-agent's max_depth guard stays accurate. |
| 297 | self._backend._run_module_agent_sync( |
| 298 | module_name=sub_name, |
| 299 | components=deps.components, |
| 300 | core_component_ids=core_ids, |
| 301 | module_path=list(deps.path_to_current_module), |
| 302 | working_dir=deps.absolute_docs_path, |
| 303 | start_depth=deps.current_depth, |
| 304 | module_tree=deps.module_tree, |
| 305 | ) |
| 306 | finally: |
| 307 | deps.path_to_current_module.pop() |
| 308 | deps.current_depth -= 1 |
| 309 | finally: |
| 310 | deps.current_module_name = previous_module_name |
| 311 | |
| 312 | return ( |
| 313 | "Generate successfully. Documentations: " |
| 314 | + ", ".join(key + ".md" for key in sub_module_specs.keys()) |
| 315 | + " are saved in the working directory." |
| 316 | ) |
nothing calls this directly
no test coverage detected