def render(self, tree, divert=False, fixposition=False):
'''Renders a tree.
Args:
tree (fypp-tree): Tree to render.
divert (bool): Whether output will be diverted and sent for further
processing, so that no line numbering directives and
postprocessing are needed at this stage. (Default: False)
fixposition (bool): Whether file name and line position (variables
_FILE_ and _LINE_) should be kept at their current values or
should be updated continuously. (Default: False).
Returns: str: Rendered string.
'''
diverted = self._diverted
self._diverted = divert
fixedposition = self._fixedposition
self._fixedposition = fixposition
output, eval_inds, eval_pos = self._render(tree)
if not self._diverted and eval_inds:
self._postprocess_eval_lines(output, eval_inds, eval_pos)
self._diverted = diverted
self._fixedposition = fixedposition
txt = ''.join(output)
return txt
评论列表
文章目录