Browse Source

Merge pull request #373 from fbindel/pydot-more-attributes

Allow any graph attribute in `pydot__tree_to_png`.
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.7.2
Erez Shinan 6 years ago
committed by GitHub
parent
commit
29ef3efeb9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      lark/tree.py

+ 6
- 4
lark/tree.py View File

@@ -141,17 +141,19 @@ class SlottedTree(Tree):
__slots__ = 'data', 'children', 'rule', '_meta' __slots__ = 'data', 'children', 'rule', '_meta'




def pydot__tree_to_png(tree, filename, rankdir="LR"):
def pydot__tree_to_png(tree, filename, rankdir="LR", **kwargs):
"""Creates a colorful image that represents the tree (data+children, without meta) """Creates a colorful image that represents the tree (data+children, without meta)


Possible values for `rankdir` are "TB", "LR", "BT", "RL", corresponding to Possible values for `rankdir` are "TB", "LR", "BT", "RL", corresponding to
directed graphs drawn from top to bottom, from left to right, from bottom to directed graphs drawn from top to bottom, from left to right, from bottom to
top, and from right to left, respectively. See:
https://www.graphviz.org/doc/info/attrs.html#k:rankdir
top, and from right to left, respectively.

`kwargs` can be any graph attribute (e. g. `dpi=200`). For a list of
possible attributes, see https://www.graphviz.org/doc/info/attrs.html.
""" """


import pydot import pydot
graph = pydot.Dot(graph_type='digraph', rankdir=rankdir)
graph = pydot.Dot(graph_type='digraph', rankdir=rankdir, **kwargs)


i = [0] i = [0]




Loading…
Cancel
Save