Skip to content

Commit 506c566

Browse files
committed
feat: Make related docs SDK-specific
- Rust SDK pages link only to /docs/rust/ pages - TypeScript SDK pages link only to /docs/typescript/ pages - Python SDK pages link to concepts/guides/features (as main SDK) - Add package parameter to render_related_section
1 parent 5b930a9 commit 506c566

File tree

2 files changed

+72
-24
lines changed

2 files changed

+72
-24
lines changed

praisonai_tools/docs_generator/generate_rust_docs.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,68 +78,69 @@ def sanitize_description(text: str, max_len: int = 150) -> str:
7878
# Abbreviations to preserve in titles
7979
ABBREVIATIONS = {"llm", "api", "cli", "id", "url", "http", "ai", "io"}
8080

81-
# Related documentation mapping (keyword -> list of (title, path, icon))
81+
# Related documentation mapping - Rust SDK only links to Rust docs
8282
RELATED_DOCS = {
8383
"agent": [
84+
("Rust Overview", "/docs/rust/overview", "book-open"),
8485
("Rust Quickstart", "/docs/rust/quickstart", "rocket"),
8586
("Rust Agent Guide", "/docs/rust/agent", "robot"),
86-
("Agents Concept", "/docs/concepts/agents", "brain"),
87+
("Rust Installation", "/docs/rust/installation", "download"),
8788
],
8889
"builder": [
89-
("Rust Quickstart", "/docs/rust/quickstart", "rocket"),
9090
("Rust Agent Guide", "/docs/rust/agent", "robot"),
91+
("Rust Quickstart", "/docs/rust/quickstart", "rocket"),
9192
],
9293
"tool": [
9394
("Rust Tools Guide", "/docs/rust/tools", "wrench"),
94-
("Tools Concept", "/docs/concepts/tools", "gear"),
95+
("Rust Agent Guide", "/docs/rust/agent", "robot"),
9596
],
9697
"workflow": [
9798
("Rust Agent Flow", "/docs/rust/agent-flow", "diagram-project"),
9899
("Rust Agent Team", "/docs/rust/agent-team", "users"),
99-
("AgentFlow Concept", "/docs/concepts/agentflow", "route"),
100100
],
101101
"memory": [
102102
("Rust Memory Guide", "/docs/rust/memory", "brain"),
103-
("Memory Concept", "/docs/concepts/memory", "database"),
103+
("Rust Agent Guide", "/docs/rust/agent", "robot"),
104104
],
105105
"llm": [
106-
("Models Overview", "/docs/models", "microchip"),
107-
("Model Failover", "/docs/features/model-failover", "shield"),
106+
("Rust Overview", "/docs/rust/overview", "book-open"),
107+
("Rust Agent Guide", "/docs/rust/agent", "robot"),
108108
],
109109
"config": [
110-
("Configuration Overview", "/docs/configuration/index", "gear"),
110+
("Rust Installation", "/docs/rust/installation", "gear"),
111+
("Rust Overview", "/docs/rust/overview", "book-open"),
111112
],
112113
"error": [
113-
("Guardrails Feature", "/docs/features/guardrails", "shield"),
114+
("Rust Overview", "/docs/rust/overview", "book-open"),
114115
],
115116
"derive": [
116117
("Rust Tools Guide", "/docs/rust/tools", "wrench"),
117118
],
118119
"cli": [
119120
("Rust CLI Guide", "/docs/rust/cli", "terminal"),
120-
("CLI Feature", "/docs/features/cli", "terminal"),
121+
("Rust Quickstart", "/docs/rust/quickstart", "rocket"),
121122
],
122123
"chat": [
123-
("Chat Feature", "/docs/features/chat", "comments"),
124124
("Rust CLI Guide", "/docs/rust/cli", "terminal"),
125125
],
126126
"prompt": [
127127
("Rust CLI Guide", "/docs/rust/cli", "terminal"),
128128
],
129129
"run": [
130130
("Rust CLI Guide", "/docs/rust/cli", "terminal"),
131-
("Workflows Feature", "/docs/features/workflows", "diagram-project"),
131+
("Rust Agent Flow", "/docs/rust/agent-flow", "diagram-project"),
132132
],
133133
"task": [
134-
("Tasks Concept", "/docs/concepts/tasks", "list-check"),
134+
("Rust Agent Team", "/docs/rust/agent-team", "users"),
135+
("Rust Agent Flow", "/docs/rust/agent-flow", "diagram-project"),
135136
],
136137
"team": [
137138
("Rust Agent Team", "/docs/rust/agent-team", "users"),
138-
("AgentTeam Concept", "/docs/concepts/agentteam", "users"),
139+
("Rust Agent Flow", "/docs/rust/agent-flow", "diagram-project"),
139140
],
140141
"flow": [
141142
("Rust Agent Flow", "/docs/rust/agent-flow", "diagram-project"),
142-
("AgentFlow Concept", "/docs/concepts/agentflow", "route"),
143+
("Rust Agent Team", "/docs/rust/agent-team", "users"),
143144
],
144145
}
145146

praisonai_tools/docs_generator/generator.py

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,53 @@ def friendly_title(name: str, page_type: str = "class") -> str:
501501
],
502502
}
503503

