Skip to content

Commit 354e566

Browse files
committed
update 2
1 parent dfcb2e1 commit 354e566

File tree

2 files changed

+55
-45
lines changed

2 files changed

+55
-45
lines changed

praisonai_tools/docs_generator/generator.py

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,17 @@ def validate_mdx(content: str) -> List[str]:
173173
return errors
174174

175175

176-
def escape_for_table(text: str) -> str:
176+
def escape_for_table(text: str, is_type: bool = False) -> str:
177177
"""Escape text for use in markdown tables."""
178178
if not text:
179179
return text
180180

181-
text = sanitize_type_for_mdx(text) or text
181+
if is_type:
182+
text = sanitize_type_for_mdx(text) or text
183+
182184
text = text.replace('|', '\\|')
183-
text = text.replace('{', '\\{').replace('}', '\\}')
184-
text = re.sub(r'<([a-zA-Z_][a-zA-Z0-9_]*)>', r'&lt;\1&gt;', text)
185+
# Use HTML entities for angle brackets to avoid tag confusion
186+
text = text.replace('<', '&lt;').replace('>', '&gt;')
185187

186188
return text
187189

@@ -212,6 +214,7 @@ def sanitize_description(text: str, max_length: int = 150) -> str:
212214
}
213215

214216
ICON_MAP = {
217+
# Core Components
215218
"agent": "robot",
216219
"agents": "users",
217220
"task": "list-check",
@@ -234,60 +237,63 @@ def sanitize_description(text: str, max_length: int = 150) -> str:
234237
"workflows": "route",
235238
"telemetry": "chart-line",
236239
"search": "magnifying-glass",
237-
"crawl": "spider",
238-
"newspaper": "newspaper",
239-
"firecrawl": "flame",
240-
"spider": "spider",
241-
"jina": "leaf",
242-
"exa": "compass",
240+
241+
# Modules & Integration
242+
"a2a": "network-wired",
243+
"agui": "window-maximize",
244+
"bus": "bus",
245+
"chunking": "scissors",
246+
"compaction": "compress",
247+
"background": "layer-group",
248+
"embedding": "layer-group",
249+
"embed": "layer-group",
250+
"escalation": "arrow-trend-up",
251+
"eval": "gauge",
252+
"flow_display": "diagram-project",
253+
"dimensions": "ruler-combined",
254+
"feature_configs": "sliders",
255+
"param_resolver": "code-fork",
256+
"parse_utils": "file-magnifying-glass",
257+
"presets": "bookmark",
258+
"main": "house",
259+
"index": "house",
260+
"server": "server",
261+
"mcp_server": "server",
243262
"acp": "server",
244263
"adapters": "plug",
245264
"api": "code",
265+
"lsp": "code",
246266
"auto": "magic",
247267
"browser": "globe",
248-
"capabilities": "star",
249-
"chat": "comments",
250-
"cli": "terminal",
251-
"code": "code",
252-
"context": "brain",
253-
"deploy": "cloud-arrow-up",
254-
"docs_runner": "book",
255-
"inbuilt_tools": "toolbox",
256-
"mcp_server": "server",
257-
"inc": "plus",
258268
"public": "globe",
259-
"version": "tag",
269+
"deploy": "cloud-arrow-up",
260270
"upload_vision": "upload",
261271
"train_vision": "eye",
262-
"agents_generator": "wand-magic-sparkles",
263-
"agent_scheduler": "calendar-day",
272+
"obs": "eye",
264273
"ai": "brain",
274+
"context": "brain",
265275
"cache": "database",
266-
"events": "bell",
267276
"db": "database",
268-
"main": "house",
269-
"server": "server",
270-
"lsp": "code",
271-
"obs": "eye",
277+
"base": "database",
278+
"events": "bell",
272279
"output": "file-export",
273-
"compaction": "compress",
274-
"background": "layers-group",
275280
"models": "box",
276281
"result": "square-check",
277282
"retrieval_config": "gears",
278283
"manager": "users-gear",
279-
"dimensions": "ruler-combined",
280-
"embed": "layer-group",
281-
"feature_configs": "sliders",
282-
"param_resolver": "code-fork",
283-
"parse_utils": "file-magnifying-glass",
284-
"presets": "bookmark",
285-
"default": "file-code",
286-
"index": "house",
287284
"types": "tags",
288-
"base": "database",
285+
"version": "tag",
286+
"inc": "plus",
287+
"video": "video",
288+
"video_agent": "video",
289+
"audio_agent": "microphone",
290+
"ocr_agent": "file-lines",
291+
"image_agent": "image",
292+
"agent_scheduler": "calendar-day",
293+
"agents_generator": "wand-magic-sparkles",
289294
"decorator": "wand-magic-sparkles",
290295
"utils": "screwdriver-wrench",
296+
"default": "file-code",
291297
}
292298

