Skip to content

Commit 27c8e8e

Browse files
committed
Make ToC regeneration script path handling more robust
1 parent 5e0cfac commit 27c8e8e

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

docs/build_toc.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fi
6262
temp_dir=$(mktemp -d)
6363
trap 'rm -rf "$temp_dir"' EXIT
6464

65-
cd "$project_root/docs" || exit 1
65+
docs_dir="$project_root/docs"
6666

6767
cat >"$temp_dir/temp_program.cs" <<EOL
6868
$(cat "$script_dir/scripts/Program.cs")
@@ -100,24 +100,24 @@ if ! mcs -r:System.Core "$temp_dir/temp_program.cs" -out:"$temp_dir/toc-builder.
100100
fi
101101

102102
for dir in "user-guide" "gfx-user-guide"; do
103-
if [ -d "$script_dir/$dir" ]; then
103+
if [ -d "$docs_dir/$dir" ]; then
104104
if [ "$check_only" -eq 1 ]; then
105105
# Ensure working directory is clean
106-
if ! git diff --quiet "$script_dir/$dir/toc.html" 2>/dev/null; then
106+
if ! git -C "$project_root" diff --quiet "docs/$dir/toc.html" 2>/dev/null; then
107107
echo "Working directory not clean, cannot check TOC" >&2
108108
exit 1
109109
fi
110110
fi
111111

112-
if ! mono "$temp_dir/toc-builder.exe" "$script_dir/$dir"; then
112+
if ! mono "$temp_dir/toc-builder.exe" "$docs_dir/$dir"; then
113113
echo "TOC generation failed for $dir" >&2
114114
exit 1
115115
fi
116116

117117
if [ "$check_only" -eq 1 ]; then
118-
if ! git diff --quiet "$script_dir/$dir/toc.html" 2>/dev/null; then
119-
git diff --color "$script_dir/$dir/toc.html"
120-
git checkout -- "$script_dir/$dir/toc.html" 2>/dev/null
118+
if ! git -C "$project_root" diff --quiet "docs/$dir/toc.html" 2>/dev/null; then
119+
git -C "$project_root" diff --color "docs/$dir/toc.html"
120+
git -C "$project_root" checkout -- "docs/$dir/toc.html" 2>/dev/null
121121
exit 1
122122
fi
123123
fi

docs/user-guide/11-test-section.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: user-guide
3+
permalink: /user-guide/test-section
4+
---
5+
6+
# Test Section
7+
8+
A new section to test the toc generation bot

0 commit comments

Comments
 (0)