Changeset 21c1a44 in rtems-docs


Ignore:
Timestamp:
11/02/18 03:05:51 (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
5, master
Children:
8b67c91
Parents:
bb13624
git-author:
Chris Johns <chrisj@…> (11/02/18 03:05:51)
git-committer:
Chris Johns <chrisj@…> (11/03/18 05:36:32)
Message:

waf: Add support to build PlantUML and Ditaa images.

Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • README.txt

    rbb13624 r21c1a44  
    115115  # pkg install npm
    116116  # npm install -g inliner
     117
     118Plant UML:
     119
     120Install NPM as shown in Single HTML then:
     121
     122  # npm install -g node-plantuml
     123
     124Ditaa:
     125
     126  # pkg install ditaa
    117127
    118128CentOS 6 and 7
     
    152162You may have to add that repository to your configuration.
    153163
    154 
    155164  # yum install npm
    156165  # npm install -g inliner
     166
     167Plant UML:
     168
     169Install NPM as shown in Single HTML then:
     170
     171  # npm install -g node-plantuml
    157172
    158173Spell check:
  • common/waf.py

    rbb13624 r21c1a44  
    258258            ctx.find_program("inliner", var = "BIN_INLINER", mandatory = False)
    259259            if not ctx.env.BIN_INLINER:
    260                 ctx.fatal("Node inliner is required install with 'npm install -g inliner' " +
     260                ctx.fatal("Node.js inliner is required install with 'npm install -g inliner' " +
    261261                          "(https://github.com/remy/inliner)")
     262
     263    ctx.envBUILD_PLANTUML = 'no'
     264    if ctx.options.plantuml:
     265        check_plantuml = not ctx.env.BIN_PUML
     266        if check_plantuml:
     267            ctx.env.BUILD_PLANTUML = 'yes'
     268            ctx.find_program("puml", var = "BIN_PUML", mandatory = False)
     269            if not ctx.env.BIN_PUML:
     270                ctx.fatal("Node.js puml is required install with 'npm install -g node-plantuml' " +
     271                          "(https://www.npmjs.com/package/node-plantuml)")
     272
     273    ctx.envBUILD_DITAA = 'no'
     274    if ctx.options.ditaa:
     275        #
     276        # We use DITAA via PlantUML
     277        #
     278        if not ctx.env.BIN_PUML:
     279            ctx.find_program("puml", var = "BIN_PUML", mandatory = False)
     280            if not ctx.env.BIN_PUML:
     281                ctx.fatal("DITAA uses PlantUML; " +
     282                          "Node.js puml is required install with 'npm install -g node-plantuml' " +
     283                          "(https://www.npmjs.com/package/node-plantuml)")
     284        check_ditaa = not ctx.env.BIN_DITAA
     285        if check_ditaa:
     286            ctx.env.BUILD_DITAA = 'yes'
     287            ctx.find_program("ditaa", var = "BIN_DITAA", mandatory = False)
     288            if not ctx.env.BIN_DITAA:
     289                ctx.fatal("DITAA not found, plase install")
    262290
    263291def doc_pdf(ctx, source_dir, conf_dir, extra_source):
     
    354382                      quiet = True)
    355383
     384def images_plantuml(ctx, source_dir, conf_dir, ext):
     385    #
     386    # Use a run command to handle stdout and stderr output from puml.
     387    #
     388    def run(task):
     389        src = task.inputs[0].abspath()
     390        tgt = task.outputs[0].abspath()
     391        cmd = '%s generate %s -o %s' % (task.env.BIN_PUML[0], src, tgt)
     392        so = open(tgt + '.out', 'w')
     393        r = task.exec_command(cmd, stdout = so, stderr = so)
     394        so.close()
     395        return r
     396
     397    for src in ctx.path.ant_glob('**/*' + ext):
     398        tgt = src.abspath()[: - len(ext)] + '.png'
     399        ctx(
     400            rule         = run,
     401            inliner      = ctx.env.BIN_PUML,
     402            source       = src,
     403            target       = tgt,
     404            install_path = None
     405    )
     406
     407
    356408def cmd_build(ctx, extra_source = []):
    357409    conf_dir = ctx.path.get_src()
     
    365417
    366418    doc_html(ctx, source_dir, conf_dir, extra_source)
     419
     420def cmd_build_images(ctx):
     421    conf_dir = ctx.path.get_src()
     422    source_dir = ctx.path.get_src()
     423    if ctx.env.BUILD_PLANTUML == 'yes':
     424        images_plantuml(ctx, source_dir, conf_dir, '.puml')
     425    if ctx.env.BUILD_DITAA == 'yes':
     426        images_plantuml(ctx, source_dir, conf_dir, '.ditaa')
    367427
    368428def cmd_options(ctx):
     
    383443                   default = False,
    384444                   help = "Build Single HTML file, requires Node Inliner")
     445    ctx.add_option('--plantuml',
     446                   action = 'store_true',
     447                   default = False,
     448                   help = "Build PlantUML images from source, need puml from npm")
     449    ctx.add_option('--ditaa',
     450                   action = 'store_true',
     451                   default = False,
     452                   help = "Build DITAA images using PlantUML from source, need ditaa and puml")
    385453
    386454def cmd_options_path(ctx):
  • wscript

    rbb13624 r21c1a44  
    5454
    5555def build(ctx):
     56    #
     57    # Generate any PlantUML images if enabled.
     58    #
     59    ctx.recurse('images')
     60    ctx.add_group('images')
     61
    5662    for b in building:
    5763        ctx.recurse(b)
Note: See TracChangeset for help on using the changeset viewer.