From 508750e836c67f95856824b97d3893c6009dda8f Mon Sep 17 00:00:00 2001 From: Paul McGuire Date: Wed, 19 Aug 2020 22:42:25 -0500 Subject: Convert SyntaxWarnings to ValueError and TypeError exceptions; change diagnostics to an enum, and add enable_diag(), disable_diag() and enable_all_warnings() methods; clean up pyparsing imports in test_unit.py --- docs/HowToUsePyparsing.rst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/HowToUsePyparsing.rst b/docs/HowToUsePyparsing.rst index 88bb8be..4e3c24b 100644 --- a/docs/HowToUsePyparsing.rst +++ b/docs/HowToUsePyparsing.rst @@ -77,7 +77,7 @@ The parsed tokens are returned in the following form:: ['Hello', ',', 'World', '!'] ['Bonjour', ',', 'Monde', '!'] ['Hola', ',', 'Mundo', '!'] - ['Gutentag', ',', 'Welt', '!'] + ['Hallo', ',', 'Welt', '!'] Usage notes @@ -809,7 +809,7 @@ Exception classes and Troubleshooting and ``setDebug()``, or test the matching of expression fragments by testing them using ``searchString()`` or ``scanString()``. -- Diagnostics can be enabled using ``pyparsing.enable_diagnostic`` and passing +- Diagnostics can be enabled using ``pyparsing.enable_diag`` and passing one of the following enum values defined in ``pyparsing.Diagnostics`` - ``warn_multiple_tokens_in_named_alternation`` - flag to enable warnings when a results @@ -834,6 +834,17 @@ Exception classes and Troubleshooting - ``enable_debug_on_named_expressions`` - flag to auto-enable debug on all subsequent calls to ``ParserElement.setName`` + All warnings can be enabled by calling ``pyparsing.enable_all_warnings()``. + Sample:: + + import pyparsing as pp + pp.enable_all_warnings() + + fwd = pp.Forward().setResultsName("recursive_expr") + + >>> UserWarning: warn_name_set_on_empty_Forward: setting results name 'recursive_expr' + on Forward expression that has no contained expression + Miscellaneous attributes and methods ==================================== -- cgit v1.2.1