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 site_scons/lib/.
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
56 # site_scon/lib/doxygen.sh
59 # 3.1. Building prerequisites
61 # The prerequisites are images referenced by the documentation. These
62 # images are mostly generated using the Dia2Png builder.
65 # 3.2. The main doxygen build (Doxygen builder)
67 # The Doxygen builder will call the doxygen command to build the
70 # The doxygen command is configured as 'site_scon/lib/doxygen.sh' which
71 # does some additional processing in addition to calling doxygen
74 # * it sets environment variables depending on command line arguments.
75 # These variables are then used in the Doxyfile's
77 # * after doxygen is finished, 'installdox' is called to resolve
78 # tag file references.
80 # * the HTML documentation is post-processed using some sed, tidy, and
83 # * a generated tag file is post-processed using an XSLT template
85 # (see site_scon/lib/doxygen.sh for more information). The Doxygen
86 # configuration is set up such, that
88 # * doxygen calls 'site_scons/lib/filter.pl' on each source file. This
89 # filter will strip excess whitespace from the beginning of lines in
90 # '\code' and '<pre>' blocks. Additionally it will expand all tabs,
91 # tab width is 8 spaces (there should be no tabs in the source but
94 # * 'site_scons/lib/filter.pl' calls 'site_scons/lib/makeDiaImageMap.py'
95 # whenever finding a '\diaimage' command. This will create an image
96 # map (in an encoded form which will be fixed by html-munge.xsl
99 # * doxygen calls 'site_scons/lib/dot' to generate the 'dot' images.
101 # * 'site_scons/lib/dot' calls 'site_scons/lib/dot-munge.pl' on the
102 # .dot files. dot-munge.pl changes the font and font-size and adds
103 # line-breaks to long labels
105 # * 'site_scons/lib/dot' calls the real dot binary. If the resulting
106 # image is more than 800 pixels wide, dot is called again, this time
107 # using the oposite rank direction (top-bottom vs. left-right). The
108 # image with the smaller width is selected and returned.
111 # 4. Fixing broken links
113 # After the documentation has been generated, additional calls first
114 # to the 'linklint' and then to the 'fixlinks' target will try to fix
115 # broken links generated by doxygen. First, 'linklint' will call the
116 # linklint tool to check for broken links in the documentation.
118 # 'fixlinks' is then called which calls 'doclib/fixlinks.py' which
119 # scans *all* html files, builds an index of all (unique) anchors and
120 # then fixes the url part of all links with correct anchor but bad
126 import SENFSCons, datetime, os
128 ###########################################################################
133 # Naja ... etwas rumgehackt aber was solls ...
136 pathbase = env.Dir('#/senf').abspath
137 pathbasel = len(pathbase)+1
138 for module in env.Alias('all_docs')[0].sources:
139 if module.name != 'html.stamp' : continue
140 if not module.dir.dir.dir.abspath.startswith(pathbase): continue
141 mods[module.dir.dir.dir.abspath] = [ module.dir.dir.dir.abspath[pathbasel:].replace('/','_'),
142 module.dir.dir.dir.name,
143 module.dir.abspath[pathbasel:],
152 if len(rv[i]) > pathbasel and mod.startswith(rv[i] + '/'):
153 level = mods[rv[i]][-1] + 1
155 while i < len(rv) and mods[rv[i]][2] >= level:
158 mods[mod][-1] = level
164 return ( tuple(mods[mod]) for mod in rv )
167 ix = len(env.Dir('#').abspath)+1
168 return [ doc.dir.abspath[ix:]
169 for doc in env.Alias('all_docs')[0].sources
170 if doc.name == "search.idx" ]
172 def writeTemplate(target = None, source = None, env = None):
173 file(target[0].abspath,"w").write(processTemplate(env))
175 def processTemplate(env):
176 return yaptu.process(str(env['TEMPLATE']), globals(), env.Dictionary())
178 writeTemplate = env.Action(writeTemplate, varlist = [ 'TEMPLATE' ])
180 ###########################################################################
182 HEADER = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
185 <title>$title</title>
186 <link href="@TOPDIR@/doc/html/doxygen.css" rel="stylesheet" type="text/css">
187 <link href="@TOPDIR@/doclib/senf.css" rel="stylesheet" type="text/css">
188 <link rel="shortcut icon" href="@TOPDIR@/doclib/favicon.ico">
189 <style type="text/css">
190 div.tabs li.$projectname a { background-color: #EDE497; }
199 <form action="@TOPDIR@/doclib/search.php" method="get">
200 Search: <input type="text" name="query" size="20" accesskey="s"/>
203 <h1>SENF Extensible Network Framework</h1>
208 <li><a href="@TOPDIR@/doc/html/index.html">Home</a></li>
209 <li><a class="ext" href="http://satext.fokus.fraunhofer.de/senf/debian">Download</a></li>
210 <li><a class="ext" href="http://openfacts2.berlios.de/wikien/index.php/BerliosProject:SENF_Network_Framework">Wiki</a></li>
211 <li><a class="ext" href="http://developer.berlios.de/projects/senf">BerliOS</a></li>
212 <li><a class="ext" href="http://svn.berlios.de/wsvn/senf/?op=log&rev=0&sc=0&isdir=1">ChangeLog</a></li>
213 <li><a class="ext" href="http://svn.berlios.de/viewcvs/senf/trunk/">Browse SVN</a></li>
214 <li><a class="ext" href="http://developer.berlios.de/bugs/?group_id=7489">Bug Tracker</a></li>
221 <div class="tabs menu">
222 <li class="Overview level0"><a href="@TOPDIR@/doc/html/index.html">Overview</a></li>
223 <li class="Examples level0"><a href="@TOPDIR@/Examples/doc/html/index.html">Examples</a></li>
224 <li class="HowTos level0"><a href="@TOPDIR@/HowTos/doc/html/index.html">HowTos</a></li>
225 <li class="glossary level0"><a href="@TOPDIR@/doc/html/glossary.html">Glossary</a></li>
227 <div class="tabs menu">
229 {{ for id, name, path, level in modules():
230 <li class="${id} level${level}"><a href="@TOPDIR@/senf/${path}/index.html">${name}</a></li>
235 FOOTER = """<hr style="width:0px;border:none;clear:both;margin:0;padding:0" />
240 <a href="mailto:senf-dev@lists.berlios.de">Contact: senf-dev@lists.berlios.de</a> |
241 © 2006-2010 <a href="http://www.fokus.fraunhofer.de/en/net/index.html">
242 Fraunhofer Institute for Open Communication Systems, Network Research</a>
248 <?php include 'search_functions.php'; ?>
249 <?php search(); ?>"""
251 SEARCH_PATHS_PHP="""<?php
254 {{ for index in indices():
266 'TODAY' : str(datetime.date.today()),
269 env.PhonyTarget('linklint', [], [
270 'rm -rf doc/linklint',
271 'linklint -doc doc/linklint -limit 99999999 `find -type d -name html -printf "/%P/@ "`',
272 '[ ! -r doc/linklint/errorX.html ] || python doclib/linklint_addnames.py <doc/linklint/errorX.html >doc/linklint/errorX.html.new',
273 '[ ! -r doc/linklint/errorX.html.new ] || mv doc/linklint/errorX.html.new doc/linklint/errorX.html',
274 '[ ! -r doc/linklint/errorAX.html ] || python doclib/linklint_addnames.py <doc/linklint/errorAX.html >doc/linklint/errorAX.html.new',
275 '[ ! -r doc/linklint/errorAX.html.new ] || mv doc/linklint/errorAX.html.new doc/linklint/errorAX.html',
278 env.PhonyTarget('fixlinks', [], [
279 'python doclib/fix-links.py -v -s .svn -s linklint -s debian doc/linklint/errorX.txt doc/linklint/errorAX.txt',
282 header = env.Command('doxy-header.html', 'SConscript', writeTemplate,
283 TEMPLATE = Literal(HEADER),
284 TITLE = "Documentation and API reference")
285 env.Depends(header, env.Value(repr(list(modules()))))
287 footer = env.Command('doxy-footer.html', 'SConscript', writeTemplate,
288 TEMPLATE = Literal(FOOTER))
290 env.Alias('all_docs',
291 env.Command('search.php', [ '#/site_scons/lib/html-munge.xsl', 'SConscript' ],
293 'xsltproc --nonet --html --stringparam topdir .. -o - $SOURCE $TARGET 2>/dev/null'
295 + r" -e 's/\[\[/<?/g' -e 's/\]\]/?>/g'"
296 + r" -e 's/\$$projectname/Overview/g'"
297 + r" -e 's/\$$title/Search results/g'"
298 + "> ${TARGETS[0]}.tmp",
299 'mv ${TARGET}.tmp ${TARGET}' ],
300 TEMPLATE = Literal(HEADER
301 + SEARCH_PHP.replace('<?','[[').replace('?>',']]')
303 TITLE = "Search results"))
304 env.Alias('all_docs',
305 env.Command('search_paths.php', 'SConscript', writeTemplate,
306 TEMPLATE = Literal(SEARCH_PATHS_PHP)))
308 env.Alias('install_all',
309 env.Install( '$DOCINSTALLDIR/doclib', [ 'favicon.ico',
312 'search_functions.php',
316 env.Clean('all', 'doxy-header.html') # I should not need this but I do ...
317 env.Clean('all_docs', 'doxy-header.html') # I should not need this but I do ...
319 env.Install('${DOCINSTALLDIR}', 'index.html')
321 env.Depends(SENFSCons.Doxygen(env, output_directory="../doc"), env.Value(env['ENV']['REVISION']))