summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2018-11-02 14:05:51 +1100
committerChris Johns <chrisj@rtems.org>2018-11-03 16:36:32 +1100
commit21c1a4492a6c437d057c3af605278e9ba5edcac0 (patch)
treeccb1a3b5d51c57af2aad3621220102b03344ea03
parentUser: Simplify the top level headings. (diff)
downloadrtems-docs-21c1a4492a6c437d057c3af605278e9ba5edcac0.tar.bz2
waf: Add support to build PlantUML and Ditaa images.
-rw-r--r--README.txt17
-rw-r--r--common/waf.py70
-rw-r--r--images/.gitignore1
-rw-r--r--images/wscript7
-rw-r--r--wscript6
5 files changed, 99 insertions, 2 deletions
diff --git a/README.txt b/README.txt
index a7380a9..203c45d 100644
--- a/README.txt
+++ b/README.txt
@@ -115,6 +115,16 @@ Single HTML:
# pkg install npm
# npm install -g inliner
+Plant UML:
+
+Install NPM as shown in Single HTML then:
+
+ # npm install -g node-plantuml
+
+Ditaa:
+
+ # pkg install ditaa
+
CentOS 6 and 7
~~~~~~~~~~~~~~
@@ -151,10 +161,15 @@ Single HTML:
NOTE: npm appears to be part of the EPEL repository for RHEL and CentOS.
You may have to add that repository to your configuration.
-
# yum install npm
# npm install -g inliner
+Plant UML:
+
+Install NPM as shown in Single HTML then:
+
+ # npm install -g node-plantuml
+
Spell check:
# yum install aspell
diff --git a/common/waf.py b/common/waf.py
index 3f0fcc1..692d4de 100644
--- a/common/waf.py
+++ b/common/waf.py
@@ -257,9 +257,37 @@ def cmd_configure(ctx):
ctx.env.BUILD_SINGLEHTML = 'yes'
ctx.find_program("inliner", var = "BIN_INLINER", mandatory = False)
if not ctx.env.BIN_INLINER:
- ctx.fatal("Node inliner is required install with 'npm install -g inliner' " +
+ ctx.fatal("Node.js inliner is required install with 'npm install -g inliner' " +
"(https://github.com/remy/inliner)")
+ ctx.envBUILD_PLANTUML = 'no'
+ if ctx.options.plantuml:
+ check_plantuml = not ctx.env.BIN_PUML
+ if check_plantuml:
+ ctx.env.BUILD_PLANTUML = 'yes'
+ ctx.find_program("puml", var = "BIN_PUML", mandatory = False)
+ if not ctx.env.BIN_PUML:
+ ctx.fatal("Node.js puml is required install with 'npm install -g node-plantuml' " +
+ "(https://www.npmjs.com/package/node-plantuml)")
+
+ ctx.envBUILD_DITAA = 'no'
+ if ctx.options.ditaa:
+ #
+ # We use DITAA via PlantUML
+ #
+ if not ctx.env.BIN_PUML:
+ ctx.find_program("puml", var = "BIN_PUML", mandatory = False)
+ if not ctx.env.BIN_PUML:
+ ctx.fatal("DITAA uses PlantUML; " +
+ "Node.js puml is required install with 'npm install -g node-plantuml' " +
+ "(https://www.npmjs.com/package/node-plantuml)")
+ check_ditaa = not ctx.env.BIN_DITAA
+ if check_ditaa:
+ ctx.env.BUILD_DITAA = 'yes'
+ ctx.find_program("ditaa", var = "BIN_DITAA", mandatory = False)
+ if not ctx.env.BIN_DITAA:
+ ctx.fatal("DITAA not found, plase install")
+
def doc_pdf(ctx, source_dir, conf_dir, extra_source):
buildtype = 'latex'
build_dir, output_node, output_dir, doctrees = build_dir_setup(ctx, buildtype)
@@ -353,6 +381,30 @@ def doc_html(ctx, source_dir, conf_dir, extra_source):
relative_trick = True,
quiet = True)
+def images_plantuml(ctx, source_dir, conf_dir, ext):
+ #
+ # Use a run command to handle stdout and stderr output from puml.
+ #
+ def run(task):
+ src = task.inputs[0].abspath()
+ tgt = task.outputs[0].abspath()
+ cmd = '%s generate %s -o %s' % (task.env.BIN_PUML[0], src, tgt)
+ so = open(tgt + '.out', 'w')
+ r = task.exec_command(cmd, stdout = so, stderr = so)
+ so.close()
+ return r
+
+ for src in ctx.path.ant_glob('**/*' + ext):
+ tgt = src.abspath()[: - len(ext)] + '.png'
+ ctx(
+ rule = run,
+ inliner = ctx.env.BIN_PUML,
+ source = src,
+ target = tgt,
+ install_path = None
+ )
+
+
def cmd_build(ctx, extra_source = []):
conf_dir = ctx.path.get_src()
source_dir = ctx.path.get_src()
@@ -365,6 +417,14 @@ def cmd_build(ctx, extra_source = []):
doc_html(ctx, source_dir, conf_dir, extra_source)
+def cmd_build_images(ctx):
+ conf_dir = ctx.path.get_src()
+ source_dir = ctx.path.get_src()
+ if ctx.env.BUILD_PLANTUML == 'yes':
+ images_plantuml(ctx, source_dir, conf_dir, '.puml')
+ if ctx.env.BUILD_DITAA == 'yes':
+ images_plantuml(ctx, source_dir, conf_dir, '.ditaa')
+
def cmd_options(ctx):
ctx.add_option('--disable-extra-fonts',
action = 'store_true',
@@ -382,6 +442,14 @@ def cmd_options(ctx):
action = 'store_true',
default = False,
help = "Build Single HTML file, requires Node Inliner")
+ ctx.add_option('--plantuml',
+ action = 'store_true',
+ default = False,
+ help = "Build PlantUML images from source, need puml from npm")
+ ctx.add_option('--ditaa',
+ action = 'store_true',
+ default = False,
+ help = "Build DITAA images using PlantUML from source, need ditaa and puml")
def cmd_options_path(ctx):
cmd_options(ctx)
diff --git a/images/.gitignore b/images/.gitignore
new file mode 100644
index 0000000..f47cb20
--- /dev/null
+++ b/images/.gitignore
@@ -0,0 +1 @@
+*.out
diff --git a/images/wscript b/images/wscript
new file mode 100644
index 0000000..41a9308
--- /dev/null
+++ b/images/wscript
@@ -0,0 +1,7 @@
+from sys import path
+from os.path import abspath
+path.append(abspath('../common/'))
+
+from waf import cmd_configure as configure
+from waf import cmd_build_images as build
+from waf import cmd_options as options
diff --git a/wscript b/wscript
index 8fd22ac..5ce7f0d 100644
--- a/wscript
+++ b/wscript
@@ -53,6 +53,12 @@ def coverpage_js(ctx):
o.write(js.replace('@CATALOGUE', xml))
def build(ctx):
+ #
+ # Generate any PlantUML images if enabled.
+ #
+ ctx.recurse('images')
+ ctx.add_group('images')
+
for b in building:
ctx.recurse(b)