MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / _write_api_index

Function _write_api_index

Scripts/emit_docs.py:542–594  ·  view source on GitHub ↗

Write docs/api/index.md — master class list, ordered by source folder structure.

(entries: list, api_root: str, parent_map: dict)

Source from the content-addressed store, hash-verified

540
541
542def _write_api_index(entries: list, api_root: str, parent_map: dict):
543 """Write docs/api/index.md — master class list, ordered by source folder structure."""
544 lines = []
545 lines.append('# API Reference\n')
546 lines.append(
547 'Auto-generated from C++ header files in `Source/URLab/Public/`.\n'
548 'All UPROPERTY specifiers, Blueprint access, and override flags are preserved.\n'
549 '\n'
550 '> Organised to match the source folder structure in `Mujoco/`.\n'
551 )
552
553 # Group by section
554 section_map = defaultdict(list)
555 for e in sorted(entries, key=lambda x: (_get_depth(x['name'], parent_map), x['name'])):
556 section_map[e['section']].append(e)
557
558 for section in NAV_SECTION_ORDER:
559 if section not in section_map:
560 continue
561 items = section_map[section]
562 title, desc = _SECTION_META.get(section, (section, ''))
563 lines.append(f'## {title}\n')
564 if desc:
565 lines.append(f'{desc}\n')
566 lines.append('| Name | Kind | Description |')
567 lines.append('|---|---|---|')
568 for e in items:
569 name = e['name']
570 kind = e['kind'].capitalize()
571 brief = _esc(_clean_brief(e.get('brief', '') or ''))
572 rel = e['path'].replace('api/', '', 1)
573 lines.append(f'| [{name}]({rel}) | {kind} | {brief} |')
574 lines.append('')
575
576 # Any sections not in NAV_SECTION_ORDER
577 for section in sorted(section_map.keys()):
578 if section in NAV_SECTION_ORDER:
579 continue
580 title, desc = _SECTION_META.get(section, (section, ''))
581 lines.append(f'## {title}\n')
582 lines.append('| Name | Kind | Description |')
583 lines.append('|---|---|---|')
584 for e in sorted(section_map[section], key=lambda x: (_get_depth(x['name'], parent_map), x['name'])):
585 name = e['name']
586 kind = e['kind'].capitalize()
587 brief = _esc(_clean_brief(e.get('brief', '') or ''))
588 rel = e['path'].replace('api/', '', 1)
589 lines.append(f'| [{name}]({rel}) | {kind} | {brief} |')
590 lines.append('')
591
592 out_path = os.path.join(api_root, 'index.md')
593 with open(out_path, 'w', encoding='utf-8') as f:
594 f.write('\n'.join(lines))
595
596
597def build_nav_yaml(nav: dict, parent_map: dict) -> str:

Callers 1

emit_docsFunction · 0.85

Calls 3

_get_depthFunction · 0.85
_escFunction · 0.85
_clean_briefFunction · 0.85

Tested by

no test coverage detected