# HG changeset patch
# User cmlenz
# Date 1151528994 0
# Node ID 1fdb7054fb42ed006e3d8b721b952ace1a7361b3
# Parent 2224a52256ca15c460ba635a417bdf94194a17d5
Add doctests for path module.
diff --git a/markup/path.py b/markup/path.py
--- a/markup/path.py
+++ b/markup/path.py
@@ -97,6 +97,15 @@
If there are no matches, this method returns an empty stream.
+ >>> from markup.input import XML
+ >>> xml = XML('Text')
+ >>> print Path('child').select(xml)
+ Text
+
+ >>> xpath = Path('child')
+ >>> print Path('child/text()').select(xml)
+ Text
+
@param stream: the stream to select from
@return: the substream matching the path, or an empty stream
"""
@@ -128,6 +137,15 @@
and `pos`, i.e. basically an unpacked stream event. If the path matches
the event, the function returns the match (for example, a `START` or
`TEXT` event.) Otherwise, it returns `None` or `False`.
+
+ >>> from markup.input import XML
+ >>> xml = XML('')
+ >>> test = Path('child').test()
+ >>> for kind, data, pos in xml:
+ ... if test(kind, data, pos):
+ ... print kind, data
+ START (u'child', [(u'id', u'1')])
+ START (u'child', [(u'id', u'2')])
"""
stack = [0] # stack of cursors into the location path