| 1 |
#!/bin/bash |
| 2 |
guidemap=user-guide-modules |
| 3 |
enguidedir=../../user-guide/en/xhtml |
| 4 |
|
| 5 |
process_one_lang() { |
| 6 |
../dump-modules $guidemap.tmp $2 >modules.$1.xml |
| 7 |
xsltproc --stringparam lang $1 -o module-list.$1.html ../modules-web.xsl modules.$1.xml |
| 8 |
xsltproc --stringparam lang $1 -o module-list-nocss.$1.html ../modules-web-nocss.xsl modules.$1.xml |
| 9 |
} |
| 10 |
|
| 11 |
enguidedir=$(realpath "$enguidedir") |
| 12 |
if test "x$1" == x--list; then |
| 13 |
if test -f "$enguidedir/index.html"; then |
| 14 |
for file in "$enguidedir/"*.html; do |
| 15 |
echo "$file" | sed 's:^.*/::; s/\.html$//' |
| 16 |
grep -E -o "\\<id=([\"'])[a-zA-Z0-9_-]+\\1" "$file" \ |
| 17 |
| sed 's/^id=.//; s/.$//' \ |
| 18 |
| grep -E -v '^(idm[0-9]|ientry-idm[0-9]|eq-|fig-|table-|gpl-|gfdl-)' \ |
| 19 |
| fmt -w 76 \ |
| 20 |
| sed 's/^/ /' |
| 21 |
done |
| 22 |
exit 0 |
| 23 |
else |
| 24 |
echo "Cannot list links, no guide found in $enguidedir" 1>&2 |
| 25 |
exit 1 |
| 26 |
fi |
| 27 |
fi |
| 28 |
|
| 29 |
if test -f "$enguidedir/index.html"; then |
| 30 |
while read -a xref; do |
| 31 |
module="${xref[0]}" |
| 32 |
if test "$module" = '#'; then |
| 33 |
continue |
| 34 |
fi |
| 35 |
file="$enguidedir/${xref[1]}.html" |
| 36 |
if test -f "$file"; then |
| 37 |
fragment="${xref[2]}" |
| 38 |
if test -n "$fragment"; then |
| 39 |
if grep -E -q -s "\\<id=([\"'])$fragment\\1" "$file"; then |
| 40 |
: # OK |
| 41 |
else |
| 42 |
echo "Broken link for $module, fragment $fragment not present in file $file" |
| 43 |
fi |
| 44 |
fi |
| 45 |
else |
| 46 |
echo "Broken link for $module, no such file $file" 1>&2 |
| 47 |
fi |
| 48 |
done <$guidemap |
| 49 |
else |
| 50 |
echo "Cannot verify links, no guide found in $enguidedir" 1>&2 |
| 51 |
fi |
| 52 |
|
| 53 |
rm -rf module-lists |
| 54 |
mkdir module-lists |
| 55 |
|
| 56 |
pushd module-lists >/dev/null |
| 57 |
sed -e '/^#/d' \ |
| 58 |
-e '/::/d' \ |
| 59 |
-e 's/^\([^\t]\+\)\t\([^\t]\+\)$/\1 \2.html/' \ |
| 60 |
-e 's/^\([^\t]\+\)\t\([^\t]\+\)\t\([^\t]\+\)$/\1 \2.html#\3/' \ |
| 61 |
../$guidemap >$guidemap.tmp |
| 62 |
|
| 63 |
process_one_lang en en_US.UTF-8 |
| 64 |
process_one_lang fr fr_FR.UTF-8 |
| 65 |
process_one_lang ru ru_RU.UTF-8 |
| 66 |
|
| 67 |
rm -rf module-lists/$guidemap.tmp |
| 68 |
popd >/dev/null |