File: make-module-lists

package info (click to toggle)
gwyddion 2.67-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 54,152 kB
  • sloc: ansic: 412,023; python: 7,885; sh: 5,492; makefile: 4,957; xml: 3,954; cpp: 2,107; pascal: 418; perl: 154; ruby: 130
file content (68 lines) | stat: -rwxr-xr-x 2,123 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
guidemap=user-guide-modules
enguidedir=../../user-guide/en/xhtml

process_one_lang() {
    ../dump-modules $guidemap.tmp $2 >modules.$1.xml
    xsltproc --stringparam lang $1 -o module-list.$1.html ../modules-web.xsl modules.$1.xml
    xsltproc --stringparam lang $1 -o module-list-nocss.$1.html ../modules-web-nocss.xsl modules.$1.xml
}

enguidedir=$(realpath "$enguidedir")
if test "x$1" == x--list; then
    if test -f "$enguidedir/index.html"; then
        for file in "$enguidedir/"*.html; do
            echo "$file" | sed 's:^.*/::; s/\.html$//'
            grep -E -o "\\<id=([\"'])[a-zA-Z0-9_-]+\\1" "$file" \
                | sed 's/^id=.//; s/.$//' \
                | grep -E -v '^(idm[0-9]|ientry-idm[0-9]|eq-|fig-|table-|gpl-|gfdl-)' \
                | fmt -w 76 \
                | sed 's/^/    /'
        done
        exit 0
    else
        echo "Cannot list links, no guide found in $enguidedir" 1>&2
        exit 1
    fi
fi

if test -f "$enguidedir/index.html"; then
    while read -a xref; do
        module="${xref[0]}"
        if test "$module" = '#'; then
            continue
        fi
        file="$enguidedir/${xref[1]}.html"
        if test -f "$file"; then
            fragment="${xref[2]}"
            if test -n "$fragment"; then
                if grep -E -q -s "\\<id=([\"'])$fragment\\1" "$file"; then
                    : # OK
                else
                    echo "Broken link for $module, fragment $fragment not present in file $file"
                fi
            fi
        else
            echo "Broken link for $module, no such file $file" 1>&2
        fi
    done <$guidemap
else
    echo "Cannot verify links, no guide found in $enguidedir" 1>&2
fi

rm -rf module-lists
mkdir module-lists

pushd module-lists >/dev/null
sed -e '/^#/d' \
    -e '/::/d' \
    -e 's/^\([^\t]\+\)\t\([^\t]\+\)$/\1 \2.html/' \
    -e 's/^\([^\t]\+\)\t\([^\t]\+\)\t\([^\t]\+\)$/\1 \2.html#\3/' \
    ../$guidemap >$guidemap.tmp

process_one_lang en en_US.UTF-8
process_one_lang fr fr_FR.UTF-8
process_one_lang ru ru_RU.UTF-8

rm -rf module-lists/$guidemap.tmp
popd >/dev/null