summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2021-10-22 16:09:45 -0500
committerptmcg <ptmcg@austin.rr.com>2021-10-22 16:09:45 -0500
commita6f335f578ae5b44ab1f17e816e07ffbf17f3131 (patch)
tree1869721daaa79e01fb04919396a55ea9ee6be4e2 /docs
parent05b777b9c087da69603069865b13a87198e8f071 (diff)
downloadpyparsing-git-a6f335f578ae5b44ab1f17e816e07ffbf17f3131.tar.gz
Add some usage tips for diagramming to HowToUsePyparsing.rst; update date and e-mail
Diffstat (limited to 'docs')
-rw-r--r--docs/HowToUsePyparsing.rst20
1 files changed, 17 insertions, 3 deletions
diff --git a/docs/HowToUsePyparsing.rst b/docs/HowToUsePyparsing.rst
index 0cb2668..69f6ad5 100644
--- a/docs/HowToUsePyparsing.rst
+++ b/docs/HowToUsePyparsing.rst
@@ -3,10 +3,10 @@ Using the pyparsing module
==========================
:author: Paul McGuire
-:address: ptmcg@users.sourceforge.net
+:address: ptmcg.pm+pyparsing@gmail.com
-:revision: 3.0.1
-:date: September, 2021
+:revision: 3.0.0
+:date: October, 2021
:copyright: Copyright |copy| 2003-2021 Paul McGuire.
@@ -1246,11 +1246,25 @@ Create your parser as you normally would. Then call ``create_diagram()``, passin
This will result in the railroad diagram being written to ``street_address_diagram.html``.
+Diagrams usually will vertically wrap expressions containing more than 3 terms. You can override this by
+passing the `vertical` argument to `create_diagram` with a larger value.
+
Example
-------
You can view an example railroad diagram generated from `a pyparsing grammar for
SQL SELECT statements <_static/sql_railroad.html>`_.
+Naming tip
+----------
+Parser elements that are separately named will be broken out as their own sub-diagrams. As a short-cut alternative
+to going through and adding ``.set_name()`` calls on all your sub-expressions, you can include this snippet after
+defining your complete grammar::
+
+ # iterate over all locals, and call set_name on those that are ParserElements
+ for name, value in list(locals().items()):
+ if isinstance(value, ParserElement):
+ value.set_name(name)
+
Customization
-------------
You can customize the resulting diagram in a few ways.