changeset 576:b00765a115a5 trunk

Improve docs on `Stream.select()` for #135.
author cmlenz
date Mon, 23 Jul 2007 09:50:44 +0000
parents d2e7fc367384
children e86edca143fb
files genshi/core.py genshi/filters/html.py genshi/filters/i18n.py genshi/filters/transform.py
diffstat 4 files changed, 36 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/genshi/core.py
+++ b/genshi/core.py
@@ -166,6 +166,27 @@
         """Return a new stream that contains the events matching the given
         XPath expression.
         
+        >>> from genshi import HTML
+        >>> stream = HTML('<doc><elem>foo</elem><elem>bar</elem></doc>')
+        >>> print stream.select('elem')
+        <elem>foo</elem><elem>bar</elem>
+        >>> print stream.select('elem/text()')
+        foobar
+        
+        Note that the outermost element of the stream becomes the *context
+        node* for the XPath test. That means that the expression "doc" would
+        not match anything in the example above, because it only tests against
+        child elements of the outermost element:
+        
+        >>> print stream.select('doc')
+        <BLANKLINE>
+        
+        You can use the "." expression to match the context node itself
+        (although that usually makes little sense):
+        
+        >>> print stream.select('.')
+        <doc><elem>foo</elem><elem>bar</elem></doc>
+        
         :param path: a string containing the XPath expression
         :param namespaces: mapping of namespace prefixes used in the path
         :param variables: mapping of variable names to values
--- a/genshi/filters/html.py
+++ b/genshi/filters/html.py
@@ -321,6 +321,7 @@
         :param uri: the URI to check
         :return: `True` if the URI can be considered safe, `False` otherwise
         :rtype: `bool`
+        :since: version 0.4.3
         """
         if ':' not in uri:
             return True # This is a relative URI
@@ -354,6 +355,7 @@
                      contain any character or numeric references
         :return: a list of declarations that are considered safe
         :rtype: `list`
+        :since: version 0.4.3
         """
         decls = []
         text = self._strip_css_comments(self._replace_unicode_escapes(text))
--- a/genshi/filters/i18n.py
+++ b/genshi/filters/i18n.py
@@ -11,7 +11,10 @@
 # individuals. For the exact contribution history, see the revision
 # history and logs, available at http://genshi.edgewall.org/log/.
 
-"""Utilities for internationalization and localization of templates."""
+"""Utilities for internationalization and localization of templates.
+
+:since: version 0.4
+"""
 
 from compiler import ast
 try:
@@ -321,7 +324,10 @@
 
 
 class MessageBuffer(object):
-    """Helper class for managing localizable mixed content."""
+    """Helper class for managing localizable mixed content.
+    
+    :since: version 0.5
+    """
 
     def __init__(self, lineno=-1):
         self.lineno = lineno
@@ -385,6 +391,7 @@
     :param code: the `Code` object
     :type code: `genshi.template.eval.Code`
     :param gettext_functions: a sequence of function names
+    :since: version 0.5
     """
     def _walk(node):
         if isinstance(node, ast.CallFunc) and isinstance(node.node, ast.Name) \
@@ -421,6 +428,8 @@
     
     >>> parse_msg("[1:] Bilder pro Seite anzeigen.")
     [(1, ''), (0, ' Bilder pro Seite anzeigen.')]
+    
+    :since: version 0.5
     """
     parts = []
     stack = [0]
--- a/genshi/filters/transform.py
+++ b/genshi/filters/transform.py
@@ -43,6 +43,8 @@
 
 The ``Transformer`` support a large number of useful transformations out of the
 box, but custom transformations can be added easily.
+
+:since: version 0.5
 """
 
 import re
Copyright (C) 2012-2017 Edgewall Software