Mercurial > hg > batmud > ggrtf
annotate docs/build-docs.sh @ 1632:8bf2b62edd12
Use rsync for uploading.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 11 Oct 2019 05:10:16 +0300 |
parents | 5a74247c16b5 |
children | 7c64f9b16f8f |
rev | line source |
---|---|
256 | 1 #!/bin/sh |
2 ### Settings | |
1547 | 3 DOCBOOKBASE="/usr/share/xml/docbook/stylesheet/docbook-xsl-ns" |
1045
42900ba491db
Use TFDoc in documentation building.
Matti Hamalainen <ccr@tnsp.org>
parents:
979
diff
changeset
|
4 UPURL="ccr@tnsp.org:public_html/ggrtf" |
42900ba491db
Use TFDoc in documentation building.
Matti Hamalainen <ccr@tnsp.org>
parents:
979
diff
changeset
|
5 TFPATH="../" |
42900ba491db
Use TFDoc in documentation building.
Matti Hamalainen <ccr@tnsp.org>
parents:
979
diff
changeset
|
6 SRCSGML="manual.sgml" |
42900ba491db
Use TFDoc in documentation building.
Matti Hamalainen <ccr@tnsp.org>
parents:
979
diff
changeset
|
7 SRCXML="manual.xml" |
1055
bb7806a7181c
Remove ASCII format documentation generation; Remove redundant GhostScript PDF generation code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1045
diff
changeset
|
8 SRCFO="manual.fo" |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
9 HTMLPATH="html" |
671
6d3d4d66c4c4
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
667
diff
changeset
|
10 HTMLFILE="$HTMLPATH/manual.html" |
6d3d4d66c4c4
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
667
diff
changeset
|
11 PDFFILE="manual.pdf" |
640
6dc4d0b19975
Added CSS stylesheets to HTML output.
Matti Hamalainen <ccr@tnsp.org>
parents:
639
diff
changeset
|
12 XSLTPARAMS="--stringparam html.stylesheet manual.css" |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
13 |
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
14 ### Get paths, if available |
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
15 echo "* Initialization" |
640
6dc4d0b19975
Added CSS stylesheets to HTML output.
Matti Hamalainen <ccr@tnsp.org>
parents:
639
diff
changeset
|
16 CPWD=`pwd` |
268
2b870ccb1b1d
Convert images to EPS, if NetPBM is installed.
Matti Hamalainen <ccr@tnsp.org>
parents:
259
diff
changeset
|
17 CONVERT=`which convert` |
2b870ccb1b1d
Convert images to EPS, if NetPBM is installed.
Matti Hamalainen <ccr@tnsp.org>
parents:
259
diff
changeset
|
18 PNMTOPS=`which pnmtops` |
2b870ccb1b1d
Convert images to EPS, if NetPBM is installed.
Matti Hamalainen <ccr@tnsp.org>
parents:
259
diff
changeset
|
19 GIFTOPNM=`which giftopnm` |
269
d049fe0beb05
Check for HTML Tidy and clean up HTML output if it is present.
Matti Hamalainen <ccr@tnsp.org>
parents:
268
diff
changeset
|
20 TIDY=`which tidy` |
626
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
21 XSLTPROC=`which xsltproc` |
1546
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
22 FOP=`which fop` |
1465
b4026d557b41
Don't use 'locate' to find required DocBook stylesheets, instead use a
Matti Hamalainen <ccr@tnsp.org>
parents:
1231
diff
changeset
|
23 CATALOGS1="$DOCBOOKBASE/xhtml/chunk.xsl" |
b4026d557b41
Don't use 'locate' to find required DocBook stylesheets, instead use a
Matti Hamalainen <ccr@tnsp.org>
parents:
1231
diff
changeset
|
24 CATALOGS2="$DOCBOOKBASE/xhtml/docbook.xsl" |
b4026d557b41
Don't use 'locate' to find required DocBook stylesheets, instead use a
Matti Hamalainen <ccr@tnsp.org>
parents:
1231
diff
changeset
|
25 CATALOGS3="$DOCBOOKBASE/fo/docbook.xsl" |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
26 |
1057 | 27 |
1546
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
28 ### Check for locally installed FOP |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
29 echo -n "* Checking for FOP .. " |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
30 if test -n "$FOP" -a -x "$FOP"; then |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
31 echo "$FOP" |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
32 elif test -x "$HOME/tf/docs/fop/fop"; then |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
33 FOP="$HOME/tf/docs/fop/fop" |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
34 echo "$FOP" |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
35 else |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
36 echo "no" |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
37 fi |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
38 |
268
2b870ccb1b1d
Convert images to EPS, if NetPBM is installed.
Matti Hamalainen <ccr@tnsp.org>
parents:
259
diff
changeset
|
39 ### Convert images |
2b870ccb1b1d
Convert images to EPS, if NetPBM is installed.
Matti Hamalainen <ccr@tnsp.org>
parents:
259
diff
changeset
|
40 echo "* Checking for image to EPS converting utilities ..." |
1062
bfaeec637a45
Prefer ImageMagick/GraphicsMagick over NetPBM utils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1061
diff
changeset
|
41 if test -n "$CONVERT" && test -x "$CONVERT"; then |
bfaeec637a45
Prefer ImageMagick/GraphicsMagick over NetPBM utils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1061
diff
changeset
|
42 echo "** GraphicsMagic/ImageMagick convert found" |
bfaeec637a45
Prefer ImageMagick/GraphicsMagick over NetPBM utils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1061
diff
changeset
|
43 for i in *.gif; do |
bfaeec637a45
Prefer ImageMagick/GraphicsMagick over NetPBM utils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1061
diff
changeset
|
44 TOUTFILE=`echo "$i" | sed "s/.gif/.eps/"` |
bfaeec637a45
Prefer ImageMagick/GraphicsMagick over NetPBM utils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1061
diff
changeset
|
45 echo " - $i -> $TOUTFILE" |
bfaeec637a45
Prefer ImageMagick/GraphicsMagick over NetPBM utils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1061
diff
changeset
|
46 $CONVERT "$i" "$TOUTFILE" |
bfaeec637a45
Prefer ImageMagick/GraphicsMagick over NetPBM utils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1061
diff
changeset
|
47 done |
bfaeec637a45
Prefer ImageMagick/GraphicsMagick over NetPBM utils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1061
diff
changeset
|
48 elif test -n "$PNMTOPS" && test -x "$PNMTOPS" && test -n "$GIFTOPNM" && test -x "$GIFTOPNM"; then |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
49 echo "** NetPBM tools found" |
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
50 for i in *.gif; do |
779 | 51 TOUTFILE=`echo "$i" | sed "s/.gif/.eps/"` |
52 echo " - $i -> $TOUTFILE" | |
53 $GIFTOPNM "$i" | $PNMTOPS -scale=0.5 -noturn > "$TOUTFILE" | |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
54 done |
268
2b870ccb1b1d
Convert images to EPS, if NetPBM is installed.
Matti Hamalainen <ccr@tnsp.org>
parents:
259
diff
changeset
|
55 else |
535 | 56 echo "*** WARNING! No supported image conversion tools found, not converting images." |
57 echo "*** This may cause some document format conversions to fail or produce errors." | |
268
2b870ccb1b1d
Convert images to EPS, if NetPBM is installed.
Matti Hamalainen <ccr@tnsp.org>
parents:
259
diff
changeset
|
58 fi |
256 | 59 |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
60 |
626
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
61 ### Check that we have xsltproc installed for DocBook XML processing |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
62 if test -n "$XSLTPROC" && test -x "$XSLTPROC"; then |
1231 | 63 echo "* xsltproc found, good... testing for DocBook XML stuff .." |
1540 | 64 if test -e "$CATALOGS1"; then |
626
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
65 echo " * $CATALOGS1 found." |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
66 else |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
67 echo "*** xhtml/chunk.xsl not found!" |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
68 exit 1 |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
69 fi |
1540 | 70 if test -e "$CATALOGS2"; then |
626
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
71 echo " * $CATALOGS2 found." |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
72 else |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
73 echo "*** xhtml/docbook.xsl not found!" |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
74 exit 1 |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
75 fi |
1540 | 76 if test -e "$CATALOGS3"; then |
810
3a37972d4215
Just some tweaks to docs building process.
Matti Hamalainen <ccr@tnsp.org>
parents:
780
diff
changeset
|
77 echo " * $CATALOGS3 found." |
3a37972d4215
Just some tweaks to docs building process.
Matti Hamalainen <ccr@tnsp.org>
parents:
780
diff
changeset
|
78 else |
3a37972d4215
Just some tweaks to docs building process.
Matti Hamalainen <ccr@tnsp.org>
parents:
780
diff
changeset
|
79 echo "*** fo/docbook.xsl not found!" |
3a37972d4215
Just some tweaks to docs building process.
Matti Hamalainen <ccr@tnsp.org>
parents:
780
diff
changeset
|
80 exit 1 |
3a37972d4215
Just some tweaks to docs building process.
Matti Hamalainen <ccr@tnsp.org>
parents:
780
diff
changeset
|
81 fi |
256 | 82 else |
626
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
83 echo "*** ERROR! Could not find xsltproc! You need xsltproc and the" |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
84 echo "*** DocBook XML suite (with XSL stylesheets) to be able to" |
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
85 echo "*** generate the documentation!" |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
86 exit 1 |
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
87 fi |
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
88 |
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
89 |
810
3a37972d4215
Just some tweaks to docs building process.
Matti Hamalainen <ccr@tnsp.org>
parents:
780
diff
changeset
|
90 ### Generate kludge-normalized XML from the DocBook SGML source |
1631
5a74247c16b5
Do not delete generated final DocBook XML.
Matti Hamalainen <ccr@tnsp.org>
parents:
1551
diff
changeset
|
91 echo "* Running tfdoc .." |
1064
dadf2faa4f35
Exit early if tfdoc or normalizeml fails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1062
diff
changeset
|
92 ( perl -w tfdoc.pl "$TFPATH" < "$SRCSGML" | perl -w normalizeml.pl > "$SRCXML" ) || exit 1 |
810
3a37972d4215
Just some tweaks to docs building process.
Matti Hamalainen <ccr@tnsp.org>
parents:
780
diff
changeset
|
93 |
3a37972d4215
Just some tweaks to docs building process.
Matti Hamalainen <ccr@tnsp.org>
parents:
780
diff
changeset
|
94 |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
95 ### Generate HTML files |
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
96 echo "* HTML" |
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
97 if test -e "$HTMLPATH"; then |
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
98 rm -fr "$HTMLPATH" |
256 | 99 fi |
305
127bc07f8d0f
HTML directory was not deleted and re-created if it did not already exist,
Matti Hamalainen <ccr@tnsp.org>
parents:
274
diff
changeset
|
100 mkdir -p "$HTMLPATH" |
256 | 101 |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
102 if test -d "$HTMLPATH"; then |
1045
42900ba491db
Use TFDoc in documentation building.
Matti Hamalainen <ccr@tnsp.org>
parents:
979
diff
changeset
|
103 cp *.css *.png *.gif "$HTMLPATH" && cd "$HTMLPATH" && $XSLTPROC $XSLTPARAMS "$CATALOGS1" "../$SRCXML" |
640
6dc4d0b19975
Added CSS stylesheets to HTML output.
Matti Hamalainen <ccr@tnsp.org>
parents:
639
diff
changeset
|
104 cd "$CPWD" |
274
b32bdb9db447
Copy images in HTML directory.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
105 |
1045
42900ba491db
Use TFDoc in documentation building.
Matti Hamalainen <ccr@tnsp.org>
parents:
979
diff
changeset
|
106 if $XSLTPROC $XSLTPARAMS "$CATALOGS2" "$SRCXML" > "$HTMLFILE"; then |
1231 | 107 echo " * Transform successful." |
779 | 108 else |
109 echo "*** ERROR! $XSLTPROC failed. Quitting on fatal error." | |
1045
42900ba491db
Use TFDoc in documentation building.
Matti Hamalainen <ccr@tnsp.org>
parents:
979
diff
changeset
|
110 echo "*** Check $SRCXML for errors." |
779 | 111 exit 2 |
112 fi | |
256 | 113 |
1231 | 114 echo " * Checking for HTML Tidy ..." |
626
39fb83d9a2dc
Refactored documentation generating.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
115 if test -n "$TIDY" && test -x "$TIDY"; then |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
116 echo "** Found, cleaning up the mess by DocBook .." |
979
24535e8e207e
Change HTML TIDY's max line length to fix a stupid problem with certain "must be typed exactly as shown" BatMUD settings in the manual and additionally introduced hidden whitespaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
846
diff
changeset
|
117 if $TIDY -q -w 512 -utf8 -asxhtml -i -m $HTMLPATH/*.html "$HTMLFILE"; then |
779 | 118 echo "** Tidying process successful." |
119 fi | |
535 | 120 else |
667 | 121 echo "*** WARNING! HTML tidy not found! To get better HTML output," |
122 echo "*** please install HTML tidy (http://tidy.sourceforge.net/)" | |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
123 fi |
269
d049fe0beb05
Check for HTML Tidy and clean up HTML output if it is present.
Matti Hamalainen <ccr@tnsp.org>
parents:
268
diff
changeset
|
124 fi |
d049fe0beb05
Check for HTML Tidy and clean up HTML output if it is present.
Matti Hamalainen <ccr@tnsp.org>
parents:
268
diff
changeset
|
125 |
810
3a37972d4215
Just some tweaks to docs building process.
Matti Hamalainen <ccr@tnsp.org>
parents:
780
diff
changeset
|
126 |
1546
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
127 ### Generate PDF |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
128 rm -f "$PDFFILE" |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
129 if test -n "$FOP" && test -x "$FOP" && test -e "$SRCXML"; then |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
130 echo "* PDF .." |
cfcbe5e0c12e
Try to use FOP for converting to PDF.
Matti Hamalainen <ccr@tnsp.org>
parents:
1540
diff
changeset
|
131 $FOP -xml "$SRCXML" -xsl "$CATALOGS3" -pdf "$PDFFILE" |
1523 | 132 fi |
639 | 133 |
1550
bbe377cccd05
Remove temporary files generated during documentation build process.
Matti Hamalainen <ccr@tnsp.org>
parents:
1547
diff
changeset
|
134 ## Remove temporary files |
1631
5a74247c16b5
Do not delete generated final DocBook XML.
Matti Hamalainen <ccr@tnsp.org>
parents:
1551
diff
changeset
|
135 #rm -f "$SRCXML" |
1550
bbe377cccd05
Remove temporary files generated during documentation build process.
Matti Hamalainen <ccr@tnsp.org>
parents:
1547
diff
changeset
|
136 |
273
754a6e8fc369
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
137 |
671
6d3d4d66c4c4
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
667
diff
changeset
|
138 ## Upload |
1632 | 139 do_upload() |
140 { | |
141 rsync -vptog --bwlimit=500 -e ssh "$@" | |
142 } | |
143 | |
671
6d3d4d66c4c4
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
667
diff
changeset
|
144 if test "x$1" = "x--upload"; then |
1632 | 145 do_upload $HTMLPATH/* manual.css "$UPURL/html/" |
146 do_upload "$PDFFILE" "$UPURL" | |
147 do_upload "$HOME/bin/tf5" "$UPURL/tf5.sh" | |
671
6d3d4d66c4c4
Improved docs building script.
Matti Hamalainen <ccr@tnsp.org>
parents:
667
diff
changeset
|
148 fi |