Skip to content

Commit 263439b

Browse files
committed
Fix generated docs to reuse main VitePress config
1 parent ddddb1c commit 263439b

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import config from '../../../docs/.vitepress/config'
2+
3+
export default config

‎scripts/expand_py_symbols.py‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,21 @@ def _repl(match: re.Match) -> str:
3636
return BLOCK_RE.sub(_repl, md_text)
3737

3838

39-
def clean_output_dir() -> None:
40-
if not OUTPUT_DIR.exists():
41-
return
42-
for p in sorted(OUTPUT_DIR.rglob("*"), reverse=True):
43-
if p.is_file():
44-
p.unlink()
45-
elif p.is_dir():
46-
p.rmdir()
39+
def ensure_vitepress_config() -> None:
40+
"""
41+
Ensure docs_generated/.vitepress/config.ts exists and re-exports the real config.
42+
43+
这样无论是本地还是 GitHub Actions,使用 docs_generated 作为根目录构建时,
44+
都会复用 docs/.vitepress/config.ts 中的所有站点配置。
45+
"""
46+
vp_dir = OUTPUT_DIR / ".vitepress"
47+
vp_dir.mkdir(parents=True, exist_ok=True)
48+
config_path = vp_dir / "config.ts"
49+
content = "import config from '../../../docs/.vitepress/config'\n\nexport default config\n"
50+
config_path.write_text(content, encoding="utf-8")
4751

4852

4953
def main() -> None:
50-
clean_output_dir()
5154
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
5255

5356
for md_path in DOCS_DIR.rglob("*.md"):
@@ -60,6 +63,7 @@ def main() -> None:
6063
out_path.write_text(new_text, encoding="utf-8")
6164
print(f"processed {rel}")
6265

66+
ensure_vitepress_config()
6367
print(f"All markdown files expanded into {OUTPUT_DIR}")
6468

6569

0 commit comments

Comments
 (0)