alogos._grammar.visualization.grammar_with_railroad

Classes

GrammarFigure

Data structure for wrapping, displaying and exporting a Grammar figure.

Functions

create_syntax_diagram(grammar)

Create a figure of a syntax diagram that represents the grammar.


Detailed object descriptions

alogos._grammar.visualization.grammar_with_railroad.create_syntax_diagram(grammar)[source]

Create a figure of a syntax diagram that represents the grammar.

References

class alogos._grammar.visualization.grammar_with_railroad.GrammarFigure(html_template)[source]

Data structure for wrapping, displaying and exporting a Grammar figure.

__init__(self, html_template)[source]

Initialize a figure with a partly filled HTML template containing a visualization.

display(self, inline=False)[source]

Display the plot in a webbrowser or as IPython rich display representation.

Parameters:

inline (bool) – If True, the plot will be shown inline in a Jupyter notebook.

property html_text(self)

Create a HTML text representation.

property html_text_standalone(self)

Create a standalone HTML text representation.

property html_text_partial(self)

Create a partial HTML text representation without html, head and body tags.

export_html(self, filepath)[source]

Export the plot as HTML file.

Parameters:

filepath (str) – Filepath of the created HTML file. If the file exists it will be overwritten without warning. If the path does not end with “.html” it will be changed to do so. If the parent directory does not exist it will be created.

Returns:

filepath (str) – Filepath of the generated HTML file, guaranteed to end with “.html”.