293299
def get_icon_for_module(module_name: str) -> str:
@@ -668,7 +674,11 @@ def _render_module(self, info: ModuleInfo) -> str:
668674
"|------|-------|",
669675
])
670676
for name, value in info.constants:
671-
lines.append(f"| `{name}` | `{escape_for_table(str(value)[:50])}` |")
677+
val_str = str(value)
678+
truncated_val = val_str[:200]
679+
if len(val_str) > 200:
680+
truncated_val += "..."
681+
lines.append(f"| `{name}` | `{escape_for_table(truncated_val, is_type=False)}` |")
672682
lines.append("")
673683

674684
return "\n".join(lines)
@@ -691,7 +701,7 @@ def _render_class(self, cls: ClassInfo, package: str) -> List[str]:
691701
"|-----------|------|----------|---------|",
692702
])
693703
for p in cls.init_params:
694-
lines.append(f"| `{p.name}` | `{escape_for_table(p.type)}` | {'Yes' if p.required else 'No'} | `{escape_for_table(p.default) if p.default else '-'}` |")
704+
lines.append(f"| `{p.name}` | `{escape_for_table(p.type, is_type=True)}` | {'Yes' if p.required else 'No'} | `{escape_for_table(p.default, is_type=False) if p.default else '-'}` |")
695705
lines.append("</Accordion>\n")
696706

697707
if cls.properties:
@@ -702,13 +712,13 @@ def _render_class(self, cls: ClassInfo, package: str) -> List[str]:
702712
"|----------|------|",
703713
])
704714
for p in cls.properties:
705-
lines.append(f"| `{p.name}` | `{escape_for_table(p.type)}` |")
715+
lines.append(f"| `{p.name}` | `{escape_for_table(p.type, is_type=True)}` |")
706716
lines.append("</Accordion>\n")
707717

708718
if cls.methods:
709719
lines.append('<Accordion title="Methods">')
710720
for m in cls.methods:
711-
lines.append(f"- **{'async ' if m.is_async else ''}{m.name}**(`{escape_for_table(m.signature)}`) → `{escape_for_table(m.return_type)}`")
721+
lines.append(f"- **{'async ' if m.is_async else ''}{m.name}**(`{escape_for_table(m.signature, is_type=True)}`) → `{escape_for_table(m.return_type, is_type=True)}`")
712722
if m.docstring:
713723
lines.append(f" {escape_mdx(m.docstring.split('\\n')[0][:80])}")
714724
lines.append("</Accordion>\n")
@@ -733,7 +743,7 @@ def _render_function(self, func: FunctionInfo, package: str) -> List[str]:
733743
if func.params:
734744
lines.append('<Expandable title="Parameters">')
735745
for p in func.params:
736-
lines.append(f"- **{p.name}** (`{escape_for_table(p.type)}`)")
746+
lines.append(f"- **{p.name}** (`{escape_for_table(p.type, is_type=True)}`)")
737747
if p.description: lines.append(f" {escape_mdx(p.description)}")
738748
lines.append("</Expandable>\n")
739749

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "praisonai-tools"
3-
version = "0.2.9"
3+
version = "0.2.10"
44
description = "Extended tools for PraisonAI Agents"
55
authors = [
66
{name = "Mervin Praison"}

0 commit comments

Comments
 (0)