@@ -78,6 +78,109 @@ def sanitize_description(text: str, max_len: int = 150) -> str:
7878# Abbreviations to preserve in titles
7979ABBREVIATIONS = {"llm" , "api" , "cli" , "id" , "url" , "http" , "ai" , "io" }
8080
81+ # Related documentation mapping (keyword -> list of (title, path, icon))
82+ RELATED_DOCS = {
83+ "agent" : [
84+ ("Rust Quickstart" , "/docs/rust/quickstart" , "rocket" ),
85+ ("Rust Agent Guide" , "/docs/rust/agent" , "robot" ),
86+ ("Agents Concept" , "/docs/concepts/agents" , "brain" ),
87+ ],
88+ "builder" : [
89+ ("Rust Quickstart" , "/docs/rust/quickstart" , "rocket" ),
90+ ("Rust Agent Guide" , "/docs/rust/agent" , "robot" ),
91+ ],
92+ "tool" : [
93+ ("Rust Tools Guide" , "/docs/rust/tools" , "wrench" ),
94+ ("Tools Concept" , "/docs/concepts/tools" , "gear" ),
95+ ],
96+ "workflow" : [
97+ ("Rust Agent Flow" , "/docs/rust/agent-flow" , "diagram-project" ),
98+ ("Rust Agent Team" , "/docs/rust/agent-team" , "users" ),
99+ ("AgentFlow Concept" , "/docs/concepts/agentflow" , "route" ),
100+ ],
101+ "memory" : [
102+ ("Rust Memory Guide" , "/docs/rust/memory" , "brain" ),
103+ ("Memory Concept" , "/docs/concepts/memory" , "database" ),
104+ ],
105+ "llm" : [
106+ ("Models Overview" , "/docs/models" , "microchip" ),
107+ ("Model Failover" , "/docs/features/model-failover" , "shield" ),
108+ ],
109+ "config" : [
110+ ("Configuration Overview" , "/docs/configuration/index" , "gear" ),
111+ ],
112+ "error" : [
113+ ("Guardrails Feature" , "/docs/features/guardrails" , "shield" ),
114+ ],
115+ "derive" : [
116+ ("Rust Tools Guide" , "/docs/rust/tools" , "wrench" ),
117+ ],
118+ "cli" : [
119+ ("Rust CLI Guide" , "/docs/rust/cli" , "terminal" ),
120+ ("CLI Feature" , "/docs/features/cli" , "terminal" ),
121+ ],
122+ "chat" : [
123+ ("Chat Feature" , "/docs/features/chat" , "comments" ),
124+ ("Rust CLI Guide" , "/docs/rust/cli" , "terminal" ),
125+ ],
126+ "prompt" : [
127+ ("Rust CLI Guide" , "/docs/rust/cli" , "terminal" ),
128+ ],
129+ "run" : [
130+ ("Rust CLI Guide" , "/docs/rust/cli" , "terminal" ),
131+ ("Workflows Feature" , "/docs/features/workflows" , "diagram-project" ),
132+ ],
133+ "task" : [
134+ ("Tasks Concept" , "/docs/concepts/tasks" , "list-check" ),
135+ ],
136+ "team" : [
137+ ("Rust Agent Team" , "/docs/rust/agent-team" , "users" ),
138+ ("AgentTeam Concept" , "/docs/concepts/agentteam" , "users" ),
139+ ],
140+ "flow" : [
141+ ("Rust Agent Flow" , "/docs/rust/agent-flow" , "diagram-project" ),
142+ ("AgentFlow Concept" , "/docs/concepts/agentflow" , "route" ),
143+ ],
144+ }
145+
146+
147+ def get_related_docs (name : str , max_items : int = 5 ) -> list :
148+ """Find related documentation based on keywords in the name."""
149+ name_lower = name .lower ()
150+ related = []
151+ seen_paths = set ()
152+
153+ for keyword , docs in RELATED_DOCS .items ():
154+ if keyword in name_lower :
155+ for doc in docs :
156+ if doc [1 ] not in seen_paths :
157+ related .append (doc )
158+ seen_paths .add (doc [1 ])
159+
160+ return related [:max_items ]
161+
162+
163+ def render_related_section (name : str , max_items : int = 5 ) -> str :
164+ """Render a CardGroup section with related documentation links."""
165+ related = get_related_docs (name , max_items )
166+ if not related :
167+ return ""
168+
169+ cards = []
170+ for title , path , icon in related :
171+ cards .append (f' <Card title="{ title } " icon="{ icon } " href="{ path } " />' )
172+
173+ return f"""
174+
175+ ---
176+
177+ ## Related Documentation
178+
179+ <CardGroup cols={{2}}>
180+ { chr (10 ).join (cards )}
181+ </CardGroup>
182+ """
183+
81184
82185def friendly_title (name : str , page_type : str = "class" ) -> str :
83186 """Convert a name to a friendly, human-readable title.
@@ -202,6 +305,11 @@ def generate_module_page(info, output_dir: Path, dry_run: bool = False) -> str:
202305 content += " </Card>\n "
203306 content += "</CardGroup>\n \n "
204307
308+ # Add related documentation section
309+ related = render_related_section (short_name , max_items = 5 )
310+ if related :
311+ content += related
312+
205313 module_file = output_dir / 'modules' / f'{ short_name } .mdx'
206314 if not dry_run :
207315 module_file .parent .mkdir (parents = True , exist_ok = True )
@@ -266,6 +374,11 @@ def generate_class_page(cls, module_info, output_dir: Path, dry_run: bool = Fals
266374 content += f"| `{ p .name } ` | `{ p_type } ` |\n "
267375 content += "\n "
268376
377+ # Add related documentation section
378+ related = render_related_section (cls .name , max_items = 5 )
379+ if related :
380+ content += related
381+
269382 class_file = output_dir / 'classes' / f'{ cls .name } .mdx'
270383 if not dry_run :
271384 class_file .parent .mkdir (parents = True , exist_ok = True )
@@ -317,6 +430,11 @@ def generate_function_page(func, module_info, output_dir: Path, dry_run: bool =
317430 content += f"| `{ p .name } ` | `{ p_type } ` | { p_desc } |\n "
318431 content += "\n "
319432
433+ # Add related documentation section
434+ related = render_related_section (func .name , max_items = 5 )
435+ if related :
436+ content += related
437+
320438 func_file = output_dir / 'functions' / f'{ func .name } .mdx'
321439 if not dry_run :
322440 func_file .parent .mkdir (parents = True , exist_ok = True )
0 commit comments