Skip to content

Commit 2659cdf

Browse files
chaoming0625oujago
andauthored
documentation fix (#786)
* fix(docs): update documentation build script to reflect current versioning logic * fix(docs): update version check in documentation build script to include stable versions * fix(docs): enhance version check in documentation build script to include 'latest' version * fix * fix * fix * fix * fix(docs): update documentation build process for version 3 * fix(conf): enhance cleanup process by adding file retention and error handling * fix(conf): update links and cleanup process in configuration --------- Co-authored-by: oujago <[email protected]>
1 parent e88cfb4 commit 2659cdf

19 files changed

+48
-232
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,6 @@ cython_debug/
233233
/docs/_static/logos/
234234
/docs/_build/
235235
/docs/changelog.md
236+
/docs_version3/_build/
237+
/docs_version3/_static/logos/
238+
/docs_version3/changelog.md

.readthedocs.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,10 @@ build:
99
os: "ubuntu-24.04"
1010
tools:
1111
python: "3.13"
12-
jobs:
13-
post_checkout:
14-
# Copy the appropriate conf.py based on project name
15-
- |
16-
if [ "$DOC_BUILD_VERSION" = "v2" ]; then
17-
echo "DOC_BUILD_VERSION is: $DOC_BUILD_VERSION"
18-
echo "Building brainpy-version2 documentation"
19-
mkdir -p docs_build
20-
cp -r docs_version2/* docs_build/
21-
else
22-
echo "DOC_BUILD_VERSION is: $DOC_BUILD_VERSION"
23-
echo "Building standard brainpy documentation"
24-
mkdir -p docs_build
25-
cp -r docs/* docs_build/
26-
fi
2712

2813
# Build documentation using the copied conf.py
2914
sphinx:
30-
configuration: docs_build/conf.py
15+
configuration: docs/conf.py
3116

3217
# Optionally set the version of Python and requirements required to build your docs
3318
python:

docs/conf.py

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,42 @@
1515
import shutil
1616
import sys
1717

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+
1847
sys.path.insert(0, os.path.abspath('./'))
1948
sys.path.insert(0, os.path.abspath('../'))
20-
sys.path.insert(0, r'D:\codes\projects\brainstate')
2149

2250
import brainpy
51+
2352
shutil.copytree('../images/', './_static/logos/', dirs_exist_ok=True)
2453
shutil.copyfile('../changelog.md', './changelog.md')
25-
shutil.rmtree('./generated', ignore_errors=True)
26-
shutil.rmtree('./_build', ignore_errors=True)
27-
2854

2955
# -- Project information -----------------------------------------------------
3056

@@ -88,12 +114,20 @@
88114
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
89115

90116
# 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+
"""
97131

98132
html_theme_options = {
99133
'repository_url': 'https://github.com/brainpy/BrainPy',

docs_version2/Makefile

Lines changed: 0 additions & 21 deletions
This file was deleted.

docs_version2/conf.py

Lines changed: 0 additions & 150 deletions
This file was deleted.

docs_version2/make.bat

Lines changed: 0 additions & 35 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)