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

Function _legacy_generate_docs

codewiki/mcp/server.py:452–510  ·  view source on GitHub ↗

Legacy generate_docs — requires CodeWiki LLM configuration.

(arguments: dict[str, Any])

Source from the content-addressed store, hash-verified

450 )
451 # Clean up workspace files on disk
452 if session.workspace is not None:
453 session.workspace.cleanup()
454 removed = _store.remove(sid)
455 return [
456 _text(
457 json.dumps(
458 {
459 "status": "closed" if removed else "not_found",
460 "session_id": sid,
461 }
462 )
463 )
464 ]
465
466 # --- Legacy tools (require CodeWiki LLM config) ---
467 elif name == "generate_docs":
468 return await _legacy_generate_docs(arguments)
469
470 elif name == "get_module_tree":
471 return await _legacy_get_module_tree(arguments)
472
473 else:
474 return [_text(json.dumps({"error": f"Unknown tool: {name}"}))]
475
476 except Exception as e:
477 logger.error("Tool %s failed: %s", name, e, exc_info=True)
478 return [_text(json.dumps({"error": str(e)}))]
479
480
481# ===================================================================
482# Legacy tool handlers (require _load_config)
483# ===================================================================
484
485
486def _load_config():
487 """Load CodeWiki configuration from ~/.codewiki/config.json + keyring."""
488 from codewiki.cli.config_manager import ConfigManager
489
490 manager = ConfigManager()
491 if not manager.load():
492 raise RuntimeError("CodeWiki not configured. Run 'codewiki config set' first.")
493 return manager
494
495
496async def _legacy_generate_docs(arguments: dict[str, Any]) -> list[TextContent]:
497 """Legacy generate_docs — requires CodeWiki LLM configuration."""
498 repo_path = Path(arguments["repo_path"]).expanduser().resolve()
499 output_dir = Path(arguments.get("output_dir", "docs")).expanduser().resolve()
500
501 if not repo_path.exists():
502 return [_text(json.dumps({"error": f"Repository not found: {repo_path}"}))]
503
504 manager = _load_config()
505 config = manager.get_config()
506 api_key = manager.get_api_key()
507
508 from codewiki.src.be.backend import needs_api_key
509

Callers 1

call_toolFunction · 0.85

Calls 12

runMethod · 0.95
is_caw_providerFunction · 0.90
set_cli_contextFunction · 0.90
get_git_commit_hashFunction · 0.90
_textFunction · 0.85
_load_configFunction · 0.85
resolveMethod · 0.80
getMethod · 0.80
get_configMethod · 0.80
get_api_keyMethod · 0.80
from_cliMethod · 0.80

Tested by

no test coverage detected