mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
support sort docgen
This commit is contained in:
parent
9633b7a3cc
commit
a9b7d4b9d1
@ -68,9 +68,16 @@ add_title_to_md_files(directory)
|
||||
# 获取目录下所有的md文件路径
|
||||
md_files = glob.glob(os.path.join(directory, '*.md'))
|
||||
|
||||
def remove_prefix(filename): # 如果文件名以“API_”开头,则去掉该前缀
|
||||
if os.path.basename(filename).startswith("API_"):
|
||||
return filename[4:] # 否则返回原文件名 else: return filename
|
||||
|
||||
md_files_sort = sorted(md_files,key=lambda x: (remove_prefix(x).casefold()))
|
||||
print(md_files_sort)
|
||||
|
||||
# 生成toctree指令内容
|
||||
toctree_content = ''
|
||||
for md_file in md_files:
|
||||
for md_file in md_files_sort:
|
||||
# 获取文件名(不包含扩展名)
|
||||
file_name = os.path.splitext(os.path.basename(md_file))[0]
|
||||
# 生成toctree指令项
|
||||
|
Loading…
x
Reference in New Issue
Block a user