2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-26 11:51:20 +01:00

extras: rst: extend parse_rst_node()

This commit is contained in:
Jérôme Carretero 2016-01-30 13:06:44 -05:00
parent 2999a120a1
commit c923c31031

View File

@ -36,8 +36,11 @@ from waflib.TaskGen import feature, before_method
rst_progs = "rst2html rst2xetex rst2latex rst2xml rst2pdf rst2s5 rst2man rst2odt rst2rtf".split()
def parse_rst_node(node, nodes, names, seen):
def parse_rst_node(task, node, nodes, names, seen, dirs=None):
# TODO add extensibility, to handle custom rst include tags...
if dirs is None:
dirs = (node.parent,node.get_bld().parent)
if node in seen:
return
seen.append(node)
@ -47,12 +50,17 @@ def parse_rst_node(node, nodes, names, seen):
ipath = match.group('file')
itype = match.group('type')
Logs.debug("rst: visiting %s: %s" % (itype, ipath))
found = node.parent.find_resource(ipath)
found = False
for d in dirs:
Logs.debug("rst: looking for %s in %s" % (ipath, d.abspath()))
found = d.find_node(ipath)
if found:
Logs.debug("rst: found %s as %s" % (ipath, found.abspath()))
nodes.append(found)
if itype == 'include':
parse_rst_node(found, nodes, names, seen)
else:
parse_rst_node(task, found, nodes, names, seen)
break
if not found:
names.append(ipath)
class docutils(Task.Task):
@ -74,7 +82,7 @@ class docutils(Task.Task):
if not node:
return (nodes, names)
parse_rst_node(node, nodes, names, seen)
parse_rst_node(self, node, nodes, names, seen)
Logs.debug("rst: %s: found the following file deps: %s" % (repr(self), nodes))
if names: