updated docs strings and added README.md
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
"""
|
||||
# Summary
|
||||
|
||||
MCP renderer implementation.
|
||||
|
||||
This module defines the `MCPRenderer` class, which generates documentation
|
||||
resources compatible with the Model Context Protocol (MCP).
|
||||
"""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Dict, List
|
||||
@@ -21,11 +30,14 @@ class MCPRenderer:
|
||||
Generate MCP documentation resources for a project.
|
||||
|
||||
The renderer serializes each module into a JSON resource and produces
|
||||
supporting metadata files such as ``nav.json`` and ``index.json``.
|
||||
supporting metadata files such as `nav.json` and `index.json`.
|
||||
|
||||
Args:
|
||||
project: Documentation project model to render.
|
||||
out_dir: Directory where MCP resources will be written.
|
||||
project (Project):
|
||||
Documentation project model to render.
|
||||
|
||||
out_dir (Path):
|
||||
Directory where MCP resources will be written.
|
||||
"""
|
||||
modules_dir = out_dir / "modules"
|
||||
modules_dir.mkdir(parents=True, exist_ok=True)
|
||||
@@ -64,8 +76,11 @@ class MCPRenderer:
|
||||
Serialize a module into an MCP resource file.
|
||||
|
||||
Args:
|
||||
module: Module instance to serialize.
|
||||
modules_dir: Directory where module JSON files are stored.
|
||||
module (Module):
|
||||
Module instance to serialize.
|
||||
|
||||
modules_dir (Path):
|
||||
Directory where module JSON files are stored.
|
||||
"""
|
||||
payload = {
|
||||
"module": module.path,
|
||||
@@ -81,10 +96,12 @@ class MCPRenderer:
|
||||
Convert a Module model into MCP-compatible structured data.
|
||||
|
||||
Args:
|
||||
module: Module instance to convert.
|
||||
module (Module):
|
||||
Module instance to convert.
|
||||
|
||||
Returns:
|
||||
Dictionary representing the module and its documented objects.
|
||||
Dict:
|
||||
Dictionary representing the module and its documented objects.
|
||||
"""
|
||||
data: Dict = {
|
||||
"path": module.path,
|
||||
@@ -102,10 +119,12 @@ class MCPRenderer:
|
||||
Recursively convert a DocObject into structured MCP data.
|
||||
|
||||
Args:
|
||||
obj: Documentation object to convert.
|
||||
obj (DocObject):
|
||||
Documentation object to convert.
|
||||
|
||||
Returns:
|
||||
Dictionary describing the object and any nested members.
|
||||
Dict:
|
||||
Dictionary describing the object and any nested members.
|
||||
"""
|
||||
data: Dict = {
|
||||
"name": obj.name,
|
||||
@@ -130,9 +149,11 @@ class MCPRenderer:
|
||||
Serialize data to formatted JSON.
|
||||
|
||||
Args:
|
||||
data: Dictionary to serialize.
|
||||
data (Dict):
|
||||
Dictionary to serialize.
|
||||
|
||||
Returns:
|
||||
JSON string formatted with indentation and UTF-8 compatibility.
|
||||
str:
|
||||
JSON string formatted with indentation and UTF-8 compatibility.
|
||||
"""
|
||||
return json.dumps(data, indent=2, ensure_ascii=False)
|
||||
|
||||
Reference in New Issue
Block a user