Skip to content

Commit c7b37b5

Browse files
committed
fix(conf): enhance cleanup process by adding file retention and error handling
1 parent c20f7af commit c7b37b5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

docs/conf.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,20 @@
1515
import shutil
1616
import sys
1717

18-
18+
# 要保留的文件/文件夹列表
19+
keep_files = {'highlight_test_lexer.py', 'conf.py', 'make.bat', 'Makefile'}
20+
21+
# 遍历当前目录
22+
for item in os.listdir('.'):
23+
if item not in keep_files:
24+
path = os.path.join('.', item)
25+
try:
26+
if os.path.isfile(path):
27+
os.remove(path)
28+
elif os.path.isdir(path):
29+
shutil.rmtree(path)
30+
except Exception as e:
31+
print(f"Error deleting {item}: {e}")
1932

2033
build_version = os.environ.get('CURRENT_VERSION', 'v3')
2134
if build_version == 'v2':
@@ -28,6 +41,7 @@
2841
shutil.copytree(
2942
os.path.join(os.path.dirname(__file__), '../docs_version3'),
3043
os.path.join(os.path.dirname(__file__), ),
44+
dirs_exist_ok=True
3145
)
3246

3347
sys.path.insert(0, os.path.abspath('./'))
@@ -47,6 +61,7 @@
4761
author = 'BrainPy Team'
4862

4963
from highlight_test_lexer import fix_ipython2_lexer_in_notebooks
64+
5065
fix_ipython2_lexer_in_notebooks(os.path.dirname(os.path.abspath(__file__)))
5166

5267
# The full version, including alpha/beta/rc tags

0 commit comments

Comments
 (0)