()
| 613 | |
| 614 | |
| 615 | def main(): |
| 616 | parser = argparse.ArgumentParser(description="Generate VitePress docs index from data layer") |
| 617 | parser.add_argument("--output-root", default=".", |
| 618 | help="Repo root directory (default: current directory)") |
| 619 | parser.add_argument("--regulation", default=None, |
| 620 | help="Only process a specific regulation (nmpa, eu_mdr, fda, shared)") |
| 621 | parser.add_argument("--dry-run", action="store_true", |
| 622 | help="Show what would be generated without writing files") |
| 623 | args = parser.parse_args() |
| 624 | |
| 625 | repo_root = Path(args.output_root).resolve() |
| 626 | print(f"\nGenerating docs index pages from {repo_root}") |
| 627 | if args.dry_run: |
| 628 | print("[DRY RUN MODE]\n") |
| 629 | |
| 630 | total_entries = 0 |
| 631 | total_pages = 0 |
| 632 | total_synced = 0 |
| 633 | all_section_entries: Dict[str, List[dict]] = {} |
| 634 | |
| 635 | for section_key, (docs_page_path, section_title, regulation, sync_content) in SECTION_MAP.items(): |
| 636 | if args.regulation and regulation != args.regulation: |
| 637 | continue |
| 638 | |
| 639 | data_dir = repo_root / section_key |
| 640 | entries = get_doc_entries(data_dir, section_key) |
| 641 | |
| 642 | if not entries: |
| 643 | continue |
| 644 | |
| 645 | if sync_content: |
| 646 | # Sync full content files into docs/zh/ for VitePress rendering |
| 647 | synced = sync_content_to_docs(section_key, entries, repo_root, dry_run=args.dry_run) |
| 648 | total_synced += synced |
| 649 | # Sync English content files into docs/en/ for VitePress rendering |
| 650 | en_synced = sync_en_content_to_docs(section_key, entries, repo_root, dry_run=args.dry_run) |
| 651 | total_synced += en_synced |
| 652 | all_section_entries[section_key] = entries |
| 653 | |
| 654 | # eu_mdr/mdcg has a hand-written index page — skip auto-generation to avoid overwriting |
| 655 | if section_key == "eu_mdr/mdcg": |
| 656 | print(f" Skipped index page for {section_key} (hand-written, preserved)") |
| 657 | continue |
| 658 | |
| 659 | generate_section_page( |
| 660 | section_key, docs_page_path, section_title, |
| 661 | entries, repo_root, dry_run=args.dry_run |
| 662 | ) |
| 663 | total_entries += len(entries) |
| 664 | total_pages += 1 |
| 665 | |
| 666 | # Generate dynamic sidebar config |
| 667 | if all_section_entries: |
| 668 | generate_sidebar_json(all_section_entries, repo_root, dry_run=args.dry_run) |
| 669 | |
| 670 | print(f"\nDone: {total_pages} index pages updated, {total_entries} entries, {total_synced} content files synced") |
| 671 | |
| 672 |
no test coverage detected