3 # Build html versions of sections of lilypond documentation
5 # Usage: ./doc-section.sh MANUAL SECTION
7 # where MANUAL is the manual and SECTION is the section to be
10 # For example, NR 1.2 would be built by
11 # ./doc-section.sh notation rhythms
13 # and LM 1 would be built by
14 # ./doc-section.sh learning tutorial
16 # At the end of the run, the user is prompted whether or not to
17 # remove the generated files.
19 # According to http://code.google.com/p/lilypond/issues/detail?id=1236
20 # the location of the lilypond git tree is taken from $LILYPOND_GIT
21 # if specified, otherwise it is auto-detected.
23 # It is assumed that compilation takes place in the build/
24 # subdirectory, but this can be overridden by setting the environment
25 # variable LILYPOND_BUILD_DIR.
27 # Similarly, output defaults to build/tempdocs/ but this can be
28 # overridden by setting the environment variable LILYPOND_TEMPDOCS.
33 # * Doesn't use website css files
34 # * Bitmap images aren't loaded properly
35 # * Won't build Contributors' Guide; see scripts/auxiliar/cg-section.sh
41 Usage: $0 MANUAL SECTION
42 e.g. $0 notation rhythms
48 if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
54 if [ -n "$LILYPOND_GIT" ]; then
55 echo "Using source tree from value of \$LILYPOND_GIT: $LILYPOND_GIT"
60 echo "\$LILYPOND_GIT was not set; auto-detected source tree at $LILYPOND_GIT"
63 if [ -n "$BROWSER" ]; then
64 echo "Using browser from \$BROWSER: $BROWSER"
66 echo "\$BROWSER not set; using firefox as default"
70 if test ! -e "$LILYPOND_GIT/DEDICATION"; then
71 echo "Error: $LILYPOND_GIT did not look like a LilyPond source tree; aborting." >&2
75 : "${LILYPOND_BUILD_DIR:=$LILYPOND_GIT/build}"
76 DOC_DIR="${LILYPOND_TEMPDOCS:-$LILYPOND_BUILD_DIR/tempdocs}"
77 LILYPOND_BOOK="$LILYPOND_BUILD_DIR/out/bin/lilypond-book"
79 REFCHECK="$LILYPOND_GIT/scripts/auxiliar/ref_check.py"
83 OUTPUT_DIR="$DOC_DIR/$SECTION"
84 MANUAL_PATH="$LILYPOND_GIT/Documentation/$MANUAL"
85 SECTION_PATH="$MANUAL_PATH/$SECTION.itely"
87 if test ! -d "$LILYPOND_BUILD_DIR"; then
88 echo "$LILYPOND_BUILD_DIR did not exist; check your setting of LILYPOND_BUILD_DIR. Aborting." >&2
92 if test ! -d "$MANUAL_PATH"; then
93 echo "$MANUAL_PATH was not a valid directory; is $MANUAL a valid manual?" >&2
97 if test ! -e "$SECTION_PATH"; then
98 echo "$SECTION_PATH did not exist; is $SECTION a valid section in the $MANUAL manual?" >&2
102 if test ! -d "$DOC_DIR"; then
104 cp "$LILYPOND_BUILD_DIR/Documentation/out/version.itexi" "$DOC_DIR"
106 if test ! -d "$OUTPUT_DIR"; then
109 if test ! -d "$OUTPUT_DIR/out"; then
110 mkdir "$OUTPUT_DIR/out"
113 cp "$LILYPOND_GIT/Documentation/common-macros.itexi" "$OUTPUT_DIR/common-macros.itexi"
114 cp "$LILYPOND_GIT/Documentation/macros.itexi" "$DOC_DIR/macros.itexi"
115 cp "$DOC_DIR/version.itexi" "$OUTPUT_DIR/version.itexi"
116 cp -r "$LILYPOND_GIT/Documentation/pictures/" "$OUTPUT_DIR/out/pictures"
118 if test -e "$OUTPUT_DIR/$SECTION.html"; then
119 rm "$OUTPUT_DIR/$SECTION.html"
122 if test -e "$OUTPUT_DIR/out/$SECTION.texi"; then
123 rm "$OUTPUT_DIR/out/$SECTION.texi"
126 echo "Running $LILYPOND_BOOK"
129 -I "$LILYPOND_GIT/Documentation/snippets" \
130 -I "$LILYPOND_GIT/Documentation/snippets/new" \
131 -I "$LILYPOND_GIT/input/manual" \
132 -I "$LILYPOND_GIT/Documentation" \
133 -I "$LILYPOND_GIT/Documentation/included" \
134 -I "$LILYPOND_GIT/Documentation/pictures" \
135 -o "$OUTPUT_DIR/out" \
138 if [ "$BOOKRC" != 0 ]; then
139 echo "Lilypond-book returned code $BOOKRC"
143 echo "Running RefCheck"
147 if test -f "$OUTPUT_DIR/out/$SECTION.texi"; then
148 echo "Running $TEXI2HTML"
149 cat "$DOC_DIR/macros.itexi" "$OUTPUT_DIR/out/$SECTION.texi" > "$OUTPUT_DIR/$SECTION.texi"
152 --output="$OUTPUT_DIR/out/$SECTION.html" \
153 --I="$OUTPUT_DIR/out" \
154 "$OUTPUT_DIR/$SECTION.texi"
157 echo "Displaying output in $BROWSER; close browser window when done."
159 $BROWSER $OUTPUT_DIR/out/$SECTION.html
163 If you want to avoid recompiling the snippets on the next
164 invocation with '$MANUAL $SECTION', answer 'n' to the next question.
168 echo "Delete temp files? [y/n]"
170 if [ "$REPLY" = "y" ]; then
171 echo "deleting files"