]> wagnertech.de Git - mfinanz.git/blob - scripts/build_doc.sh
kivitendo 3.9.2-0.2
[mfinanz.git] / scripts / build_doc.sh
1 #!/bin/bash
2
3 # Usage:
4 #   cd /path/to/kivitendo
5 #   ./scripts/build_doc.sh
6
7 set -e
8
9 if [[ ! -d doc ]]; then
10   echo "Please run this from the installation directory."
11   exit 1
12 fi
13
14 doc=${PWD}/doc
15
16 if [[ ! -d doc/build/dobudish ]]; then
17   echo "  ERROR: looks like 'doc/build/dobudish' DIR is missing"
18   echo "   - You need to get 'dobudish-nojre-1.1.4.zip' from https://code.google.com/archive/p/dobudish/downloads"
19   echo "   - Download and unpack ( unzip dobudish-nojre-1.1.4.zip -d doc/build )"
20   echo "   - create dobudish symlink ( ln -sf dobudish-1.1.4 doc/build/dobudish )"
21 fi
22
23 html=1
24 pdf=1
25 images=1
26
27 if [[ ! -z $1 ]] ; then
28   html=0
29   pdf=0
30   images=0
31   while [[ ! -z $1 ]] ; do
32     case $1 in
33       html)   html=1   ;;
34       pdf)    pdf=1    ;;
35       images) images=1 ;;
36       *)
37         echo "Unknown parameter $1"
38         exit 1
39         ;;
40     esac
41
42     shift
43   done
44 fi
45
46 cd doc/build/dobudish
47
48 base=documents/dokumentation
49 if [[ ! -d $base ]]; then
50   ./generator.sh dokumentation create book
51 fi
52
53 input=${base}/input
54 output=${base}/output
55 custom=${base}/custom-cfg
56
57 rm -rf ${input} ${custom}
58 mkdir ${input} ${input}/copy_to_output ${custom}
59
60 cp ${doc}/dokumentation.xml ${input}/
61 test -d ${doc}/images && cp -R ${doc}/images ${input}/copy_to_output/
62 cp -R ${doc}/build/custom-cfg/* ${custom}/
63
64 if [[ $pdf = 1 ]] ; then
65   ./generator.sh dokumentation pdf
66   cp ${output}/pdf/dokumentation.pdf ${doc}/kivitendo-Dokumentation.pdf
67 fi
68
69 if [[ $html = 1 ]]; then
70   ./generator.sh dokumentation html
71   rm -rf ${doc}/html
72   mkdir ${doc}/html
73   cp -R ${output}/html ${doc}/
74 fi
75
76 if [[ $images = 1 ]]; then
77   # copy system images from Dobudish directory
78   image_list=$(mktemp)
79   perl -nle 'print $1 while m{ (?: \.\./ )+ ( system/ [^\"]+ ) }xg' ${doc}/html/*.html | sort | uniq > $image_list
80   if [[ -s $image_list ]]; then
81     tar -c -f - -T $image_list | tar -x -f - -C ${doc}/html
82     perl -pi -e 's{ (\.\./)+ system }{system}xg' ${doc}/html/*.html
83   fi
84
85   rm $image_list
86 fi