Changeset 2866:9ed77c797435 in livinglogic.python.xist

Show
Ignore:
Timestamp:
08/09/07 12:59:52 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Remove examples from module docstring. Add docstrings to Selector methods.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/xist/xfind.py

    r2856 r2866  
    1616be combined with various operations and form a language comparable to 
    1717<link href="http://www.w3.org/TR/xpath">XPath</link> but implemented as Python 
    18 expressions. The following code shows some 
    19 examples. First lets define some support code:</par> 
    20  
    21 <example><title>Support code (put in <filename>help.py</filename>)</title> 
    22 <prog> 
    23 from ll.xist import xsc, xfind, parsers 
    24 from ll.xist.ns import html 
    25  
    26 node = parsers.parseURL("http://www.python.org", tidy=True) 
    27  
    28 def output(selector): 
    29     for n in node.walknode(selector): 
    30         print n.bytes() 
    31 </prog> 
    32 </example> 
    33  
    34 <par>We can now use this code in a Python session via <lit>from help import *</lit>.</par> 
    35  
    36 <prog> 
    37 <prompt>>>> </prompt><input>output(html.a/html.img) # images children of a elements</input> 
    38 <![CDATA[<img src="/images/python-logo.gif" alt="homepage" id="logo" border="0" /> 
    39 <img id="skiptonav" alt="skip to navigation" src="/images/trans.gif" border="0" /> 
    40 <img id="skiptocontent" alt="skip to content" src="/images/trans.gif" border="0" /> 
    41 <img alt="success story photo" class="success" src="/images/success/nasa.jpg" />]]> 
    42  
    43 <prompt>>>> </prompt><input>output(html.ul//html.a) # a descendants of ul elements</input> 
    44 <![CDATA[<a title="About The Python Language" href="/about/">About</a> 
    45 <a title="Major Happenings Within the Python Community" href="/news/">News</a> 
    46 <a title="Tutorials, Library Reference, C API" href="/doc/">Documentation</a>]]> 
    47  
    48 <prompt>>>> </prompt><input>output(html.img & xfind.attrendswith("src", ".jpg")) # JPEG images</input> 
    49 <![CDATA[<img alt="success story photo" class="success" src="/images/success/nasa.jpg" />]]> 
    50  
    51 <prompt>>>> </prompt><input>output(html.img & ~xfind.hasattr("title")) # All images without a title attribute</input> 
    52 <![CDATA[<img src="/images/python-logo.gif" border="0" id="logo" alt="homepage" /> 
    53 <img id="skiptonav" border="0" src="/images/trans.gif" alt="skip to navigation" /> 
    54 <img id="skiptocontent" border="0" src="/images/trans.gif" alt="skip to content" /> 
    55 <img alt="success story photo" src="/images/success/nasa.jpg" class="success" />]]> 
    56  
    57 <prompt>>>> </prompt><input>output(html.a & xfind.hasclass("reference")) # Links with 'reference' class</input> 
    58 <![CDATA[<a class="reference" href="/search">Advanced Search</a> 
    59 <a href="about/success/rackspace" class="reference">Rackspace</a> 
    60 <a href="about/success/ilm" class="reference">Industrial Light and Magic</a>]]> 
    61  
    62 <prompt>>>> </prompt><input>output(html.ul/html.li[0]) # Every li element that is the first li child of its ul parent</input> 
    63 <![CDATA[<li> 
    64           <a title="About The Python Language" href="/about/">About</a> 
    65         </li> 
    66 <li><a title="Manuals for Latest Stable Release" href="http://docs.python.org/">Documentation</a></li> 
    67 <li class="group"><a href="http://wiki.python.org/moin/WebProgramming">Web Programming</a></li>]]> 
    68  
    69 </prog> 
     18expressions.</par> 
    7019""" 
    7120 
     
    11867 
    11968    def __div__(self, other): 
     69        """ 
     70        Create a <pyref class="ChildCombinator"><class>ChildCombinator</class> 
     71        with <self/> as the left hand selector and <arg>other</arg> as the right 
     72        hand selector. 
     73        """ 
    12074        return ChildCombinator(self, xsc.makewalkfilter(other)) 
    12175 
    12276    def __floordiv__(self, other): 
     77        """ 
     78        Create a <pyref class="DescendantCombinator"><class>DescendantCombinator</class> 
     79        with <self/> as the left hand selector and <arg>other</arg> as the right 
     80        hand selector. 
     81        """ 
    12382        return DescendantCombinator(self, xsc.makewalkfilter(other)) 
    12483 
    12584    def __mul__(self, other): 
     85        """ 
     86        Create an <pyref class="AdjacentSiblingCombinator"><class>AdjacentSiblingCombinator</class> 
     87        with <self/> as the left hand selector and <arg>other</arg> as the right 
     88        hand selector. 
     89        """ 
    12690        return AdjacentSiblingCombinator(self, xsc.makewalkfilter(other)) 
    12791 
    12892    def __pow__(self, other): 
     93        """ 
     94        Create a <pyref class="GeneralSiblingCombinator"><class>GeneralSiblingCombinator</class> 
     95        with <self/> as the left hand selector and <arg>other</arg> as the right 
     96        hand selector. 
     97        """ 
    12998        return GeneralSiblingCombinator(self, xsc.makewalkfilter(other)) 
    13099 
    131100    def __and__(self, other): 
     101        """ 
     102        Create an <pyref class="AndCombinator"><class>AndCombinator</class> 
     103        from <self/> and <arg>other</arg>. 
     104        """ 
    132105        return AndCombinator(self, xsc.makewalkfilter(other)) 
    133106 
    134107    def __or__(self, other): 
     108        """ 
     109        Create an <pyref class="OrCombinator"><class>OrCombinator</class> 
     110        from <self/> and <arg>other</arg>. 
     111        """ 
    135112        return OrCombinator(self, xsc.makewalkfilter(other)) 
    136113 
    137114    def __invert__(self): 
     115        """ 
     116        Create a <pyref class="NotCombinator"><class>NotCombinator</class> 
     117        inverting <self/>. 
     118        """ 
    138119        return NotCombinator(self) 
    139120