Removed obsolete files from old Doxygen versions.
[wxWidgets.git] / docs / doxygen / regen.sh
1 #!/bin/bash
2 #
3 # $Id$
4 #
5 # This bash script regenerates the HTML doxygen version of the
6 # wxWidgets manual and adjusts the doxygen log to make it more
7 # readable.
8 #
9 # Usage:
10 # ./regen.sh [html|chm|xml|latex|all]
11 #
12 # Pass "x" to regen only the X output format and "all" to regen them all.
13 # If no arguments are passed all formats are regenerated
14 # (just like passing "all").
15 #
16
17
18 # remember current folder and then cd to the docs/doxygen one
19 me=$(basename $0)
20 path=${0%%/$me} # path from which the script has been launched
21 current=$(pwd)
22 cd $path
23 if [[ -z "$WXWIDGETS" ]]; then
24 WXWIDGETS=`cd ../.. && pwd`
25 # Use the real path in case it's a symlink
26 if command -v readlink; then
27 normalized=`readlink -e $WXWIDGETS`
28 if [[ -n $normalized ]]; then
29 WXWIDGETS=$normalized
30 fi
31 fi
32 if [ "$OSTYPE" = "cygwin" ]; then
33 WXWIDGETS=`cygpath -w $WXWIDGETS`
34 fi
35 export WXWIDGETS
36 fi
37
38 if [ "$DOXYGEN" = "" ]; then
39 DOXYGEN=doxygen
40 fi
41
42 # prepare folders for the cp commands below
43 mkdir -p out/html # we need to copy files in this folder below
44 mkdir -p out/html/generic
45
46 # These are not automatically copied by Doxygen because they're not
47 # used in doxygen documentation, only in our html footer and by our
48 # custom aliases
49 cp images/generic/*png out/html/generic
50 cp wxwidgets.js out/html
51
52 # which configuration should we use?
53 if [[ -z "$1" ]]; then
54 cfgfile="Doxyfile_all"
55 else
56 cfgfile="Doxyfile_$1"
57 fi
58
59 #
60 # NOW RUN DOXYGEN
61 #
62 # NB: we do this _after_ copying the required files to the output folders
63 # otherwise when generating the CHM file with Doxygen, those files are
64 # not included!
65 #
66 $DOXYGEN $cfgfile
67
68 if [[ "$1" = "qch" ]]; then
69 # we need to add missing files to the .qhp
70 cd out/html
71 qhelpfile="index.qhp"
72
73 # remove all <file> and <files> tags
74 cat $qhelpfile | grep -v "<file" >temp
75
76 # remove last 4 lines (so we have nothing after the last <keyword> tag)
77 lines=$(wc -l < temp)
78 wanted=`expr $lines - 4`
79 head -n $wanted temp >$qhelpfile
80
81 # generate a list of new <keyword> tags to add to the index file; without
82 # this step in the 'index' tab of Qt assistant the "wxWindow" class is not
83 # present; just "wxWindow::wxWindow" ctor is listed.
84 # NOTE: this operation is not indispensable but produces a QCH easier to use IMO.
85 sed -e 's/<keyword name="wx[a-zA-Z~]*" id="wx\([a-zA-Z]*\)::[a-zA-Z~]*" ref="\([a-z_]*.html\)#.*"/<keyword name="wx\1" id="wx\1" ref="\2"/g' < $qhelpfile | grep "<keyword name=\"wx" | uniq >temp
86 cat temp >>$qhelpfile
87 echo " </keywords>" >>$qhelpfile
88 echo " <files>" >>$qhelpfile
89
90 # remove useless files to make the qch slim
91 rm temp *map *md5
92
93 # add a <file> tag for _any_ file in out/html folder except the .qhp itself
94 for f in * */*png; do
95 if [[ $f != $qhelpfile ]]; then
96 echo " <file>$f</file>" >>$qhelpfile
97 fi
98 done
99
100 # add ending tags to the qhp file
101 echo " </files>
102 </filterSection>
103 </QtHelpProject>" >>$qhelpfile
104
105 # replace keyword names so that they appear fully-qualified in the
106 # "index" tab of the Qt Assistant; e.g. Fit => wxWindow::Fit
107 # NOTE: this operation is not indispendable but produces a QCH easier to use IMO.
108 sed -e 's/<keyword name="[a-zA-Z:~]*" id="\([a-zA-Z]*::[a-zA-Z~]*\)"/<keyword name="\1" id="\1"/g' <$qhelpfile >temp
109 mv temp $qhelpfile
110
111 # last, run qhelpgenerator:
112 cd ../..
113 qhelpgenerator out/html/index.qhp -o out/wx.qch
114 fi
115
116 if [[ "$1" = "docset" ]]; then
117 DOCSETNAME="org.wxwidgets.doxygen.wx29.docset"
118 ATOM="org.wxwidgets.doxygen.docset.wx29.atom"
119 ATOMDIR="http://docs.wxwidgets.org/docsets"
120 XAR="org.wxwidgets.doxygen.docset.wx29.xar"
121 XARDIR="http://docs.wxwidgets.org/docsets"
122 XCODE_INSTALL=`sh xcode-select -print-path`
123
124 cd out/html
125 DESTINATIONDIR=`pwd`
126
127 rm -rf $DESTINATIONDIR/$DOCSETNAME
128 rm -f $DESTINATIONDIR/$XAR
129
130 make
131
132 defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info CFBundleVersion 1.3
133 defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info CFBundleShortVersionString 1.3
134 defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info CFBundleName "wxWidgets 2.9 Library"
135 defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info DocSetFeedURL $ATOMDIR/$ATOM
136 defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info DocSetFallbackURL http://docs.wxwidgets.org
137 defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info DocSetDescription "API reference and conceptual documentation for wxWidgets 2.9"
138 defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info NSHumanReadableCopyright "Copyright 1992-2012 wxWidgets team, Portions 1996 Artificial Intelligence Applications Institute"
139
140 $XCODE_INSTALL/usr/bin/docsetutil package -atom $DESTINATIONDIR/$ATOM -download-url $XARDIR/$XAR -output $DESTINATIONDIR/$XAR $DESTINATIONDIR/$DOCSETNAME
141
142 cd ../..
143 fi
144
145 # Doxygen has the annoying habit to put the full path of the
146 # affected files in the log file; remove it to make the log
147 # more readable
148 currpath=`pwd`/
149 interfacepath=`cd ../../interface && pwd`/
150 cat doxygen.log | sed -e "s|$currpath||g" -e "s|$interfacepath||g" > temp
151 cat temp > doxygen.log
152 rm temp
153
154 # return to the original folder from which this script was launched
155 cd $current