File: make-library-index

package info (click to toggle)
rocq-stdlib 9.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 11,828 kB
  • sloc: python: 2,928; sh: 444; makefile: 319; javascript: 24; ml: 2
file content (52 lines) | stat: -rwxr-xr-x 1,422 bytes parent folder | download
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
#!/usr/bin/env bash

# Instantiate links to library files in index template

set -e

FILE=$1
HIDDEN=$2
tmp=$(mktemp)
tmp2=$(mktemp)

sed -e '/#include depends.svg/r doc/stdlib/depends.svg' "$FILE.template" > "$tmp"
echo -n "Building file index-list.prehtml... "

LIBDIRS=$(find theories/* -type d ! -name .coq-native)

for k in $LIBDIRS; do
    BASE_PREFIX="Stdlib."
    d=$(basename "$k")
    for j in "$k"/*.v; do
        if ! [ -e "$j" ]; then break; fi
        b=$(basename "$j" .v)

        a=0; grep -q "$k/$b.v" "$tmp" || a=$?
        h=0; grep -q "$k/$b.v" "$HIDDEN" || h=$?
        if [ $a = 0 ]; then
            if [ $h = 0 ]; then
                echo "Error: $FILE and $HIDDEN both mention $k/$b.v" >&2
                exit 1
            else
                p=$(echo "$k" | sed 's:^[^/]*/::' | sed 's:/:.:g')
                sed -e "s:$k/$b.v:<a href=\"$BASE_PREFIX$p.$b.html\">$b</a>:g" "$tmp" > "$tmp2"
                mv -f "$tmp2" "$tmp"
            fi
        else
            if [ $h = 0 ]; then
                # Skipping file from the index
                :
            else
                echo "Error: none of $FILE and $HIDDEN mention $k/$b.v" >&2
                exit 1
            fi

        fi
    done
    sed -e "s/#$d#//" "$tmp" > "$tmp2"
    mv -f "$tmp2" "$tmp"
done

if a=$(grep theories "$tmp"); then echo Error: extra files: >&2; echo "$a" >&2; exit 1; fi
mv "$tmp" "$FILE"
echo Done