summaryrefslogtreecommitdiffstats
path: root/docs/build_toc.sh
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-11-29 13:31:04 +0800
committerGitHub <noreply@github.com>2024-11-29 13:31:04 +0800
commit7a5981eb554eaa97653a1a1f74b1ec9a44b82633 (patch)
tree219a73c65c72fb188efd1e91b766fad969ab8145 /docs/build_toc.sh
parent6bc63681e0b874e66fd9b8881c533eafdc6b9b78 (diff)
Make ToC regeneration script path handling more robust (#5700)
Co-authored-by: Anders Leino <aleino@nvidia.com>
Diffstat (limited to 'docs/build_toc.sh')
-rwxr-xr-xdocs/build_toc.sh14
1 files changed, 7 insertions, 7 deletions
diff --git a/docs/build_toc.sh b/docs/build_toc.sh
index 9c158d6a2..9c197cad6 100755
--- a/docs/build_toc.sh
+++ b/docs/build_toc.sh
@@ -62,7 +62,7 @@ fi
temp_dir=$(mktemp -d)
trap 'rm -rf "$temp_dir"' EXIT
-cd "$project_root/docs" || exit 1
+docs_dir="$project_root/docs"
cat >"$temp_dir/temp_program.cs" <<EOL
$(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.
fi
for dir in "user-guide" "gfx-user-guide"; do
- if [ -d "$script_dir/$dir" ]; then
+ if [ -d "$docs_dir/$dir" ]; then
if [ "$check_only" -eq 1 ]; then
# Ensure working directory is clean
- if ! git diff --quiet "$script_dir/$dir/toc.html" 2>/dev/null; then
+ if ! git -C "$project_root" diff --quiet "docs/$dir/toc.html" 2>/dev/null; then
echo "Working directory not clean, cannot check TOC" >&2
exit 1
fi
fi
- if ! mono "$temp_dir/toc-builder.exe" "$script_dir/$dir"; then
+ if ! mono "$temp_dir/toc-builder.exe" "$docs_dir/$dir"; then
echo "TOC generation failed for $dir" >&2
exit 1
fi
if [ "$check_only" -eq 1 ]; then
- if ! git diff --quiet "$script_dir/$dir/toc.html" 2>/dev/null; then
- git diff --color "$script_dir/$dir/toc.html"
- git checkout -- "$script_dir/$dir/toc.html" 2>/dev/null
+ if ! git -C "$project_root" diff --quiet "docs/$dir/toc.html" 2>/dev/null; then
+ git -C "$project_root" diff --color "docs/$dir/toc.html"
+ git -C "$project_root" checkout -- "docs/$dir/toc.html" 2>/dev/null
exit 1
fi
fi