summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2016-08-05 18:53:07 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2016-08-05 18:53:07 +0000
commit1e38ca42c51f546527b33e0065d16ab24c36ce89 (patch)
tree9e220c6b07a87255f1584d745a093d5dd46b784e
parentc73ab617c0d090ab29d3ef9a940abe435cbcb51b (diff)
downloadpyparsing-1e38ca42c51f546527b33e0065d16ab24c36ce89.tar.gz
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
-rw-r--r--src/CHANGES8
-rw-r--r--src/pyparsing.py16
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: