summaryrefslogtreecommitdiff
path: root/libraries/gen_contents_index
blob: 1efd5eb157098a193b45f6d03d30c28dc8213aec (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh

set -e

USAGE="Usage: $0 [--intree] [--verbose] [--help]"
INTREE=
VERBOSE=

HADDOCK_ARGS=

while [ "$#" -ne "0" ]
do
    case "$1" in
    --intree)
        # We're in a GHC build tree
        INTREE=yes
        ;;
    --verbose)
        VERBOSE=yes
        ;;
    --help)
        echo "$USAGE"
        exit 0
        ;;
    esac

    shift
done

if [ -n "$INTREE" ]
then
    [ -d dist-haddock ] || mkdir dist-haddock
    cd dist-haddock

    if [ -e ../../inplace/bin/haddock ]
    then
      # Make #17527
      HADDOCK=../../inplace/bin/haddock
    elif [ -e ../../../../../bin/haddock ]
    then
      # Hadrian
      HADDOCK=../../../../../bin/haddock
    else
      echo "Haddock not found"
      exit 1
    fi
    # Exclude Cabal package-tests, which may run haddock
    HADDOCK_FILES=`find ../ -name *.haddock | grep -v 'PackageTests' | sort`
    HADDOCK_ARGS="-p ../prologue.txt"
    for HADDOCK_FILE in $HADDOCK_FILES
    do
                LIBPATH=`echo "$HADDOCK_FILE" | sed 's#/dist-install.*##'`
                NAME=`echo "$HADDOCK_FILE" | sed 's#.*/##' | sed 's#\.haddock$##'`
                # It's easier to portably remove tabs with tr than to try to get
                # sed to do what we want
                VERSION=`grep -i '^version:' $LIBPATH/$NAME.cabal | sed 's/.*://' | tr -d ' \t'`
                HADDOCK_ARG="--read-interface=${NAME}-${VERSION},$HADDOCK_FILE"
                HADDOCK_ARGS="$HADDOCK_ARGS $HADDOCK_ARG"
    done
else
    HADDOCK=../../../../../bin/haddock
    # We don't want the GHC API to swamp the index
    HADDOCK_FILES=`ls -1 */*.haddock | grep -v '/ghc\.haddock' | sort`
    HADDOCK_ARGS="-p prologue.txt"
    for HADDOCK_FILE in $HADDOCK_FILES
    do
        NAME_VERSION=`echo "$HADDOCK_FILE" | sed 's#/.*##'`
        HADDOCK_ARG="--read-interface=${NAME_VERSION},$HADDOCK_FILE"
        HADDOCK_ARGS="$HADDOCK_ARGS $HADDOCK_ARG"
    done
fi

# Now create the combined contents and index pages
if [ -n "$VERBOSE" ]
then
    echo $HADDOCK --gen-index --gen-contents -o . \
             -t "Haskell Hierarchical Libraries" \
             $HADDOCK_ARGS
fi
$HADDOCK --gen-index --gen-contents -o . \
         -t "Haskell Hierarchical Libraries" \
         $HADDOCK_ARGS

# Unhandled Windows help stuff?:

#libraries.HxS : libraries.txt
#	 haddock ...
#		-k libraries
#		--html-help=mshelp2
#	( cd $(HTML_DIR) && if Hxcomp -p libraries.HxC -o ../$@ ; then false ; else true ; fi ) || true
#
#libraries.chm : libraries.txt
#	haddock ...
#		-k libraries \
#		--html-help=mshelp \
#	( cd $(HTML_DIR) && if hhc libraries.hhp ; then false ; else true ; fi && mv libraries.chm .. ) || true