source: rtems-docs/common/waf.py @ 62efd4c

5
Last change on this file since 62efd4c was 62efd4c, checked in by Chris Johns <chrisj@…>, on 02/19/19 at 23:11:37

waf: Change --sphinx-verbose to --sphinx-options, add --sphinx-nit-pick

Provide options to manage sphinx. Make using the nit-picky mode simpler
to access.

  • Property mode set to 100644
File size: 20.2 KB
RevLine 
[5ce8e43]1#
2# RTEMS Documentation Project
3#
4# Waf build support.
5#
6
7
8from __future__ import print_function
9
10import os
11import re
12import sys
13
[f916fca]14from waflib.Build import BuildContext
[5daabd2]15
[8330198]16import latex
[a3b0a40]17import conf
[8330198]18
[0bc9c6d]19sphinx_min_version = (1, 3)
[a316b1f]20
[0263581]21def version_cmdline(ctx):
[3202e31]22    return '-Drelease="%s" -Dversion="%s"' % (ctx.env.RELEASE, ctx.env.VERSION)
[0263581]23
[5ce8e43]24def sphinx_cmdline(ctx, build_type, conf_dir, doctrees,
25                   source_dir, output_dir, configs = []):
26    cfgs = ''
27    for c in configs:
28        cfgs += ' -D %s=%s' % (c, configs[c])
29    rule = "${BIN_SPHINX_BUILD} %s -b %s -c %s %s -d %s %s %s %s ${SRC}" % \
[62efd4c]30           (sphinx_options(ctx), build_type, conf_dir, version_cmdline(ctx),
[5ce8e43]31            doctrees, cfgs, source_dir, output_dir)
[0263581]32    return rule
33
[f916fca]34def cmd_spell(ctx):
[0bc9c6d]35    from waflib import Options
36    from sys import argv
37    from subprocess import call
[f916fca]38
[0bc9c6d]39    Options.commands = None # stop warnings about knowing commands.
[f916fca]40
[0bc9c6d]41    if not ctx.env.BIN_ASPELL:
42        ctx.fatal("'aspell' is required please install and re-run configure.")
[f916fca]43
[0bc9c6d]44    if len(argv) < 3:
45        ctx.fatal("Please supply at least one file name")
[f916fca]46
[0bc9c6d]47    files = argv[2:]
[f916fca]48
[0bc9c6d]49    path = ctx.path.parent.abspath()
[f916fca]50
[0bc9c6d]51    # XXX: add error checking eg check if file exists.
52    for file in files:
53        cmd = ctx.env.BIN_ASPELL + \
54              ["-c",
55               "--personal=%s/common/spell/dict/rtems" % path,
56               "--extra-dicts=%s/common/spell/en_GB-ise-w_accents.multi" % path,
57               file]
58        print("running:", cmd)
59        call(cmd)
[f916fca]60
[0263581]61def cmd_linkcheck(ctx):
62    conf_dir = ctx.path.get_src()
63    source_dir = ctx.path.get_src()
64    buildtype = 'linkcheck'
65    build_dir, output_node, output_dir, doctrees = build_dir_setup(ctx, buildtype)
66    rule = sphinx_cmdline(ctx, buildtype, conf_dir, doctrees, source_dir, output_dir)
[0bc9c6d]67    ctx(
[0263581]68        rule   = rule,
[0bc9c6d]69        cwd    = ctx.path.abspath(),
70        source = ctx.path.ant_glob('**/*.rst'),
71        target = "linkcheck/output.txt"
72    )
[ed3794e]73
[f916fca]74class spell(BuildContext):
[0bc9c6d]75    __doc__ = "Check spelling.  Supply a list of files or a glob (*.rst)"
76    cmd = 'spell'
77    fun = 'cmd_spell'
[3a71759]78
[ed3794e]79class linkcheck(BuildContext):
[0bc9c6d]80    __doc__ = "Check all external URL references."
81    cmd = 'linkcheck'
82    fun = 'cmd_linkcheck'
[ed3794e]83
[14bbcb1]84def check_sphinx_version(ctx, minver):
[0bc9c6d]85    try:
[2a06644]86        import sphinx
87        # sphinx.version_info was introduced in sphinx ver 1.2
88        version = sphinx.version_info
89        # version looks like (1, 7, 0, 'final', 0))
90        ver = version[0:2]
[0bc9c6d]91    except:
[2a06644]92        try:
93            # sphinx-build returns its version info in stderr
94            (out, err) = ctx.cmd_and_log(ctx.env.BIN_SPHINX_BUILD +
95                              ['--version'], output=Context.BOTH)
96            # err looks like 'sphinx-build 1.7.0\n'
97            version = err.split(" ")[-1:][0].strip()
98            ver = tuple(map(int, re.split('[\D]', version)))
99        except:
100            try:
101                # sphinx-build returns its version info in stdout
102                version = ctx.cmd_and_log(ctx.env.BIN_SPHINX_BUILD +
103                              ['--version']).split(" ")[-1:][0].strip()
104                try:
105                    ver = tuple(map(int, re.split('[\D]', version)))
106                except:
[a46b025]107                    ctx.fatal("Sphinx version cannot be checked or Sphinx is not installed")
[2a06644]108            except:
[a46b025]109                ctx.fatal("Sphinx version cannot be checked or Sphinx is not installed")
[0bc9c6d]110    if ver < minver:
111        ctx.fatal("Sphinx version is too old: %s" % ".".join(map(str, ver)))
112    return ver
[14bbcb1]113
[62efd4c]114def sphinx_options(ctx):
115    return ' '.join(ctx.env.SPHINX_OPTIONS)
[0bc9c6d]116
117def is_top_build(ctx):
118    from_top = False
119    if ctx.env['BUILD_FROM_TOP'] and ctx.env['BUILD_FROM_TOP'] == 'yes':
120        from_top = True
121    return from_top
122
123def build_dir_setup(ctx, buildtype):
124    where = buildtype
125    if is_top_build(ctx):
126        where = os.path.join(ctx.path.name, where)
[9024cfb]127    bnode = ctx.bldnode.find_node(where)
[0bc9c6d]128    if bnode is None:
129        ctx.bldnode.make_node(where).mkdir()
130    build_dir = ctx.path.get_bld().relpath()
131    output_node = ctx.path.get_bld().make_node(buildtype)
132    output_dir = output_node.abspath()
[6207c37]133    doctrees = os.path.join(os.path.dirname(output_dir), 'doctrees', buildtype)
134    return build_dir, output_node, output_dir, doctrees
[0bc9c6d]135
[8330198]136def pdf_resources(ctx, buildtype):
[2fdbc98]137    packages_base = ctx.path.parent.find_dir('common/latex')
138    if packages_base is None:
139        ctx.fatal('Latex package directory not found')
140    base = packages_base.path_from(ctx.path)
141    fnode = ctx.path.get_bld().make_node(buildtype)
142    fnode.mkdir()
[8330198]143    local_packages = latex.local_packages()
[5ce8e43]144    targets = []
[8330198]145    if local_packages is not None:
146        srcs = [os.path.join(base, p) for p in local_packages]
[5ce8e43]147        targets += [fnode.make_node(p) for p in local_packages]
148        ctx(features = "subst",
[8330198]149            is_copy  = True,
150            source   = srcs,
[5ce8e43]151            target   = targets)
152    targets += [fnode.make_node('rtemsextrafonts.sty')]
153    ctx(features = "subst",
[2fdbc98]154        is_copy  = True,
155        source   = os.path.join(base, ctx.env.RTEMSEXTRAFONTS),
[5ce8e43]156        target   = fnode.make_node('rtemsextrafonts.sty'))
157    return targets
[8330198]158
[0bc9c6d]159def html_resources(ctx, buildtype):
[5ce8e43]160    extra_source = []
[0bc9c6d]161    for dir_name in ["_static", "_templates"]:
162        files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir_name)
163        fnode = ctx.path.get_bld().make_node(os.path.join(buildtype, dir_name))
[5ce8e43]164        targets = [fnode.make_node(x.name) for x in files]
165        extra_source += targets
[0bc9c6d]166        fnode.mkdir() # dirs
[5ce8e43]167        ctx(features = "subst",
[0bc9c6d]168            is_copy  = True,
169            source   = files,
[5ce8e43]170            target   = targets)
171        ctx.add_group()
172    return extra_source
[74194f7]173
[ff9d555]174def check_sphinx_extension(ctx, extension):
175    def run_sphinx(bld):
176        rst_node = bld.srcnode.make_node('testbuild/contents.rst')
177        rst_node.parent.mkdir()
178        rst_node.write('.. COMMENT test sphinx\n')
179        bld(rule = bld.kw['rule'], source = rst_node)
180
181    ctx.start_msg("Checking for '%s'" % (extension))
182    try:
183        ctx.run_build(fragment = 'xx',
184                      rule = "${BIN_SPHINX_BUILD} -b html -D extensions=%s -C . out" % (extension),
185                      build_fun = run_sphinx,
186                      env = ctx.env)
187    except ctx.errors.ConfigurationError:
188        ctx.end_msg('not found (see README.txt)', 'RED')
189        ctx.fatal('The configuration failed')
190    ctx.end_msg('found')
[0bc9c6d]191
[ff9d555]192def cmd_configure(ctx):
193    check_sphinx = not ctx.env.BIN_SPHINX_BUILD
194    if check_sphinx:
195        ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD", mandatory = True)
196        ctx.find_program("aspell", var = "BIN_ASPELL", mandatory = False)
197
198        ctx.start_msg("Checking if Sphinx is at least %s.%s" % sphinx_min_version)
199        ver = check_sphinx_version(ctx, sphinx_min_version)
200        ctx.end_msg("yes (%s)" % ".".join(map(str, ver)))
201
[62efd4c]202        ctx.start_msg("Checking Sphinx Options ")
203        if 'SPHINX_OPTIONS' not in ctx.env:
204            ctx.env.append_value('SPHINX_OPTIONS', ctx.options.sphinx_options)
205            opts = sphinx_options(ctx)
206            if len(opts) == 0:
207                opts = 'none'
208            ctx.end_msg(opts)
209
210        ctx.start_msg("Checking Sphinx Nit-Pick mode ")
211        if ctx.options.sphinx_nit_pick:
212            opt = '-n'
213            msg = 'yes'
214        else:
215            opt = '-Q'
216            msg = 'no'
217        ctx.env.append_value('SPHINX_OPTIONS', opt)
218        ctx.end_msg(msg)
219
[ff9d555]220        #
221        # Check extensions.
222        #
223        check_sphinx_extension(ctx, 'sphinx.ext.autodoc')
224        check_sphinx_extension(ctx, 'sphinx.ext.coverage')
225        check_sphinx_extension(ctx, 'sphinx.ext.doctest')
226        check_sphinx_extension(ctx, 'sphinx.ext.graphviz')
227        check_sphinx_extension(ctx, 'sphinx.ext.intersphinx')
228        check_sphinx_extension(ctx, 'sphinx.ext.mathjax')
[58de62d]229        check_sphinx_extension(ctx, 'sphinxcontrib.bibtex')
[0bc9c6d]230
231    #
232    # Optional builds.
233    #
234    ctx.env.BUILD_PDF = 'no'
235    if ctx.options.pdf:
[a3b0a40]236        if conf.latex_engine == 'xelatex':
237            if not ctx.env.LATEX_CMD:
238                ctx.load('tex')
239                if not ctx.env.XELATEX or not ctx.env.MAKEINDEX:
240                    ctx.fatal('The programs xelatex and makeindex are required for PDF output')
241                ctx.env.LATEX_CMD = 'xelatex'
242                latex.configure_tests(ctx)
243                # Minted needs 'shell-escape'
244                if 'XELATEXFLAGS' not in ctx.env or \
245                   '-shell-escape' not in ctx.env['XELATEXFLAGS']:
246                    ctx.env.append_value('XELATEXFLAGS', '-shell-escape')
247                ctx.env.append_value('MAKEINDEXFLAGS', ['-s', 'python.ist'])
248        elif conf.latex_engine == 'pdflatex':
249            if not ctx.env.LATEX_CMD:
250                ctx.load('tex')
251                if not ctx.env.PDFLATEX or not ctx.env.MAKEINDEX:
252                    ctx.fatal('The programs pdflatex and makeindex are required for PDF output')
253                if 'PDFLATEXFLAGS' not in ctx.env or \
254                   '-shell-escape' not in ctx.env['PDFLATEXFLAGS']:
255                    ctx.env.append_value('PDFLATEXFLAGS', '-shell-escape')
256                ctx.env.append_value('MAKEINDEXFLAGS', ['-s', 'python.ist'])
257                ctx.env.LATEX_CMD = 'pdflatex'
258                latex.configure_tests(ctx)
259        else:
260            ctx.fatal('Unsupported latex engine: %s' % (conf.latex_engine))
[0bc9c6d]261        ctx.env.BUILD_PDF = 'yes'
262
263    ctx.envBUILD_SINGLEHTML = 'no'
264    if ctx.options.singlehtml:
[91d6c96]265        check_inliner = not ctx.env.BIN_INLINER
266        if check_inliner:
267            ctx.env.BUILD_SINGLEHTML = 'yes'
268            ctx.find_program("inliner", var = "BIN_INLINER", mandatory = False)
269            if not ctx.env.BIN_INLINER:
[21c1a44]270                ctx.fatal("Node.js inliner is required install with 'npm install -g inliner' " +
[91d6c96]271                          "(https://github.com/remy/inliner)")
[dd43d0b]272
[21c1a44]273    ctx.envBUILD_PLANTUML = 'no'
274    if ctx.options.plantuml:
275        check_plantuml = not ctx.env.BIN_PUML
276        if check_plantuml:
277            ctx.env.BUILD_PLANTUML = 'yes'
278            ctx.find_program("puml", var = "BIN_PUML", mandatory = False)
279            if not ctx.env.BIN_PUML:
280                ctx.fatal("Node.js puml is required install with 'npm install -g node-plantuml' " +
281                          "(https://www.npmjs.com/package/node-plantuml)")
282
283    ctx.envBUILD_DITAA = 'no'
284    if ctx.options.ditaa:
285        #
286        # We use DITAA via PlantUML
287        #
288        if not ctx.env.BIN_PUML:
289            ctx.find_program("puml", var = "BIN_PUML", mandatory = False)
290            if not ctx.env.BIN_PUML:
291                ctx.fatal("DITAA uses PlantUML; " +
292                          "Node.js puml is required install with 'npm install -g node-plantuml' " +
293                          "(https://www.npmjs.com/package/node-plantuml)")
294        check_ditaa = not ctx.env.BIN_DITAA
295        if check_ditaa:
296            ctx.env.BUILD_DITAA = 'yes'
297            ctx.find_program("ditaa", var = "BIN_DITAA", mandatory = False)
298            if not ctx.env.BIN_DITAA:
299                ctx.fatal("DITAA not found, plase install")
300
[8e8094a]301def doc_pdf(ctx, source_dir, conf_dir, extra_source):
[0bc9c6d]302    buildtype = 'latex'
[6207c37]303    build_dir, output_node, output_dir, doctrees = build_dir_setup(ctx, buildtype)
[5ce8e43]304    resources = pdf_resources(ctx, buildtype)
[228560f]305    rule = sphinx_cmdline(ctx, buildtype, conf_dir, doctrees, source_dir, output_dir)
[0bc9c6d]306    ctx(
307        rule         = rule,
308        cwd          = ctx.path,
[8e8094a]309        source       = ctx.path.ant_glob('**/*.rst') + extra_source,
[5ce8e43]310        depends_on   = extra_source,
[0bc9c6d]311        target       = ctx.path.find_or_declare("%s/%s.tex" % (buildtype,
312                                                               ctx.path.name))
313    )
314    ctx(
315        features     = 'tex',
316        cwd          = output_dir,
[a3b0a40]317        type         = ctx.env.LATEX_CMD,
[0bc9c6d]318        source       = "%s/%s.tex" % (buildtype, ctx.path.name),
319        prompt       = 0
320    )
321    ctx.install_files('${PREFIX}',
322                      '%s/%s.pdf' % (buildtype, ctx.path.name),
323                      cwd = output_node,
324                      quiet = True)
[dd43d0b]325
[8e8094a]326def doc_singlehtml(ctx, source_dir, conf_dir, extra_source):
[0bc9c6d]327    #
328    # Use a run command to handle stdout and stderr output from inliner. Using
329    # a standard rule in the build context locks up.
330    #
331    def run(task):
332        src = task.inputs[0].abspath()
333        tgt = task.outputs[0].abspath()
334        cmd = '%s %s' % (task.env.BIN_INLINER[0], src)
335        so = open(tgt, 'w')
336        se = open(tgt + '.err', 'w')
337        r = task.exec_command(cmd, stdout = so, stderr = se)
338        so.close()
339        se.close()
340        #
341        # The inliner does not handle internal href's correctly and places the
342        # input's file name in the href. Strip these.
343        #
344        with open(tgt, 'r') as i:
345            before = i.read()
346            after = before.replace('index.html', '')
347        i.close()
348        with open(tgt, 'w') as o:
349            o.write(after)
350        o.close()
351        return r
352
353    buildtype = 'singlehtml'
[6207c37]354    build_dir, output_node, output_dir, doctrees = build_dir_setup(ctx, buildtype)
[859096b]355    resources = html_resources(ctx, buildtype)
[228560f]356    rule = sphinx_cmdline(ctx, buildtype, conf_dir, doctrees, source_dir, output_dir)
[0bc9c6d]357    ctx(
358        rule         = rule,
359        cwd          = ctx.path,
[8e8094a]360        source       = ctx.path.ant_glob('**/*.rst') + extra_source,
[5ce8e43]361        depends_on   = resources,
[0bc9c6d]362        target       = ctx.path.find_or_declare("%s/index.html" % (buildtype)),
363        install_path = None
364    )
365    ctx(
366        rule         = run,
367        inliner      = ctx.env.BIN_INLINER,
368        source       = "%s/index.html" % buildtype,
369        target       = "%s/%s.html" % (buildtype, ctx.path.name),
370        install_path = '${PREFIX}'
371    )
[a316b1f]372
[8e8094a]373def doc_html(ctx, source_dir, conf_dir, extra_source):
[0bc9c6d]374    buildtype = 'html'
[6207c37]375    build_dir, output_node, output_dir, doctrees = build_dir_setup(ctx, buildtype)
[5ce8e43]376    resources = html_resources(ctx, buildtype)
377    templates = os.path.join(str(ctx.path.get_bld()), buildtype, '_templates')
378    configs = { 'templates_path': templates }
379    rule = sphinx_cmdline(ctx, buildtype, conf_dir, doctrees, source_dir, output_dir, configs)
[0bc9c6d]380    ctx(
381        rule         = rule,
382        cwd          = ctx.path,
[8e8094a]383        source       = ctx.path.ant_glob('**/*.rst') + extra_source,
[5ce8e43]384        depends_on   = resources,
[0bc9c6d]385        target       = ctx.path.find_or_declare('%s/index.html' % buildtype),
386        install_path = None
387    )
388    ctx.install_files('${PREFIX}/%s' % (ctx.path.name),
389                      output_node.ant_glob('**/*', quiet = True),
390                      cwd = output_node,
391                      relative_trick = True,
392                      quiet = True)
[a316b1f]393
[21c1a44]394def images_plantuml(ctx, source_dir, conf_dir, ext):
395    #
396    # Use a run command to handle stdout and stderr output from puml.
397    #
398    def run(task):
399        src = task.inputs[0].abspath()
400        tgt = task.outputs[0].abspath()
401        cmd = '%s generate %s -o %s' % (task.env.BIN_PUML[0], src, tgt)
402        so = open(tgt + '.out', 'w')
403        r = task.exec_command(cmd, stdout = so, stderr = so)
404        so.close()
405        return r
406
407    for src in ctx.path.ant_glob('**/*' + ext):
[4407039]408        tgt = src.change_ext('.png')
[21c1a44]409        ctx(
410            rule         = run,
411            inliner      = ctx.env.BIN_PUML,
412            source       = src,
413            target       = tgt,
414            install_path = None
[a3b0a40]415        )
[21c1a44]416
[8e8094a]417def cmd_build(ctx, extra_source = []):
[0263581]418    conf_dir = ctx.path.get_src()
419    source_dir = ctx.path.get_src()
[170418a]420
[0bc9c6d]421    if ctx.env.BUILD_PDF == 'yes':
[8e8094a]422        doc_pdf(ctx, source_dir, conf_dir, extra_source)
[a316b1f]423
[0bc9c6d]424    if ctx.env.BUILD_SINGLEHTML == 'yes':
[8e8094a]425        doc_singlehtml(ctx, source_dir, conf_dir, extra_source)
[9b5801a]426
[8e8094a]427    doc_html(ctx, source_dir, conf_dir, extra_source)
[a316b1f]428
[21c1a44]429def cmd_build_images(ctx):
430    conf_dir = ctx.path.get_src()
431    source_dir = ctx.path.get_src()
432    if ctx.env.BUILD_PLANTUML == 'yes':
433        images_plantuml(ctx, source_dir, conf_dir, '.puml')
434    if ctx.env.BUILD_DITAA == 'yes':
435        images_plantuml(ctx, source_dir, conf_dir, '.ditaa')
436
[0bc9c6d]437def cmd_options(ctx):
[9330bfb]438    ctx.add_option('--disable-extra-fonts',
439                   action = 'store_true',
440                   default = False,
441                   help = "Disable building with extra fonts for better quality (lower quality).")
[62efd4c]442    ctx.add_option('--sphinx-options',
[0bc9c6d]443                   action = 'store',
[62efd4c]444                   default = "",
445                   help = "Additional Sphinx options.")
446    ctx.add_option('--sphinx-nit-pick',
447                   action = 'store_true',
448                   default = False,
449                   help = "Enable Sphinx nit-picky mode else be quiet")
[0bc9c6d]450    ctx.add_option('--pdf',
[228560f]451                   action = 'store_true',
[0bc9c6d]452                   default = False,
453                   help = "Build PDF.")
454    ctx.add_option('--singlehtml',
[228560f]455                   action = 'store_true',
[0bc9c6d]456                   default = False,
457                   help = "Build Single HTML file, requires Node Inliner")
[21c1a44]458    ctx.add_option('--plantuml',
459                   action = 'store_true',
460                   default = False,
461                   help = "Build PlantUML images from source, need puml from npm")
462    ctx.add_option('--ditaa',
463                   action = 'store_true',
464                   default = False,
465                   help = "Build DITAA images using PlantUML from source, need ditaa and puml")
[5daabd2]466
[3a71759]467def cmd_options_path(ctx):
[0bc9c6d]468    cmd_options(ctx)
469    ctx.add_option('--rtems-path-py',
470                   type = 'string',
471                   help = "Full path to py/ in RTEMS source repository.")
[3a71759]472
473def cmd_configure_path(ctx):
[0bc9c6d]474    if not ctx.options.rtems_path_py:
475        ctx.fatal("--rtems-path-py is required")
[3a71759]476
[0bc9c6d]477    ctx.env.RTEMS_PATH = ctx.options.rtems_path_py
[3a71759]478
[0bc9c6d]479    cmd_configure(ctx)
[3a71759]480
[f97be09]481def xml_catalogue(ctx, building):
[782b4fe]482    #
483    # The following is a hack to find the top_dir because the task does
484    # provided a reference to top_dir like a build context.
485    #
486    top_dir = ctx.get_cwd().find_node('..')
[1a9b02e]487    #
488    # Read the conf.py files in each directory to gather the doc details.
489    #
[782b4fe]490    catalogue = {}
[1a9b02e]491    sp = sys.path[:]
[782b4fe]492    for doc in building:
493        #
494        # Import using the imp API so the module is reloaded for us.
495        #
496        import imp
[a7dc083]497        sys.path = [top_dir.find_node(doc).abspath()]
[782b4fe]498        mf = imp.find_module('conf')
[feb6832]499        sys.path = sp[:]
[782b4fe]500        try:
501            bconf = imp.load_module('bconf', mf[0], mf[1], mf[2])
502        finally:
503            mf[0].close()
504        catalogue[doc] = {
505            'title': bconf.project,
[f97be09]506            'version': str(ctx.env.VERSION),
507            'release': str(ctx.env.VERSION),
[782b4fe]508            'pdf': bconf.latex_documents[0][1].replace('.tex', '.pdf'),
509            'html': '%s/index.html' % (doc),
510            'singlehtml': '%s.html' % (doc)
511        }
512        bconf = None
[1a9b02e]513
514    import xml.dom.minidom as xml
515    cat = xml.Document()
516
517    root = cat.createElement('rtems-docs')
[3202e31]518    root.setAttribute('date', ctx.env.DATE)
[1a9b02e]519    cat.appendChild(root)
520
[9aa52b9]521    heading = cat.createElement('catalogue')
[f97be09]522    text = cat.createTextNode(str(ctx.env.VERSION))
[9aa52b9]523    heading.appendChild(text)
524    root.appendChild(heading)
525
[782b4fe]526    builds = ['html']
527    if ctx.env.BUILD_PDF == 'yes':
528        builds += ['pdf']
529    if ctx.env.BUILD_SINGLEHTML == 'yes':
530        builds += ['singlehtml']
531
532    for d in building:
[1a9b02e]533        doc = cat.createElement('doc')
534        name = cat.createElement('name')
535        text = cat.createTextNode(d)
536        name.appendChild(text)
537        title = cat.createElement('title')
[782b4fe]538        text = cat.createTextNode(catalogue[d]['title'])
[1a9b02e]539        title.appendChild(text)
540        release = cat.createElement('release')
[782b4fe]541        text = cat.createTextNode(catalogue[d]['release'])
[1a9b02e]542        release.appendChild(text)
543        version = cat.createElement('version')
[782b4fe]544        text = cat.createTextNode(catalogue[d]['version'])
[1a9b02e]545        version.appendChild(text)
546        doc.appendChild(name)
547        doc.appendChild(title)
548        doc.appendChild(release)
549        doc.appendChild(version)
[782b4fe]550        for b in builds:
[1a9b02e]551            output = cat.createElement(b)
[782b4fe]552            text = cat.createTextNode(catalogue[d][b])
[1a9b02e]553            output.appendChild(text)
554            doc.appendChild(output)
555        root.appendChild(doc)
556
[782b4fe]557    catnode = ctx.get_cwd().make_node('catalogue.xml')
[1a9b02e]558    catnode.write(cat.toprettyxml(indent = ' ' * 2, newl = os.linesep))
559
560    cat.unlink()
Note: See TracBrowser for help on using the repository browser.