File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55import sys
66from pathlib import Path
7+ import re
78
89BASE_DIR = Path ("docs/user_manual" )
910OUTPUT_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
1322if not files :
1423 print ("No component files found." )
1524 sys .exit (0 )
1625
1726output = []
18-
1927output .append ("<!-- AUTO-GENERATED FILE - DO NOT EDIT -->\n " )
2028
2129for 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
2736OUTPUT_FILE .write_text ("\n " .join (output ), encoding = "utf-8" )
2837
29- print (f"Built: { OUTPUT_FILE } " )
38+ print (f"Built: { OUTPUT_FILE } " )
You can’t perform that action at this time.
0 commit comments