Add docs governance and Czech parity updates
This commit is contained in:
45
scripts/check_markdown_links.sh
Executable file
45
scripts/check_markdown_links.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$repo_root"
|
||||
|
||||
missing_count=0
|
||||
|
||||
while IFS=$'\t' read -r src link; do
|
||||
case "$link" in
|
||||
''|'#'*|mailto:*|http://*|https://*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
# Remove optional anchors and query strings for filesystem checks.
|
||||
target="${link%%#*}"
|
||||
target="${target%%\?*}"
|
||||
|
||||
[[ -z "$target" ]] && continue
|
||||
|
||||
if [[ "$target" == /* ]]; then
|
||||
# Treat /path as repository-root relative for markdown in GitHub.
|
||||
path="${repo_root}${target}"
|
||||
else
|
||||
path="$(dirname "$src")/$target"
|
||||
fi
|
||||
|
||||
if [[ ! -e "$path" ]]; then
|
||||
printf 'BROKEN: %s -> %s (missing: %s)\n' "$src" "$link" "$path"
|
||||
missing_count=$((missing_count + 1))
|
||||
fi
|
||||
done < <(
|
||||
while IFS= read -r file; do
|
||||
perl -ne 'while(/\[[^\]]*\]\(([^)]+)\)/g){print "$ARGV\t$1\n"}' "$file"
|
||||
done < <(rg --files -g '*.md')
|
||||
)
|
||||
|
||||
if [[ "$missing_count" -gt 0 ]]; then
|
||||
printf '\nFound %d broken markdown link(s).\n' "$missing_count"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Markdown local links: OK"
|
||||
|
||||
116
scripts/translation_parity_report.sh
Executable file
116
scripts/translation_parity_report.sh
Executable file
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$repo_root"
|
||||
|
||||
threshold="${THRESHOLD_PERCENT:-30}"
|
||||
output_file="${1:-}"
|
||||
|
||||
if [[ -n "$output_file" ]]; then
|
||||
exec >"$output_file"
|
||||
fi
|
||||
|
||||
if [[ ! -d docs/en || ! -d docs/cs ]]; then
|
||||
echo "ERROR: expected docs/en and docs/cs directories."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmp_dir="$(mktemp -d)"
|
||||
trap 'rm -rf "$tmp_dir"' EXIT
|
||||
|
||||
(cd docs/en && rg --files -g '*.md' | sort) >"$tmp_dir/en_files.txt"
|
||||
(cd docs/cs && rg --files -g '*.md' | sort) >"$tmp_dir/cs_files.txt"
|
||||
|
||||
comm -23 "$tmp_dir/en_files.txt" "$tmp_dir/cs_files.txt" >"$tmp_dir/missing_in_cs.txt"
|
||||
comm -13 "$tmp_dir/en_files.txt" "$tmp_dir/cs_files.txt" >"$tmp_dir/extra_in_cs.txt"
|
||||
comm -12 "$tmp_dir/en_files.txt" "$tmp_dir/cs_files.txt" >"$tmp_dir/common_files.txt"
|
||||
|
||||
missing_count="$(wc -l <"$tmp_dir/missing_in_cs.txt" | tr -d ' ')"
|
||||
extra_count="$(wc -l <"$tmp_dir/extra_in_cs.txt" | tr -d ' ')"
|
||||
|
||||
# Report any TODO markers in Czech files.
|
||||
todo_count="$(
|
||||
(rg -n '\bTODO\b' docs/cs --glob '*.md' --glob '!README.md' || true) | wc -l | tr -d ' '
|
||||
)"
|
||||
|
||||
echo "# Translation Parity Report (docs/en -> docs/cs)"
|
||||
echo
|
||||
echo "## Summary"
|
||||
echo
|
||||
echo "- English files: $(wc -l <"$tmp_dir/en_files.txt" | tr -d ' ')"
|
||||
echo "- Czech files: $(wc -l <"$tmp_dir/cs_files.txt" | tr -d ' ')"
|
||||
echo "- Missing in Czech: $missing_count"
|
||||
echo "- Extra in Czech: $extra_count"
|
||||
echo "- Czech TODO markers (excluding docs/cs/README.md): $todo_count"
|
||||
echo
|
||||
|
||||
if [[ "$missing_count" -gt 0 ]]; then
|
||||
echo "## Missing Czech Files"
|
||||
echo
|
||||
while IFS= read -r rel; do
|
||||
echo "- docs/cs/$rel"
|
||||
done <"$tmp_dir/missing_in_cs.txt"
|
||||
echo
|
||||
fi
|
||||
|
||||
if [[ "$extra_count" -gt 0 ]]; then
|
||||
echo "## Extra Czech Files"
|
||||
echo
|
||||
while IFS= read -r rel; do
|
||||
echo "- docs/cs/$rel"
|
||||
done <"$tmp_dir/extra_in_cs.txt"
|
||||
echo
|
||||
fi
|
||||
|
||||
echo "## Line Count Delta (warnings at >= ${threshold}%)"
|
||||
echo
|
||||
echo "| File | EN lines | CS lines | Delta |"
|
||||
echo "| --- | ---: | ---: | ---: |"
|
||||
|
||||
warn_count=0
|
||||
while IFS= read -r rel; do
|
||||
en_lines="$(wc -l <"docs/en/$rel" | tr -d ' ')"
|
||||
cs_lines="$(wc -l <"docs/cs/$rel" | tr -d ' ')"
|
||||
|
||||
if [[ "$en_lines" -eq 0 ]]; then
|
||||
delta_percent="n/a"
|
||||
abs_percent=0
|
||||
else
|
||||
abs_percent="$(
|
||||
awk -v en="$en_lines" -v cs="$cs_lines" 'BEGIN{
|
||||
d = cs - en; if (d < 0) d = -d;
|
||||
printf "%.1f", (d / en) * 100
|
||||
}'
|
||||
)"
|
||||
delta_percent="${abs_percent}%"
|
||||
fi
|
||||
|
||||
echo "| \`$rel\` | $en_lines | $cs_lines | $delta_percent |"
|
||||
|
||||
if [[ "$en_lines" -gt 0 ]]; then
|
||||
over="$(
|
||||
awk -v p="$abs_percent" -v t="$threshold" 'BEGIN{if (p >= t) print 1; else print 0}'
|
||||
)"
|
||||
if [[ "$over" -eq 1 ]]; then
|
||||
warn_count=$((warn_count + 1))
|
||||
fi
|
||||
fi
|
||||
done <"$tmp_dir/common_files.txt"
|
||||
|
||||
echo
|
||||
echo "Large-delta warnings: $warn_count"
|
||||
|
||||
status=0
|
||||
if [[ "$missing_count" -gt 0 || "$todo_count" -gt 0 ]]; then
|
||||
status=1
|
||||
fi
|
||||
|
||||
echo
|
||||
if [[ "$status" -eq 0 ]]; then
|
||||
echo "Result: PASS"
|
||||
else
|
||||
echo "Result: FAIL (missing files and/or TODO markers found)"
|
||||
fi
|
||||
|
||||
exit "$status"
|
||||
Reference in New Issue
Block a user