From a9b7d4b9d1e5291c9949209030f01955c34c35bb Mon Sep 17 00:00:00 2001 From: pikabot Date: Mon, 20 Mar 2023 10:27:05 +0800 Subject: [PATCH] support sort docgen --- package/docgen.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package/docgen.py b/package/docgen.py index ca6ce7d00..55f14d038 100644 --- a/package/docgen.py +++ b/package/docgen.py @@ -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指令项