3 # The documentation generation process is tightly integrated with the
4 # scons build framework:
6 # * SCons analyzes the Doxyfile's to find all the documentation
7 # dependencies. This happens in the doxygen builder in
8 # senfscons/Doxygen.py.
10 # * the doclib/doxy-header.html and/or doclib/doxy-footer.html files
13 # * If any documentation is out-of-date with respect to it's source
14 # files, the documentation is regenerated.
16 # * To fix some link errors, the additional 'linklint' and 'fixlinks'
20 # 1. Scanning the Doxyfile's
22 # The doxygen builder scans all documentation source files which have
23 # the text 'doxyfile' in any case in their name. It understands
24 # @INCLUDE directives and will find all the dependencies of the
27 # * All the source files as selected by INPUT, INPUT_PATTERN,
28 # RECURSIVE and so on.
30 # * Any referenced tag-files
32 # * Documentation header and/or footer
34 # * The INPUT_FILTER program
36 # * Any included doxygen configuration files
39 # 2. Regenerating header and/or footer
41 # If needed, the doxy-header.html and/or doxy-footer.html file will be
42 # regenerated. The header and/or footer are generated from templates
43 # using a simple python based templating system called yaptu which is
44 # included in doclib/.
49 # The doxygen call itself is quite complex since there is some pre-
50 # and post-processing going on. We can separate this step into two
53 # * Building prerequisites (e.g. images)
55 # * The processing done by the Doxygen builder and doclib/doxygen.sh
58 # 3.1. Building prerequisites
60 # The prerequisites are images referenced by the documentation. These
61 # images are mostly generated using the Dia2Png builder.
64 # 3.2. The main doxygen build (Doxygen builder)
66 # The Doxygen builder will call the doxygen command to build the
69 # The doxygen command is configured as 'doclib/doxygen.sh' which
70 # does some additional processing in addition to calling doxygen
73 # * it sets environment variables depending on command line arguments.
74 # These variables are then used in the Doxyfile's
76 # * after doxygen is finished, 'installdox' is called to resolve
77 # tag file references.
79 # * the HTML documentation is post-processed using some sed, tidy, and
82 # * a generated tag file is post-processed using an XSLT template
84 # (see doclib/doxygen.sh for more information). The Doxygen
85 # configuration is set up such, that
87 # * doxygen calls 'doclib/filter.pl' on each source file. This filter
88 # will strip excess whitespace from the beginning of lines in
89 # '\code' and '<pre>' blocks. Additionally it will expand all tabs,
90 # tab width is 8 spaces (there should be no tabs in the source but
93 # * doxygen calls 'doclib/dot' to generate the 'dot' images.
95 # * 'doclib/dot' calls 'doclib/dot-munge.pl' on the .dot
96 # files. dot-munge.pl changes the font and font-size and adds
97 # line-breaks to long labels
99 # * 'doclib/dot' calls the real dot binary. If the resulting image is
100 # more than 800 pixels wide, dot is called again, this time using
101 # the oposite rank direction (top-bottom vs. left-right). The image
102 # with the smaller width is selected and returned.
105 # 4. Fixing broken links
107 # After the documentation has been generated, additional calls first
108 # to the 'linklint' and then to the 'fixlinks' target will try to fix
109 # broken links generated by doxygen. First, 'linklint' will call the
110 # linklint tool to check for broken links in the documentation.
112 # 'fixlinks' is then called which calls 'doclib/fixlinks.py' which
113 # scans *all* html files, builds an index of all (unique) anchors and
114 # then fixes the url part of all links with correct anchor but bad
120 import SENFSCons, datetime, os
122 ###########################################################################
127 # Naja ... etwas rumgehackt aber was solls ...
130 pathbase = env.Dir('#/senf').abspath
131 pathbasel = len(pathbase)+1
132 for module in env.Alias('all_docs')[0].sources:
133 if module.name != 'html.stamp' : continue
134 if not module.dir.dir.dir.abspath.startswith(pathbase): continue
135 mods[module.dir.dir.dir.abspath] = [ module.dir.dir.dir.abspath[pathbasel:].replace('/','_'),
136 module.dir.dir.dir.name,
137 module.dir.abspath[pathbasel:],
146 if len(rv[i]) > pathbasel and mod.startswith(rv[i] + '/'):
147 level = mods[rv[i]][-1] + 1
149 while i < len(rv) and mods[rv[i]][2] >= level:
152 mods[mod][-1] = level
158 return ( tuple(mods[mod]) for mod in rv )
161 ix = len(env.Dir('#').abspath)+1
162 return [ doc.dir.abspath[ix:]
163 for doc in env.Alias('all_docs')[0].sources
164 if doc.name == "search.idx" ]
166 def writeTemplate(target = None, source = None, env = None):
167 file(target[0].abspath,"w").write(processTemplate(env))
169 def processTemplate(env):
170 return yaptu.process(str(env['TEMPLATE']), globals(), env.Dictionary())
172 writeTemplate = env.Action(writeTemplate, varlist = [ 'TEMPLATE' ])
174 ###########################################################################
176 HEADER = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
179 <title>$title</title>
180 <link href="@TOPDIR@/doc/html/doxygen.css" rel="stylesheet" type="text/css">
181 <link href="@TOPDIR@/doclib/senf.css" rel="stylesheet" type="text/css">
182 <link rel="shortcut icon" href="@TOPDIR@/doclib/favicon.ico">
183 <style type="text/css">
184 div.tabs li.$projectname a { background-color: #EDE497; }
193 <form action="@TOPDIR@/doclib/search.php" method="get">
194 Search: <input type="text" name="query" size="20" accesskey="s"/>
197 <h1>SENF Extensible Network Framework</h1>
202 <li><a href="@TOPDIR@/doc/html/index.html">Home</a></li>
203 <li><a class="ext" href="http://satext.fokus.fraunhofer.de/senf/debian">Download</a></li>
204 <li><a class="ext" href="http://openfacts2.berlios.de/wikien/index.php/BerliosProject:SENF_Network_Framework">Wiki</a></li>
205 <li><a class="ext" href="http://developer.berlios.de/projects/senf">BerliOS</a></li>
206 <li><a class="ext" href="http://svn.berlios.de/wsvn/senf/?op=log&rev=0&sc=0&isdir=1">ChangeLog</a></li>
207 <li><a class="ext" href="http://svn.berlios.de/viewcvs/senf/trunk/">Browse SVN</a></li>
208 <li><a class="ext" href="http://developer.berlios.de/bugs/?group_id=7489">Bug Tracker</a></li>
215 <div class="tabs menu">
216 <li class="Overview level0"><a href="@TOPDIR@/doc/html/index.html">Overview</a></li>
217 <li class="Examples level0"><a href="@TOPDIR@/Examples/doc/html/index.html">Examples</a></li>
218 <li class="HowTos level0"><a href="@TOPDIR@/HowTos/doc/html/index.html">HowTos</a></li>
219 <li class="glossary level0"><a href="@TOPDIR@/doc/html/glossary.html">Glossary</a></li>
221 <div class="tabs menu">
223 {{ for id, name, path, level in modules():
224 <li class="${id} level${level}"><a href="@TOPDIR@/senf/${path}/index.html">${name}</a></li>
229 FOOTER = """<hr style="width:0px;border:none;clear:both;margin:0;padding:0" />
234 <a href="mailto:senf-dev@lists.berlios.de">Contact: senf-dev@lists.berlios.de</a> |
235 Copyright © 2006 Fraunhofer Gesellschaft, SatCom, Stefan Bund
241 <?php include 'search_functions.php'; ?>
242 <?php search(); ?>"""
244 SEARCH_PATHS_PHP="""<?php
247 {{ for index in indices():
255 'TODAY' : str(datetime.date.today()),
256 'TEXINPUTS' : os.environ.get('TEXINPUTS',env.Dir('#/doclib').abspath + ':'),
257 'DOXYGEN' : env.get('DOXYGEN', 'doxygen'),
262 DOXYGENCOM = "doclib/doxygen.sh $DOXYOPTS $SOURCE",
265 env.PhonyTarget('linklint', [], [
267 'linklint -doc linklint -limit 99999999 `find -type d -name html -printf "/%P/@ "`',
268 '[ ! -r linklint/errorX.html ] || python doclib/linklint_addnames.py <linklint/errorX.html >linklint/errorX.html.new',
269 '[ ! -r linklint/errorX.html.new ] || mv linklint/errorX.html.new linklint/errorX.html',
270 '[ ! -r linklint/errorAX.html ] || python doclib/linklint_addnames.py <linklint/errorAX.html >linklint/errorAX.html.new',
271 '[ ! -r linklint/errorAX.html.new ] || mv linklint/errorAX.html.new linklint/errorAX.html',
272 'echo -e "\\nLokal link check results: linklint/index.html\\nRemote link check results: linklint/urlindex.html\\n"',
275 env.PhonyTarget('fixlinks', [], [
276 'python doclib/fix-links.py -v -s .svn -s linklint -s debian linklint/errorX.txt linklint/errorAX.txt',
280 header = env.Command('doxy-header.html', 'SConscript', writeTemplate,
281 TEMPLATE = Literal(HEADER),
282 TITLE = "Documentation and API reference")
283 env.Depends(header, env.Value(repr(list(modules()))))
285 footer = env.Command('doxy-footer.html', 'SConscript', writeTemplate,
286 TEMPLATE = Literal(FOOTER))
288 env.Alias('all_docs',
289 env.Command('search.php', [ 'html-munge.xsl', 'SConscript' ],
291 'xsltproc --nonet --html --stringparam topdir .. -o - $SOURCE $TARGET 2>/dev/null'
293 + r" -e 's/\[\[/<?/g' -e 's/\]\]/?>/g'"
294 + r" -e 's/\$$projectname/Overview/g'"
295 + r" -e 's/\$$title/Search results/g'"
296 + "> ${TARGETS[0]}.tmp",
297 'mv ${TARGET}.tmp ${TARGET}' ],
298 TEMPLATE = Literal(HEADER
299 + SEARCH_PHP.replace('<?','[[').replace('?>',']]')
301 TITLE = "Search results"))
302 env.Alias('all_docs',
303 env.Command('search_paths.php', 'SConscript', writeTemplate,
304 TEMPLATE = Literal(SEARCH_PATHS_PHP)))
306 env.Alias('install_all',
307 env.Install( '$DOCINSTALLDIR/doclib', [ 'favicon.ico',
310 'search_functions.php',
314 env.Clean('all', 'doxy-header.html') # I should not need this but I do ...
315 env.Clean('all_docs', 'doxy-header.html') # I should not need this but I do ...