504+
# TypeScript SDK links to TypeScript-specific docs
505+
TYPESCRIPT_RELATED_DOCS = {
506+
"agent": [
507+
("TypeScript Overview", "/docs/typescript/overview", "book-open"),
508+
("TypeScript Quickstart", "/docs/typescript/quickstart", "rocket"),
509+
("TypeScript Agent", "/docs/typescript/agent", "robot"),
510+
],
511+
"tool": [
512+
("TypeScript Tools", "/docs/typescript/tools", "wrench"),
513+
("TypeScript Agent", "/docs/typescript/agent", "robot"),
514+
],
515+
"config": [
516+
("TypeScript Installation", "/docs/typescript/installation", "download"),
517+
("TypeScript Overview", "/docs/typescript/overview", "book-open"),
518+
],
519+
"memory": [
520+
("TypeScript Memory", "/docs/typescript/memory", "brain"),
521+
],
522+
"workflow": [
523+
("TypeScript AgentFlow", "/docs/typescript/agentflow", "diagram-project"),
524+
("TypeScript AgentTeam", "/docs/typescript/agentteam", "users"),
525+
],
526+
"team": [
527+
("TypeScript AgentTeam", "/docs/typescript/agentteam", "users"),
528+
],
529+
"flow": [
530+
("TypeScript AgentFlow", "/docs/typescript/agentflow", "diagram-project"),
531+
],
532+
"task": [
533+
("TypeScript AgentTeam", "/docs/typescript/agentteam", "users"),
534+
],
535+
"mcp": [
536+
("TypeScript MCP", "/docs/typescript/mcp", "plug"),
537+
],
538+
"llm": [
539+
("TypeScript Overview", "/docs/typescript/overview", "book-open"),
540+
],
541+
}
504542

505-
def get_related_docs(name: str, max_items: int = 5) -> list:
543+
544+
def get_related_docs(name: str, max_items: int = 5, package: str = "python") -> list:
506545
"""Find related documentation based on keywords in the name.
507546
508547
Args:
509548
name: Class, function, or module name to find related docs for
510549
max_items: Maximum number of related docs to return
550+
package: Package name to determine which mapping to use
511551
512552
Returns:
513553
List of (title, path, icon) tuples, most relevant first
@@ -516,8 +556,14 @@ def get_related_docs(name: str, max_items: int = 5) -> list:
516556
related = []
517557
seen_paths = set()
518558

559+
# Select the appropriate mapping based on package
560+
if package == "typescript":
561+
docs_map = TYPESCRIPT_RELATED_DOCS
562+
else:
563+
docs_map = RELATED_DOCS # Python packages use the main mapping
564+
519565
# Check each keyword against the name
520-
for keyword, docs in RELATED_DOCS.items():
566+
for keyword, docs in docs_map.items():
521567
if keyword in name_lower:
522568
for doc in docs:
523569
if doc[1] not in seen_paths:
@@ -527,17 +573,18 @@ def get_related_docs(name: str, max_items: int = 5) -> list:
527573
return related[:max_items]
528574

529575

530-
def render_related_section(name: str, max_items: int = 5) -> str:
576+
def render_related_section(name: str, max_items: int = 5, package: str = "python") -> str:
531577
"""Render a CardGroup section with related documentation links.
532578
533579
Args:
534580
name: Class, function, or module name
535581
max_items: Maximum related items to show
582+
package: Package name to determine which links to use
536583
537584
Returns:
538585
MDX string with CardGroup, or empty string if no related docs
539586
"""
540-
related = get_related_docs(name, max_items)
587+
related = get_related_docs(name, max_items, package)
541588
if not related:
542589
return ""
543590

@@ -1249,7 +1296,7 @@ def _render_module(self, info: ModuleInfo) -> str:
12491296
lines.append(f"| `{name}` | `{escape_for_table(truncated_val, is_type=False)}` |")
12501297
lines.append("")
12511298
# Add related documentation section
1252-
related_section = render_related_section(info.short_name, max_items=5)
1299+
related_section = render_related_section(info.short_name, max_items=5, package=self.package_name)
12531300
if related_section:
12541301
lines.append(related_section)
12551302

@@ -1333,7 +1380,7 @@ def _render_module_granular(self, info: ModuleInfo) -> str:
13331380
lines.append(f"| `{name}` | `{escape_for_table(truncated_val, is_type=False)}` |")
13341381
lines.append("")
13351382
# Add related documentation section
1336-
related_section = render_related_section(info.short_name, max_items=5)
1383+
related_section = render_related_section(info.short_name, max_items=5, package=self.package_name)
13371384
if related_section:
13381385
lines.append(related_section)
13391386

@@ -1467,7 +1514,7 @@ def _render_class_page(self, cls: ClassInfo, module_info: ModuleInfo) -> str:
14671514
lines.append(f"```{lang}\n{cls.examples[0]}\n```\n")
14681515

14691516
# Add related documentation section
1470-
related_section = render_related_section(cls.name, max_items=5)
1517+
related_section = render_related_section(cls.name, max_items=5, package=self.package_name)
14711518
if related_section:
14721519
lines.append(related_section)
14731520

@@ -1577,7 +1624,7 @@ def _render_function_page(self, func: FunctionInfo, module_info: ModuleInfo, cls
15771624
lines.append(f"```python\n{dedented_ex}\n```\n")
15781625

15791626
# Add related documentation section
1580-
related_section = render_related_section(func.name, max_items=5)
1627+
related_section = render_related_section(func.name, max_items=5, package=self.package_name)
15811628
if related_section:
15821629
lines.append(related_section)
15831630

0 commit comments

Comments
 (0)