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
40 Usage: $0 MANUAL SECTION
42 e.g. $0 notation rhythms
47 if [ "$1" == '-h' ] || [ "$1" == '--help' ]; then
53 if [ -n "$LILYPOND_GIT" ]; then
54 echo "Using source tree from value of \$LILYPOND_GIT: $LILYPOND_GIT"
59 echo "\$LILYPOND_GIT was not set; auto-detected source tree at $LILYPOND_GIT"
62 if test ! -e "$LILYPOND_GIT/DEDICATION"; then
63 echo "Error: $LILYPOND_GIT did not look like a LilyPond source tree; aborting." >&2
67 : "${LILYPOND_BUILD_DIR:=$LILYPOND_GIT/build}"
68 DOC_DIR="${LILYPOND_TEMPDOCS:-$LILYPOND_BUILD_DIR/tempdocs}"
69 LILYPOND_BOOK="$LILYPOND_BUILD_DIR/out/bin/lilypond-book"
71 REFCHECK="$LILYPOND_GIT/scripts/auxiliar/ref_check.py"
75 OUTPUT_DIR="$DOC_DIR/$SECTION"
76 MANUAL_PATH="$LILYPOND_GIT/Documentation/$MANUAL"
77 SECTION_PATH="$MANUAL_PATH/$SECTION.itely"
79 if test ! -d "$LILYPOND_BUILD_DIR"; then
80 echo "$LILYPOND_BUILD_DIR did not exist; check your setting of LILYPOND_BUILD_DIR. Aborting." >&2
84 if test ! -d "$MANUAL_PATH"; then
85 echo "$MANUAL_PATH was not a valid directory; is $MANUAL a valid manual?" >&2
89 if test ! -e "$SECTION_PATH"; then
90 echo "$SECTION_PATH did not exist; is $SECTION a valid section in the $MANUAL manual?" >&2
94 if test ! -d "$DOC_DIR"; then
96 cp "$LILYPOND_BUILD_DIR/Documentation/out/version.itexi" "$DOC_DIR"
98 if test ! -d "$OUTPUT_DIR"; then
101 if test ! -d "$OUTPUT_DIR/out"; then
102 mkdir "$OUTPUT_DIR/out"
105 cp "$LILYPOND_GIT/Documentation/common-macros.itexi" "$OUTPUT_DIR/common-macros.itexi"
106 cp "$LILYPOND_GIT/Documentation/macros.itexi" "$DOC_DIR/macros.itexi"
107 cp "$DOC_DIR/version.itexi" "$OUTPUT_DIR/version.itexi"
109 if test -e "$OUTPUT_DIR/$SECTION.html"; then
110 rm "$OUTPUT_DIR/$SECTION.html"
113 if test -e "$OUTPUT_DIR/out/$SECTION.texi"; then
114 rm "$OUTPUT_DIR/out/$SECTION.texi"
117 echo "Running $LILYPOND_BOOK"
120 -I "$LILYPOND_GIT/Documentation/snippets" \
121 -I "$LILYPOND_GIT/Documentation/snippets/new" \
122 -I "$LILYPOND_GIT/input/manual" \
123 -I "$LILYPOND_GIT/Documentation" \
124 -I "$LILYPOND_GIT/Documentation/included" \
125 -I "$LILYPOND_GIT/Documentation/pictures" \
126 -o "$OUTPUT_DIR/out" \
129 if [ "$BOOKRC" != 0 ]; then
130 echo "Lilypond-book returned code $BOOKRC"
134 echo "Running RefCheck"
138 if test -f "$OUTPUT_DIR/out/$SECTION.texi"; then
139 echo "Running $TEXI2HTML"
140 cat "$DOC_DIR/macros.itexi" "$OUTPUT_DIR/out/$SECTION.texi" > "$OUTPUT_DIR/$SECTION.texi"
143 --output="$OUTPUT_DIR/out/$SECTION.html" \
144 --I="$OUTPUT_DIR/out" \
145 "$OUTPUT_DIR/$SECTION.texi"
150 The $SECTION section of the $MANUAL manual should now be viewable at
152 $OUTPUT_DIR/out/$SECTION.html
154 If you want to keep the generated docs around for a while, answer
155 'n' to the next question. If you only needed them to quickly check
156 something, view them now and then answer 'y' when you're done.
160 read -p "rm -rf $OUTPUT_DIR ? (y/n): "
161 if [ "$REPLY" = "y" ]; then
162 echo "deleting files"