]> git.donarmstrong.com Git - lilypond.git/blob - scripts/auxiliar/cg-section.sh
Add '-dcrop' option to ps and svg backends
[lilypond.git] / scripts / auxiliar / cg-section.sh
1 #!/bin/sh
2
3 #  Build html versions of sections of lilypond Contributors' Guide
4 #
5 #  Usage:  ./cg-section.sh SECTION
6 #
7 #    where SECTION is the section to be built.
8 #
9 #  For example, CG 4 would be built by
10 #       ./cg-section.sh doc-work
11 #
12 #  At the end of the run, the user is prompted whether or not to
13 #  remove the generated files.
14 #
15 #  Paths are calculated from environment variables in exactly the
16 #  same way as they are for doc-section.sh - see the documentation
17 #  for that.
18 #
19 #  Known limitations:
20 #
21 #     * Doesn't use website css files
22 #     * Bitmap images aren't loaded properly
23 #
24
25 usage () {
26     cat <<EOF >&2
27 Usage: $0 SECTION
28
29 e.g. $0 doc-work
30 EOF
31     exit "$1"
32 }
33
34 if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
35     usage 0
36 fi
37
38 [ $# = 1 ] || usage 1
39
40 if [ -n "$LILYPOND_GIT" ]; then
41     echo "Using source tree from value of \$LILYPOND_GIT: $LILYPOND_GIT"
42 else
43     cd "`dirname $0`"
44     cd ../..
45     LILYPOND_GIT="`pwd`"
46     echo "\$LILYPOND_GIT was not set; auto-detected source tree at $LILYPOND_GIT"
47 fi
48
49 if test ! -e "$LILYPOND_GIT/DEDICATION"; then
50     echo "Error: $LILYPOND_GIT did not look like a LilyPond source tree; aborting." >&2
51     exit 1
52 fi
53
54 : "${LILYPOND_BUILD_DIR:=$LILYPOND_GIT/build}"
55 DOC_DIR="${LILYPOND_TEMPDOCS:-$LILYPOND_BUILD_DIR/tempdocs}"
56 LILYPOND_BOOK="$LILYPOND_BUILD_DIR/out/bin/lilypond-book"
57 TEXI2HTML="texi2html"
58 REFCHECK="$LILYPOND_GIT/scripts/auxiliar/ref_check.py"
59
60 SECTION="$1"
61 DOCDIR="$HOME/lilypond/tempdocs"
62 OUTPUT_DIR="$DOC_DIR/contributor"
63 SECTION_PATH="$LILYPOND_GIT/Documentation/contributor/$SECTION.itexi"
64
65 if test ! -e "$SECTION_PATH"; then
66     echo "$SECTION_PATH did not exist; is $SECTION a valid section in the Contributor's Guide?" >&2
67     exit 1
68 fi
69
70 if test ! -d "$OUTPUT_DIR"; then
71     mkdir "$OUTPUT_DIR"
72 fi
73 if test ! -d "$OUTPUT_DIR/out"; then
74     mkdir "$OUTPUT_DIR/out"
75 fi
76
77 cp "$LILYPOND_GIT/Documentation/common-macros.itexi" "$OUTPUT_DIR/common-macros.itexi"
78 cp "$LILYPOND_GIT/Documentation/macros.itexi" "$DOC_DIR/macros.itexi"
79 cp "$LILYPOND_BUILD_DIR/Documentation/out/version.itexi" "$OUTPUT_DIR"
80
81 if test -e "$OUTPUT_DIR/$SECTION.html"; then
82     rm "$OUTPUT_DIR/$SECTION.html"
83 fi
84
85 if test -e "$OUTPUT_DIR/out/$SECTION.texi"; then
86     rm "$OUTPUT_DIR/out/$SECTION.texi"
87 fi
88
89 echo "Running RefCheck"
90 python "$REFCHECK"
91
92 cd "$DOC_DIR"
93 echo "Running $TEXI2HTML"
94 cat "$DOC_DIR/macros.itexi" "$SECTION_PATH" > "$OUTPUT_DIR/$SECTION.texi"
95
96 "$TEXI2HTML" \
97     --no-validate \
98     --output="$OUTPUT_DIR/out/$SECTION.html" \
99     --I="$LILYPOND_GIT/Documentation" \
100     --I="$OUTPUT_DIR/out" \
101     "$OUTPUT_DIR/$SECTION.texi"
102
103 cat <<EOF
104
105 The $SECTION section of the Contributor's Guide should now be viewable at
106
107   $OUTPUT_DIR/out/$SECTION.html
108
109 If you want to keep the generated docs around for a while, answer
110 'n' to the next question.  If you only needed them to quickly check
111 something, view them now and then answer 'y' when you're done.
112
113 EOF
114
115 read -p "rm -rf $OUTPUT_DIR ? (y/n): "
116 if [ "$REPLY" = "y" ]; then
117     echo "deleting files"
118     rm -rf "$OUTPUT_DIR"
119 fi