-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
140 lines (118 loc) · 4.68 KB
/
Makefile
File metadata and controls
140 lines (118 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Makefile for mdbook documentation management
.PHONY: help build serve install clean summary summary-simple validate build-zh build-en build-all serve-zh serve-en sync sync-dry-run copy-theme copy-theme-zh copy-theme-en
MDBOOK_VERSION := 0.5.2
THEME_ASSET_VERSION := v20260507-1
# Default target
help:
@echo "Available targets:"
@echo " build - Build all language versions"
@echo " build-zh - Build Chinese version only"
@echo " build-en - Build English version only"
@echo " build-all - Build all language versions (same as build)"
@echo " serve - Serve Chinese version (http://localhost:3000)"
@echo " serve-zh - Serve Chinese version (http://localhost:3000)"
@echo " serve-en - Serve English version (http://localhost:3001)"
@echo " install - Install required tools"
@echo " summary - Generate structured SUMMARY.md"
@echo " summary-simple- Generate simple SUMMARY.md"
@echo " validate - Validate markdown links and formatting"
@echo " sync - Sync docs from configured upstream sources"
@echo " sync-dry-run - Preview sync changes without writing files"
@echo " clean - Clean build artifacts"
# Install required tools
install:
@echo "Installing mdbook..."
@if ! command -v mdbook &> /dev/null; then \
curl -L https://github.com/rust-lang/mdBook/releases/download/v$(MDBOOK_VERSION)/mdbook-v$(MDBOOK_VERSION)-x86_64-apple-darwin.tar.gz | tar xz -C /usr/local/bin; \
fi
@echo "Installing mdbook-auto-summary..."
@if ! command -v mdbook-auto-summary &> /dev/null; then \
cargo install mdbook-auto-summary; \
fi
@echo "Installing markdown-link-check..."
@if ! command -v markdown-link-check &> /dev/null; then \
npm install -g markdown-link-check; \
fi
# Build all language versions
build: copy-theme build-zh build-en copy-assets
@echo "All documentation built successfully!"
# Build Chinese version
build-zh: copy-theme-zh
@echo "Building Chinese documentation..."
cd docs-zh && mdbook build
copy-theme: copy-theme-zh copy-theme-en
copy-theme-zh:
@mkdir -p docs-zh/theme
@cp theme/*.css docs-zh/theme/
@cp theme/*.js docs-zh/theme/
@rm -f docs-zh/theme/*.hbs
@cp theme/*.hbs docs-zh/theme/
@rm -f docs-zh/theme/site.$(THEME_ASSET_VERSION).css docs-zh/theme/site.$(THEME_ASSET_VERSION).js
@ln -s site.css docs-zh/theme/site.$(THEME_ASSET_VERSION).css
@ln -s site.js docs-zh/theme/site.$(THEME_ASSET_VERSION).js
# Build English version
build-en: copy-theme-en
@echo "Building English documentation..."
cd docs-en && mdbook build
copy-theme-en:
@mkdir -p docs-en/theme
@cp theme/*.css docs-en/theme/
@cp theme/*.js docs-en/theme/
@rm -f docs-en/theme/*.hbs
@cp theme/*.hbs docs-en/theme/
@rm -f docs-en/theme/site.$(THEME_ASSET_VERSION).css docs-en/theme/site.$(THEME_ASSET_VERSION).js
@ln -s site.css docs-en/theme/site.$(THEME_ASSET_VERSION).css
@ln -s site.js docs-en/theme/site.$(THEME_ASSET_VERSION).js
# Copy index.html and assets
copy-assets:
@echo "Copying language selection page..."
@mkdir -p book
@cp index.html book/
# Serve documentation locally (Chinese, default port 3000)
serve: copy-theme serve-zh
# Serve Chinese version
serve-zh: copy-theme-zh
@echo "Starting Chinese documentation server on http://localhost:3000..."
cd docs-zh && mdbook serve --hostname 0.0.0.0 --port 3000
# Serve English version
serve-en: copy-theme-en
@echo "Starting English documentation server on http://localhost:3001..."
cd docs-en && mdbook serve --hostname 0.0.0.0 --port 3001
# Generate structured SUMMARY.md
summary:
@echo "Generating structured SUMMARY.md..."
python3 generate_summary.py
# Generate simple SUMMARY.md
summary-simple:
@echo "Generating simple SUMMARY.md..."
python3 generate_summary.py
# Validate markdown links and formatting
validate:
@echo "Validating markdown links..."
@if command -v markdown-link-check &> /dev/null; then \
markdown-link-check **/*.md; \
else \
echo "markdown-link-check not found. Install with: npm install -g markdown-link-check"; \
fi
# Sync docs from configured upstream sources
sync:
@echo "Syncing docs from docs-sources.json..."
@python3 scripts/sync_docs.py --prefer-local --generate-summary
sync-dry-run:
@echo "Previewing docs sync from docs-sources.json..."
@python3 scripts/sync_docs.py --prefer-local --dry-run
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
rm -rf book/
rm -f SUMMARY.md.bak
# Full rebuild workflow
rebuild: clean summary build
@echo "Documentation rebuilt successfully!"
# Watch for changes and auto-rebuild (requires inotify-tools)
watch:
@echo "Watching for changes (requires inotify-tools)..."
@while inotifywait -e modify -r **/*.md; do \
echo "Changes detected, rebuilding..."; \
make build; \
done