-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (103 loc) · 3.9 KB
/
Makefile
File metadata and controls
121 lines (103 loc) · 3.9 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
# 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
# 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/v0.4.21/mdbook-v0.4.21-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: build-zh build-en copy-assets
@echo "All documentation built successfully!"
# Build Chinese version
build-zh:
@echo "Building Chinese documentation..."
cd docs-zh && mdbook build
@mkdir -p book/zh/theme
@cp theme/lang-switch.css book/zh/theme/
@cp theme/lang-switch.js book/zh/theme/
# Build English version
build-en:
@echo "Building English documentation..."
cd docs-en && mdbook build
@mkdir -p book/en/theme
@cp theme/lang-switch.css book/en/theme/
@cp theme/lang-switch.js book/en/theme/
# 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: serve-zh
# Serve Chinese version
serve-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:
@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