[Git][NTPsec/ntpsec][master] Add a scanner for building the manpages.
Amar Takhar
gitlab at mg.gitlab.com
Fri Nov 20 17:26:14 UTC 2015
Amar Takhar pushed to branch master at NTPsec / ntpsec
Commits:
d9ef3dec by Amar Takhar at 2015-11-20T12:25:21Z
Add a scanner for building the manpages.
* This allows for rebuilding of manpages when the includes are edited.
- - - - -
2 changed files:
- pylib/asciidoc.py
- pylib/util.py
Changes:
=====================================
pylib/asciidoc.py
=====================================
--- a/pylib/asciidoc.py
+++ b/pylib/asciidoc.py
@@ -1,8 +1,10 @@
-# asciidoc -b html5 -a linkcss -a stylesdir=/mnt/devel/ntp/commit/docs -o asd driver32.txt
-
+from util import ascii_doc_scan
from waflib import Task
from waflib.TaskGen import extension
+# asciidoc -b html5 -a linkcss -a stylesdir=/mnt/devel/ntp/commit/docs -o asd driver32.txt
+
+
# ASCIIDOC_FLAGS are almost always needed and need to be set by the user.
class asciidoc(Task.Task):
color = "BLUE"
@@ -21,7 +23,7 @@ class a2x(Task.Task):
color = "YELLOW"
shell = True
run_str = '${BIN_A2X} ${A2X_FLAGS} ${SRC[0].abspath()}'
-
+ scan = ascii_doc_scan
@extension('.man-tmp')
def run_a2x(self, node):
=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -1,4 +1,5 @@
from waflib.Logs import pprint
+import re
def msg(str):
pprint("YELLOW", str)
@@ -7,3 +8,35 @@ def msg_setting(name, val):
pprint("NORMAL", " %-30s: " % name, sep="")
pprint("YELLOW", val)
+# Borrowed from waf/docs/book/wscript in the Waf Project.
+re_xi = re.compile('''^(include|image)::(.*?.(txt|\\{PIC\\}))\[''', re.M)
+def ascii_doc_scan(self):
+ p = self.inputs[0].parent
+ node_lst = [self.inputs[0]]
+ seen = []
+ depnodes = []
+
+ while node_lst:
+ nd = node_lst.pop(0)
+ if nd in seen: continue
+ seen.append(nd)
+
+ code = nd.read()
+ for m in re_xi.finditer(code):
+ name = m.group(2)
+ if m.group(3) == '{PIC}':
+
+ ext = '.eps'
+ if self.generator.rule.rfind('A2X') > 0:
+ ext = '.png'
+
+ k = p.find_resource(name.replace('{PIC}', ext))
+ if k:
+ depnodes.append(k)
+ else:
+ k = self.inputs[0].find_resource(name)
+ if k:
+ depnodes.append(k)
+ node_lst.append(k)
+ return [depnodes, ()]
+
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/d9ef3dece3d7b2a0f87ee67828ef150c5b98b391
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151120/e6019a90/attachment.html>
More information about the vc
mailing list