Skip to content

Commit 87e3d99

Browse files
committed
try reveal components
Signed-off-by: zhen0427 <Zhen.Wang@alliander.com>
1 parent 567eb13 commit 87e3d99

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

scripts/build-docs.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,35 @@
44

55
import sys
66
from pathlib import Path
7+
import re
78

89
BASE_DIR = Path("docs/user_manual")
910
OUTPUT_FILE = BASE_DIR / "components.md"
1011

11-
files = sorted(BASE_DIR.glob("*components*.md"))
12+
def extract_index(path: Path):
13+
# 从 001-components.md 提取 001
14+
match = re.match(r"(\d+)", path.name)
15+
return int(match.group(1)) if match else 9999
16+
17+
files = sorted(
18+
BASE_DIR.glob("*components*.md"),
19+
key=extract_index
20+
)
1221

1322
if not files:
1423
print("No component files found.")
1524
sys.exit(0)
1625

1726
output = []
18-
1927
output.append("<!-- AUTO-GENERATED FILE - DO NOT EDIT -->\n")
2028

2129
for f in files:
22-
content = f.read_text(encoding="utf-8")
30+
content = f.read_text(encoding="utf-8").strip()
2331

32+
# 保留结构连续性,但加清晰分隔
2433
output.append(f"\n\n<!-- ===== {f.name} ===== -->\n")
25-
output.append(content.strip())
34+
output.append(content)
2635

2736
OUTPUT_FILE.write_text("\n".join(output), encoding="utf-8")
2837

29-
print(f"Built: {OUTPUT_FILE}")
38+
print(f"Built: {OUTPUT_FILE}")

0 commit comments

Comments
 (0)