mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 02:16:53 +08:00
tools: metadata modules check with diff
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# metadata_modules.sh — generate and sync PX4 module reference documentation
|
# metadata_modules.sh - generate and sync PX4 module reference documentation
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# Tools/ci/metadata_modules.sh [--test-only] [--debug]
|
# Tools/ci/metadata_modules.sh [--test-only] [--debug]
|
||||||
@@ -44,11 +44,15 @@ if [ ${#src_files[@]} -eq 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ─── Strip trailing whitespace from all generated module docs ─────────────────────────────
|
# ─── Strip trailing whitespace from all generated module docs (unless test-only) ─────────────
|
||||||
echo "✂️ Removing trailing whitespace from generated module docs"
|
if [ "$test_only" = false ]; then
|
||||||
for src in "${src_files[@]}"; do
|
echo "✂️ Removing trailing whitespace from generated module docs"
|
||||||
sed -i 's/[[:space:]]\+$//' "$src"
|
for src in "${src_files[@]}"; do
|
||||||
done
|
sed -i 's/[[:space:]]\+$//' "$src"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
[ "$debug" = true ] && echo "🧪 Test-only mode: skipping whitespace removal"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "🔍 Checking module reference docs in $dest_dir"
|
echo "🔍 Checking module reference docs in $dest_dir"
|
||||||
mkdir -p "$dest_dir"
|
mkdir -p "$dest_dir"
|
||||||
@@ -61,9 +65,12 @@ for src in "${src_files[@]}"; do
|
|||||||
if [[ ! -e "$dst" ]]; then
|
if [[ ! -e "$dst" ]]; then
|
||||||
[ "$debug" = true ] && echo "DEBUG: missing $dst"
|
[ "$debug" = true ] && echo "DEBUG: missing $dst"
|
||||||
changed+=("$name")
|
changed+=("$name")
|
||||||
elif ! cmp -s "$src" "$dst"; then
|
else
|
||||||
[ "$debug" = true ] && echo "DEBUG: cmp -s '$src' '$dst'; echo \$?"
|
# Use diff -q -b (ignore whitespace changes) and --strip-trailing-cr (ignore CRLF vs LF)
|
||||||
changed+=("$name")
|
if ! diff -q -b --strip-trailing-cr "$src" "$dst" > /dev/null; then
|
||||||
|
[ "$debug" = true ] && echo "DEBUG: diff -q -b --strip-trailing-cr '$src' '$dst' (exit_code=$?)"
|
||||||
|
changed+=("$name")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -81,7 +88,9 @@ if [ "$test_only" = true ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "📂 Copying updated module docs to $dest_dir"
|
echo "📂 Copying updated module docs to $dest_dir"
|
||||||
for f in "${changed[@]}"; do cp -rv "$src_dir/$f" "$dest_dir/$f"; done
|
for f in "${changed[@]}"; do
|
||||||
|
cp -rv "$src_dir/$f" "$dest_dir/$f"
|
||||||
|
done
|
||||||
|
|
||||||
echo "🚨 Module reference docs updated; please commit changes:"
|
echo "🚨 Module reference docs updated; please commit changes:"
|
||||||
echo " git status -s $dest_dir"
|
echo " git status -s $dest_dir"
|
||||||
|
|||||||
Reference in New Issue
Block a user