3 Star 23 Fork 14

小荷才露尖尖角/Python-100-Days

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
generate_md_index.py 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
小荷才露尖尖角 提交于 2个月前 . add sphnix support
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2025/4/28
# @USER : Shengji He
# @File : generate_md_index.py
# @Software: PyCharm
# @Version : Python-
# @TASK:
import os
import glob
def main():
# -----------------------------------------------------------
# get md files
# -----------------------------------------------------------
root_folder = r'..\Python-100-Days'
main_msg = ''
other_msg = ''
for directory in os.listdir(root_folder):
cur_folder = os.path.join(root_folder, directory)
if not os.path.isdir(cur_folder):
continue
md_files = glob.glob(os.path.join(cur_folder, '**', '*.md'), recursive=True)
if len(md_files) == 0:
continue
msg = f'{directory}\n--------------\n.. toctree::\n :maxdepth: 4\n\n'
for md_file in md_files:
md_file_name = os.path.relpath(md_file, root_folder).replace('\\', '/')
msg += f' {md_file_name}\n'
if 'Day' in directory:
main_msg += msg + '\n\n'
else:
other_msg += msg + '\n\n'
final_msg = '\n\nPython-100-Days\n===============\n\n' + main_msg
final_msg += '\n\nOthers\n===============\n\n' + other_msg
# 将 final_msg 保存到 index.rst 文件
output_file = os.path.join(root_folder, 'modules.rst')
with open(output_file, 'w', encoding='utf-8') as f:
f.write(final_msg)
if __name__ == '__main__':
main()
print('done')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Heconnor/Python-100-Days.git
git@gitee.com:Heconnor/Python-100-Days.git
Heconnor
Python-100-Days
Python-100-Days
master

搜索帮助