def parse_rst_node(node, nodes, names, seen):
# TODO add extensibility, to handle custom rst include tags...
if node in seen:
return
seen.append(node)
code = node.read()
re_rst = re.compile(r'^\s*.. ((?P<subst>\|\S+\|) )?(?P<type>include|image|figure):: (?P<file>.*)$', re.M)
for match in re_rst.finditer(code):
ipath = match.group('file')
itype = match.group('type')
Logs.debug("rst: visiting %s: %s" % (itype, ipath))
found = node.parent.find_resource(ipath)
if found:
nodes.append(found)
if itype == 'include':
parse_rst_node(found, nodes, names, seen)
else:
names.append(ipath)
评论列表
文章目录