From 1e38ca42c51f546527b33e0065d16ab24c36ce89 Mon Sep 17 00:00:00 2001 From: ptmcg Date: Fri, 5 Aug 2016 18:53:07 +0000 Subject: Add inline examples to docstrings, so that reference docs will show sample code along with arg and usage descriptions - hopefully this will make them generally more useful, or at least a little less dry. git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@387 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b --- src/CHANGES | 8 ++++++++ src/pyparsing.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/CHANGES b/src/CHANGES index 823ad88..6cc9934 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -22,6 +22,14 @@ Version 2.1.6 - while the generic "number" is similar to the flexible number syntax in other languages. +- Major change to docs! After seeing some comments on reddit about + general issue with docs of Python modules, and thinking that I'm a + little overdue in doing some doc tuneup on pyparsing, I decided to + following the suggestions of the redditor and add more inline examples + to the pyparsing reference documentation. I hope this addition + will clarify some of the more common questions people have, especially + when first starting with pyparsing/Python. + - Deprecated ParseResults.asXML. I've never been too happy with this method, and it usually forces some unnatural code in the parsers in order to get decent tag names. The amount of guesswork that asXML diff --git a/src/pyparsing.py b/src/pyparsing.py index 0f658b0..29c9d14 100644 --- a/src/pyparsing.py +++ b/src/pyparsing.py @@ -3685,14 +3685,14 @@ def srange(s): srange("[a-z$_]") -> "abcdefghijklmnopqrstuvwxyz$_" The input string must be enclosed in []'s, and the returned string is the expanded character set joined into a single string. - The values enclosed in the []'s may be:: - a single character - an escaped character with a leading backslash (such as \- or \]) - an escaped hex character with a leading '\x' (\x21, which is a '!' character) - (\0x## is also supported for backwards compatibility) - an escaped octal character with a leading '\0' (\041, which is a '!' character) - a range of any of the above, separated by a dash ('a-z', etc.) - any combination of the above ('aeiouy', 'a-zA-Z0-9_$', etc.) + The values enclosed in the []'s may be: + - a single character + - an escaped character with a leading backslash (such as C{\-} or C{\]}) + - an escaped hex character with a leading C{'\x'} (C{\x21}, which is a C{'!'} character) + (C{\0x##} is also supported for backwards compatibility) + - an escaped octal character with a leading C{'\0'} (C{\041}, which is a C{'!'} character) + - a range of any of the above, separated by a dash (C{'a-z'}, etc.) + - any combination of the above (C{'aeiouy'}, C{'a-zA-Z0-9_$'}, etc.) """ _expanded = lambda p: p if not isinstance(p,ParseResults) else ''.join(unichr(c) for c in range(ord(p[0]),ord(p[1])+1)) try: -- cgit v1.2.1