|
15 | 15 | import shutil |
16 | 16 | import sys |
17 | 17 |
|
| 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}") |
| 32 | + |
| 33 | +build_version = os.environ.get('CURRENT_VERSION', 'v3') |
| 34 | +if build_version == 'v2': |
| 35 | + shutil.copytree( |
| 36 | + os.path.join(os.path.dirname(__file__), '../docs_version2'), |
| 37 | + os.path.join(os.path.dirname(__file__), ), |
| 38 | + dirs_exist_ok=True |
| 39 | + ) |
| 40 | +else: |
| 41 | + shutil.copytree( |
| 42 | + os.path.join(os.path.dirname(__file__), '../docs_version3'), |
| 43 | + os.path.join(os.path.dirname(__file__), ), |
| 44 | + dirs_exist_ok=True |
| 45 | + ) |
| 46 | + |
18 | 47 | sys.path.insert(0, os.path.abspath('./')) |
19 | 48 | sys.path.insert(0, os.path.abspath('../')) |
20 | | -sys.path.insert(0, r'D:\codes\projects\brainstate') |
21 | 49 |
|
22 | 50 | import brainpy |
| 51 | + |
23 | 52 | shutil.copytree('../images/', './_static/logos/', dirs_exist_ok=True) |
24 | 53 | shutil.copyfile('../changelog.md', './changelog.md') |
25 | | -shutil.rmtree('./generated', ignore_errors=True) |
26 | | -shutil.rmtree('./_build', ignore_errors=True) |
27 | | - |
28 | 54 |
|
29 | 55 | # -- Project information ----------------------------------------------------- |
30 | 56 |
|
|
88 | 114 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] |
89 | 115 |
|
90 | 116 | # href with no underline and white bold text color |
91 | | -announcement = """ |
92 | | -<a href="https://brainpy-v2.readthedocs.io" style="text-decoration: none; color: white;"> |
93 | | - This site covers the new BrainPy 3.0 API. |
94 | | - <span style="color: lightgray;">[Click here for the classical <b>BrainPy 2.0</b> API]</span> |
95 | | -</a> |
96 | | -""" |
| 117 | + |
| 118 | +if build_version == 'v2': |
| 119 | + announcement = """ |
| 120 | + <a href="https://brainpy.readthedocs.io" style="text-decoration: none; color: white;"> |
| 121 | + This site covers the old BrainPy 2.0 API. <span style="color: lightgray;">[Explore the new <b>BrainPy 3.0</b> API ✨]</span> |
| 122 | + </a> |
| 123 | + """ |
| 124 | +else: |
| 125 | + announcement = """ |
| 126 | + <a href="https://brainpy-v2.readthedocs.io" style="text-decoration: none; color: white;"> |
| 127 | + This site covers the new BrainPy 3.0 API. |
| 128 | + <span style="color: lightgray;">[Click here for the classical <b>BrainPy 2.0</b> API]</span> |
| 129 | + </a> |
| 130 | + """ |
97 | 131 |
|
98 | 132 | html_theme_options = { |
99 | 133 | 'repository_url': 'https://github.com/brainpy/BrainPy', |
|
0 commit comments