forked from ApolloAuto/apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoxygen_helpers.py
779 lines (692 loc) · 26.4 KB
/
doxygen_helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""doxygen_helpers.py
"""
import sys
import os
import pathlib
import subprocess
import jinja2
import yaml
from urllib.parse import quote
from urllib.parse import unquote
from xml.etree import ElementTree as ET
# from jinja2 import Environment, PackageLoader, select_autoescape
# env = Environment(loader=PackageLoader("doxygen"),
# autoescape=select_autoescape())
CATEGORIES = (
('core', 'cyber', 'cyber'),
('core', 'planning', 'modules/external_command'),
('core', 'planning', 'modules/routing'),
('core', 'planning', 'modules/planning'),
('core', 'planning', 'modules/storytelling'),
('core', 'control', 'modules/control'),
('core', 'canbus', 'modules/canbus'),
('core', 'canbus', 'modules/canbus_vehicle'),
('core', 'perception', 'modules/perception'),
('core', 'perception', 'modules/third_party_perception'),
('core', 'prediction', 'modules/prediction'),
('core', 'drivers', 'modules/drivers'),
('core', 'localization', 'modules/localization'),
('core', 'dreamview', 'modules/dreamview'),
('core', 'dreamview', 'modules/dreamview_plus'),
('core', 'task_manager', 'modules/task_manager'),
('core', 'monitor', 'modules/monitor'),
('core', 'guardian', 'modules/guardian'),
('core', 'tools', 'modules/tools'),
('core', 'audio', 'modules/audio'),
('core', 'bridge', 'modules/bridge'),
('core', 'common', 'modules/common'),
('core', 'common', 'modules/common_msgs'),
('core', 'contrib', 'modules/contrib'),
('core', 'v2x', 'modules/x2x'),
('core', 'transform', 'modules/transform'),
('core', 'calibration', 'modules/calibration'),
('core', 'data', 'modules/data'),
('core', 'map', 'modules/map'),
)
def remove_prefix(text, prefix):
"""remove_prefix
"""
if text.startswith(prefix):
return text[len(prefix):]
return text
def remove_suffix(text, suffix):
"""remove_suffix
"""
if text.endswith(suffix):
return text[:-len(suffix)]
return text
def doxylink_encode(path):
"""doxylink_encode
"""
rules = (
('.md', ''),
('_', '\\_\\_'),
('.', '_8'),
('/', '_2'),
('+', '_09'),
(' ', '_01'),
)
result = path
for rule in rules:
result = result.replace(*rule)
return result
def doxylink_encode_unescape(path):
"""doxylink_encode
"""
rules = (
('.md', ''),
('_', '__'),
('.', '_8'),
('/', '_2'),
('+', '_09'),
(' ', '_01'),
)
result = path
for rule in rules:
result = result.replace(*rule)
result = quote(result).replace('%', '_x')
return result
class Package():
"""Package"""
def __init__(self, path):
"""__init__
Args:
path (str): package path
Returns:
None
"""
self.path = path
self.cyberfile = ET.parse(os.path.join(path, 'cyberfile.xml'))
self.category = ''
@property
def name(self):
"""name
"""
return self.cyberfile.findtext('name')
@property
def version(self):
"""version
"""
return self.cyberfile.findtext('version')
@property
def depends(self):
"""depends
"""
return [x.text for x in self.cyberfile.findall('depend')]
@property
def readme_cn_path(self):
"""readme_cn_path
"""
return pathlib.Path(self.path).joinpath('README_cn.md')
@property
def readme_en_path(self):
"""readme_en_path
"""
return pathlib.Path(self.path).joinpath('README.md')
@property
def readme_path(self):
"""readme_path
"""
if self.readme_cn_path.exists():
return self.readme_cn_path
if self.readme_en_path.exists():
return self.readme_en_path
return self.readme_cn_path
def readme_md_link(self):
"""readme_md_link
"""
return f'[{self.name}]({self.readme_path})'
def readme_md_doxylink(self):
"""readme_md_doxylink
"""
encoded_path = doxylink_encode(self.readme_path.as_posix())
return f'@subpage md_{encoded_path} "{self.name}"'
def readme_md_doxylink_ref(self):
"""readme_md_doxylink_ref
"""
encoded_path = doxylink_encode_unescape(self.readme_path.as_posix())
return f'@ref md_{encoded_path}'
def find_packages(prefix: str):
"""find packages in prefix
"""
for root, _, files in os.walk(prefix):
if 'cyberfile.xml' in files:
yield Package(root)
continue
def generate_packages_cn_md():
"""generate_packages_cn_md
"""
categories = CATEGORIES
pkg_core_cn_md_path = 'docs/packages/packages_core_cn.md'
output = [
r'# 包',
r'',
f'@subpage md_{doxylink_encode(pkg_core_cn_md_path)} "Apollo Core"',
r'',
r'|仓库|分类|包名|',
r'|---|---|---|',
]
for repo, category, path in categories:
for pkg in find_packages(path):
if pkg.readme_path.exists():
output.append(f'|{repo}|{category}|{pkg.readme_md_link()}|')
prettier_output = subprocess.check_output(
['prettier', '--parser=markdown'],
input='\n'.join(output).encode('utf-8'),
)
print(prettier_output.decode('utf-8'))
def generate_packages_core_cn_md():
"""generate_packages_core_cn_md
"""
categories = CATEGORIES
output = [
r'# Apollo Core',
r'',
r'|仓库|分类|包名|',
r'|---|---|---|',
]
for repo, category, path in categories:
for pkg in find_packages(path):
if pkg.readme_path.exists():
output.append(
f'|{repo}|{category}|{pkg.readme_md_doxylink()}|')
prettier_output = subprocess.check_output(
['prettier', '--parser=markdown'],
input='\n'.join(output).encode('utf-8'),
)
print(prettier_output.decode('utf-8'))
def render_doxygen_tree_item_html(item):
"""render_doxygen_tree_item_html
"""
link = ''
if len(item[1]) > 0:
link = f'@ref md_{doxylink_encode_unescape(item[1])}'
if len(item) >= 3 and len(item[2]) > 0:
return '\n'.join([
f'<tab type="usergroup" visible="yes" title="{item[0]}" intro="" url="{link}">',
*[render_doxygen_tree_item_html(i) for i in item[2]], r'</tab>'
])
return f'<tab type="user" visible="yes" title="{item[0]}" intro="" url="{link}" />'
def generate_treeview_html():
"""generate_treeview_html
"""
tree_data = (
('发版说明', 'docs/RELEASE_cn.md'),
('安装说明', '', (
('必备软件安装指南',
'docs/installation_instructions/essential_software_installation_guide_cn.md'
),
('快速开始', 'docs/installation_instructions/quick_start_cn.md'),
)),
('使用指南', '', (
('包管理使用教程', 'docs/user_guidelines/packages_tutorial_cn.md'),
('核心模块', '', (
('感知能力', '', (
('功能综述', '', (
('模块概述',
'docs/user_guidelines/modules/perception/overview/overview_cn.md'
),
('功能列表',
'docs/user_guidelines/modules/perception/overview/function_list_cn.md'
),
)),
('开发模式', '', (
('参数开发',
'docs/user_guidelines/modules/perception/development/development_params_cn.md'
),
('插件开发',
'docs/user_guidelines/modules/perception/development/development_plugins_cn.md'
),
('新增模型',
'docs/user_guidelines/modules/perception/development/development_models_cn.md'
),
('组件开发',
'docs/user_guidelines/modules/perception/development/development_components_cn.md'
),
)),
('模块解析', '',
(('框架设计',
'docs/user_guidelines/modules/perception/analysis/framework_design_cn.md'
), )),
)),
('规划能力', '', (
('功能综述', '', (
('模块概述',
'docs/user_guidelines/modules/planning/overview/overview_cn.md'
),
('功能列表',
'docs/user_guidelines/modules/planning/overview/function_list_cn.md'
),
)),
('开发模式', '', (
('概述',
'docs/user_guidelines/modules/planning/development/overview_cn.md'
),
('通过发布命令开发',
'docs/user_guidelines/modules/planning/development/development_commands_cn.md'
),
('通过新增插件开发',
'docs/user_guidelines/modules/planning/development/development_plugins_cn.md'
),
('通过配置参数开发',
'docs/user_guidelines/modules/planning/development/development_params_cn.md'
),
)),
('模块解析', '', (
('目录结构',
'docs/user_guidelines/modules/planning/analysis/directory_structure_cn.md'
),
('框架设计',
'docs/user_guidelines/modules/planning/analysis/framework_design_cn.md'
),
)),
)),
)),
('可视化交互工具 Dreamview+', '', (
('Dreamview+ 概述',
'docs/user_guidelines/dreamview_plus/dreamview_plus_overview_cn.md'
),
('Add Panel',
'docs/user_guidelines/dreamview_plus/add_panel_cn.md'),
('Mode Settings',
'docs/user_guidelines/dreamview_plus/mode_settings_cn.md'),
('Resource Manager',
'docs/user_guidelines/dreamview_plus/resource_manager_cn.md'),
('PNC可视化调试', '', (
('场景仿真',
'docs/user_guidelines/dreamview_plus/pnc_visual_debugging/scenario_simulation_cn.md'
),
('复制全部坐标点信息',
'docs/user_guidelines/dreamview_plus/pnc_visual_debugging/copy_coordinate_point_information_cn.md'
),
('测距',
'docs/user_guidelines/dreamview_plus/pnc_visual_debugging/distance_measurement_cn.md'
),
('自由仿真',
'docs/user_guidelines/dreamview_plus/pnc_visual_debugging/free_simulation_cn.md'
),
('轨迹绘制',
'docs/user_guidelines/dreamview_plus/pnc_visual_debugging/trajectory_drawing_cn.md'
),
)),
)),
('研发工具', '', (
('Apollo 研发工具 - aem',
'docs/user_guidelines/tools/tool_aem_cn.md'),
('Apollo 研发工具 - buildtool',
'docs/user_guidelines/tools/tool_buildtool_cn.md'),
)),
)),
('应用实践', '', (('上机实践教程', '', (
('Apollo 感知实践(2.0)', '', (
('基于插件进行开发',
'docs/practices/tutorial/perception_practical_2.0/development_based_on_plugins_cn.md'
),
('基于组件进行开发',
'docs/practices/tutorial/perception_practical_2.0/development_based_on_components_cn.md'
),
('如何在感知模式下播包',
'docs/practices/tutorial/perception_practical_2.0/how_to_play_bag_in_perception_mode_cn.md'
),
)),
('Apollo 规划实践(2.0)', '', (
('左转待转场景仿真调试',
'docs/practices/tutorial/planning_practical_2.0/left_turn_waiting_scene_simulation_debugging_cn.md'
),
('红绿灯场景仿真调试',
'docs/practices/tutorial/planning_practical_2.0/traffic_light_scene_simulation_debugging_cn.md'
),
('限速区域场景仿真调试',
'docs/practices/tutorial/planning_practical_2.0/speed_limit_area_scene_simulation_debugging_cn.md'
),
)),
)), )),
('常见问题', '',
(('Dreamview+', '',
(('如何把英文界面切换为中文',
'docs/faqs/dreamview_plus/how_to_switch_english_to_chinese_cn.md'
), )), )),
)
for item in tree_data:
print(render_doxygen_tree_item_html(item))
categories = CATEGORIES
for repo, category, path in categories:
for pkg in find_packages(path):
if pkg.readme_path.exists():
print(
f'<tab type="user" visible="yes" title="{pkg.name}" intro="" url="{pkg.readme_md_doxylink_ref()}" />'
)
def generate_dir_html(dirpath, prefix='', indent_level=0):
"""generate_dir_html
"""
dir_title = dirpath.split('/')[-1]
indent = ' ' * indent_level
# print(indent + dirpath)
print(
f'{indent}<tab type="usergroup" visible="yes" title="{dir_title}" intro="" url="">'
)
for name in os.listdir(dirpath):
if name.startswith('.'):
continue
if os.path.isdir(os.path.join(dirpath, name)):
generate_dir_html(os.path.join(dirpath, name), prefix,
indent_level + 1)
elif os.path.isfile(os.path.join(dirpath,
name)) and name.endswith('.md'):
filepath = os.path.join(dirpath, name)
sub_indent = ' ' * (indent_level + 1)
title = remove_suffix(name, '.md')
# print(sub_indent + os.path.join(dirpath, name))
print(
f'{sub_indent}<tab type="user" visible="yes" title="{title}" intro="" url="@ref md_{doxylink_encode_unescape(filepath)}" />'
)
# for root, dirs, files in os.walk(dirpath):
# print('root', root)
# print('dirs', dirs)
# print('files', files)
# for filename in files:
# if filename.endswith('.md'):
# filepath = os.path.join(root, filename)
# sub_indent = ' ' * (indent_level + 1)
# title = remove_suffix(filename, '.md')
# print(sub_indent + os.path.join(root, filename))
# # print(
# # f'{sub_indent}<tab type="user" visible="yes" title="{title}" intro="" url="@ref md_{doxylink_encode_unescape(filepath)}" />'
# # )
# print(2)
# for dirname in dirs:
# generate_dir_html(os.path.join(root, dirname), prefix,
# indent_level + 1)
print(f'{indent}</tab>')
def generate_treeview_html2():
"""generate_treeview_html2
"""
dirs1 = (
'docs/发版说明',
'docs/安装指南',
'docs/应用实践',
)
for dirent in dirs1:
generate_dir_html(dirent)
dirs4 = ('docs/框架设计', )
dirs2 = ('docs/工具使用', )
for dirent in dirs2:
generate_dir_html(dirent, 'docs')
# 源代码文档
def scan_dir(dirpath, indent_level=0):
"""scan_dir
"""
print(f'{indent_level}\t{dirpath}/')
for name in os.listdir(dirpath):
if name.startswith('.'):
continue
if os.path.isdir(os.path.join(dirpath, name)):
scan_dir(os.path.join(dirpath, name), indent_level + 1)
elif os.path.isfile(os.path.join(dirpath,
name)) and name.endswith('.md'):
filepath = os.path.join(dirpath, name)
print(f'{indent_level + 1}\t{filepath}')
def scan_docs_dir():
"""scan_docs_dir
"""
dirs1 = (
'docs/发版说明',
'docs/安装指南',
'docs/应用实践',
'docs/框架设计',
'docs/工具使用',
)
for dirent in dirs1:
scan_dir(dirent)
def generate_treeview_html3():
"""generate_treeview_html3
"""
with open('./docs.structure.txt', 'r') as fin:
docs_structure = list(
map(lambda x: x.split('\t'),
fin.read().splitlines()))
output = []
stack = []
last_level = 0
for (level, name) in docs_structure:
level = int(level)
if level < last_level:
for _ in range(last_level - level):
stack.pop()
indent = ' ' * len(stack)
output.append(f'{indent}</tab>')
if name.endswith('/'):
title = name.split('/')[-2]
indent = ' ' * int(level)
# print(f'{indent}{name}')
output.append(
f'{indent}<tab type="usergroup" visible="yes" title="{title}" intro="" url="">'
)
stack.append(name)
elif name.endswith('.md'):
title = remove_suffix(name.split('/')[-1], '.md')
indent = ' ' * int(level)
# print(f'{indent}{name}')
output.append(
f'{indent}<tab type="user" visible="yes" title="{title}" intro="" url="@ref md_{doxylink_encode_unescape(name)}" />'
)
upper_dir = name.split('/')[-2]
if upper_dir == '核心模块':
for line in generate_treeview_modules_html_old():
output.append(line)
last_level = level
while len(stack) > 0:
stack.pop()
indent = ' ' * len(stack)
output.append(f'{indent}</tab>')
# print('\n'.join(output))
with open('./docs/DoxygenLayout.xml.tpl', 'r') as fin:
template = jinja2.Template(fin.read())
print(template.render(docs_structure_html='\n'.join(output)))
return output
class PageItem():
"""PageItem"""
def __init__(self, **attrs):
"""__init__
Args:
title (str): title
Returns:
None
"""
self.title = attrs.get('title', '')
self.intro = attrs.get('intro', '')
self.type = attrs.get('type', '')
self.prefix = attrs.get('prefix', '')
self._url = attrs.get('url', '')
self.pages = []
if 'pages' in attrs:
for page in attrs['pages']:
if type(page) in (str, bytes):
self.pages.append(
PageItem(prefix=pathlib.Path(self.prefix).joinpath(
self.title).as_posix(),
title=page))
else:
self.pages.append(
PageItem(prefix=pathlib.Path(self.prefix).joinpath(
self.title).as_posix(),
**page))
if 'path' in attrs:
self.path = pathlib.Path(attrs['path'])
@property
def url(self):
"""url
"""
if self._url:
return self._url
if hasattr(self, 'path'):
encoded_path = doxylink_encode_unescape(self.path.as_posix())
return f'@ref md_{encoded_path}'
elif pathlib.Path(self.prefix).joinpath(f'{self.title}.md').exists():
encoded_path = doxylink_encode_unescape(
pathlib.Path(
self.prefix).joinpath(f'{self.title}.md').as_posix())
return f'@ref md_{encoded_path}'
elif len(self.pages) > 0:
# dir, no url
return '[none]'
elif pathlib.Path(self.prefix).joinpath(self.title).is_dir():
return '[none]'
return '[none]'
def html(self, level=0):
"""html
"""
indent = ' ' * level
if self.type == 'apollomodules':
return '\n'.join([(f'{indent}<tab type="usergroup" visible="yes"'
f' title="{self.title}"'
f' intro="{self.intro}"'
f' url="{self.url}">'),
*[page.html(level + 1) for page in self.pages],
*generate_treeview_modules_html(level + 1),
f'{indent}</tab>'])
if self.type == 'apollopackages':
return '\n'.join([(f'{indent}<tab type="usergroup" visible="yes"'
f' title="{self.title}"'
f' intro="{self.intro}"'
f' url="{self.url}">'),
*[page.html(level + 1) for page in self.pages],
*generate_treeview_packages_html(level + 1),
f'{indent}</tab>'])
if len(self.pages) > 0:
return '\n'.join([(f'{indent}<tab type="usergroup" visible="yes"'
f' title="{self.title}"'
f' intro="{self.intro}"'
f' url="{self.url}">'),
*[page.html(level + 1) for page in self.pages],
f'{indent}</tab>'])
return (f'{indent}<tab type="user" visible="yes"'
f' title="{self.title}"'
f' intro="{self.intro}"'
f' url="{self.url}" />')
def generate_treeview_html4():
"""generate_treeview_html4
"""
with open('./docs/pages_structure.yaml', 'r') as fin:
structure = yaml.safe_load(fin)
output = []
for page in structure.get('pages', []):
if type(page) in (str, bytes):
# if page is a string, use it as title
item = PageItem(prefix='docs', title=page)
output.append(item.html(2))
continue
item = PageItem(prefix='docs', **page)
output.append(item.html(2))
# print('\n'.join(output))
with open('./docs/DoxygenLayout.xml.tpl', 'r') as fin:
template = jinja2.Template(fin.read())
print(template.render(docs_structure_html='\n'.join(output)))
return output
def generate_treeview_packages_html(level=0):
"""generate_treeview_packages_html
"""
output = []
pkg_map = {}
categories = CATEGORIES
for repo, category, path in categories:
for pkg in find_packages(path):
pkg.category = category
if pkg.readme_path.exists():
pkg_map.setdefault(category, []).append(pkg)
indent = ' ' * level
for category, pkgs in pkg_map.items():
output.append(f'{indent}<tab type="usergroup" visible="yes"'
f' title="{category}" intro="" url="[none]">')
sub_indent = ' ' * (level + 1)
for pkg in pkgs:
output.append(f'{sub_indent}<tab type="user" visible="yes"'
f' title="{pkg.name}"'
f' intro="" url="{pkg.readme_md_doxylink_ref()}" />')
output.append(f'{indent}</tab>')
return output
def generate_treeview_modules_html(level=0):
"""generate_treeview_modules_html
"""
output = []
modules = (
'collection/planning',
'collection/control',
'collection/canbus',
'collection/perception',
'collection/prediction',
'collection/localization',
)
indent = ' ' * level
for module_path in modules:
module = module_path.split('/')[-1]
module_pkg = Package(f'{module_path}')
output.append(f'{indent}<tab type="user" visible="yes"'
f' title="{module}"'
r' intro=""'
f' url="{module_pkg.readme_md_doxylink_ref()}" />')
return output
def generate_treeview_modules_html_old():
"""generate_treeview_modules_html_old
"""
output = []
pkg_map = {}
categories = CATEGORIES
for repo, category, path in categories:
for pkg in find_packages(path):
if pkg.readme_path.exists():
pkg_map[pkg.name] = pkg
modules = (
'collection/planning',
'collection/control',
'collection/canbus',
'collection/perception',
'collection/prediction',
'collection/localization',
)
for module_path in modules:
indent = ' ' * 2
module = module_path.split('/')[-1]
output.append(
f'{indent}<tab type="usergroup" visible="yes" title="{module}" intro="" url="">'
)
module_pkg = Package(f'{module_path}')
output.append(
f'{indent} <tab type="user" visible="yes" title="概述" intro="" url="{module_pkg.readme_md_doxylink_ref()}" />'
)
for dep in module_pkg.depends:
if dep in pkg_map:
pkg = pkg_map[dep]
output.append(
f'{indent} <tab type="user" visible="yes" title="{pkg.name}" intro="" url="{pkg.readme_md_doxylink_ref()}" />'
)
output.append(f'{indent}</tab>')
output.append(
f'{indent}<tab type="usergroup" visible="yes" title="软件包文档" intro="" url="@ref md_docs_2packages_2packages__cn">'
)
output.append(
f'{indent} <tab type="usergroup" visible="yes" title="Apollo Core" intro="" url="@ref md_docs_2packages_2packages__core__cn">'
)
for pkg in pkg_map.values():
if pkg.readme_path.exists():
output.append(
f'{indent} <tab type="user" visible="yes" title="{pkg.name}" intro="" url="{pkg.readme_md_doxylink_ref()}" />'
)
output.append(f'{indent} </tab>')
output.append(f'{indent}</tab>')
return output
def main():
"""main entry
"""
command = 'generate_packages_cn_md'
if len(sys.argv) > 1:
command = sys.argv[1]
entrypoint = globals().get(command)
if callable(entrypoint):
entrypoint()
else:
print(f'Unknown command: {command}')
if __name__ == "__main__":
sys.exit(main())