Mike Orr avatar Mike Orr committed ef8ce33

Proofread docs from 'containers' to 'html'.

Comments (0)

Files changed (13)

 
 ``webhelpers.html.grid`` needs some API changes to make a table from a list of
 lists and from a dict. Some arguments will be changing also.
+
+Run tests on Python 2.4 to see if any 2.5isms have crept in.

docs/modules/containers.rst

 
 .. currentmodule:: webhelpers.containers
 
+Classes
+-------
+
+.. autoclass:: Counter
+   :members:
+
+.. autoclass:: Accumulator
+   :members:
+
+.. autoclass:: UniqueAccumulator
+   :members:
+
+.. class:: defaultdict(missing_func)
+
+   A dict that automatically creates values for missing keys. This is the same
+   as ``collections.defaultdict`` in the Python standard library. It's provided
+   here for Python 2.4, which doesn't have that class.
+
+   When you try to read a key that's missing, I call ``missing_func`` without
+   args to create a value. The result is inserted into the dict and returned.
+   Many Python type constructors can be used as ``missing_func``.  Passing
+   ``list`` or ``set`` creates an empty dict or set.  Passing ``int`` creates
+   the integer ``0``.  These are useful in the following ways::
+
+       >> d = defaultdict(list);  d[ANYTHING].append(SOMEVALUE)
+       >> d = defaultdict(set);  d[ANYTHING].include(SOMEVALUE)
+       >> d = defaultdict(int);  d[ANYTHING] += 1
+
+.. autoclass:: DumbObject
 .. autoclass:: NotGiven
-.. autoclass:: DumbObject
-.. autoclass:: Counter
-.. autoclass:: Accumulator
-.. autoclass:: UniqueAccumulator
 
-.. autofunction:: unique
-.. autofunction:: only_some_keys
+Functions
+---------
+.. autofunction:: correlate_dicts
+.. autofunction:: correlate_objects
+.. autofunction:: del_quiet
+.. autofunction:: distribute
 .. autofunction:: except_keys
 .. autofunction:: extract_keys
+.. autofunction:: only_some_keys
 .. autofunction:: ordered_items
-.. autofunction:: del_quiet
-.. autofunction:: correlate_dicts
-.. autofunction:: correlate_objects
-.. autofunction:: distribute
 .. autofunction:: transpose
+.. autofunction:: unique
 

docs/modules/feedgenerator.rst

 ================================================
 
 This is a port of Django's feeed generator for creating RSS and Atom feeds.
-The Geo classes are also ported for publishing geographical (GIS) data.
+The Geo classes for publishing geographical (GIS) data are also ported.
 
 .. automodule:: webhelpers.feedgenerator
 

docs/modules/html/builder.rst

 
 .. autofunction:: lit_sub
 
-``webhelpers.html.builder`` **url_escape** (*s, safe='/'*)
+.. function:: url_escape(s, safe='/')
 
     Urlencode the path portion of a URL. This is the same function as
     ``urllib.quote`` in the Python standard library. It's exported here

docs/third_party.rst

 Third-party helpers
 ===================
+
+BeautifulSoup
+
+HTMLTidy
+
+Unidecode
+

tests/test_tools.py

 from routes import url_for
 
 from webhelpers.html import HTML, literal
+import webhelpers.html.render as render
 from webhelpers.html.tools import *
 
 class TestToolsHelper(WebHelpersTestCase):
                          highlight("This is a beautiful morning, but also a beautiful day",
                                    "beautiful", r'<b>\1</b>'))
 
+class TestStripTagsHelper(WebHelpersTestCase):
+    def test_compare_strip_tags_to_sanitize(self):
+        text = u'I <i>really</i> like <script language="javascript">NEFARIOUS CODE</script> steak!'
+        eq_(strip_tags(text), render.sanitize(text))
+
 if __name__ == '__main__':
     suite = map(unittest.makeSuite, [
         TestToolsHelper,
         TestHighlightHelper,
         TestURLHelper,
+        TestStripTagsHelper,
         ])
     for testsuite in suite:
         unittest.TextTestRunner(verbosity=1).run(testsuite)

webhelpers/constants.py

 # -*- encoding: latin-1 -*-
 # Latin-1 encoding needed for countries list.
-"""Geographical and other constants often used in web forms.
+"""Place names and other constants often used in web forms.
 """
 
 def uk_counties():
 
 _country_codes = None
 def country_codes():
-    """\
-    Return a list of all country names and their respective codes specified by
-    the ISO in the format ``("GB", "United Kingdom")``
+    """Return a list of all country names as tuples. The tuple value is the
+    country's 2-letter ISO code and its name; e.g., 
+    ``("GB", "United Kingdom")``. The countries are in name order.
     
     Can be used like this::
 
-        h.select(
-            "country", 
-            option_tags=options_with_please_select(
-                country_codes(),
-                selected = 'GB',
-                caption = 'Please choose a country'
-            ),
-        )
+        import webhelpers.constants as constants
+        from webhelpers.html.tags import select
+        select("country", country_codes(),
+            prompt="Please choose a country ...")
 
     See here for more information:
     http://www.iso.org/iso/english_country_names_and_code_elements
     """
     # Updated on 2007-10-24.
     #
-    # This might seem a funny implementation but it makes it easier to updated next
-    # time there is a change
+    # This might seem a funny implementation but it makes it easier to update
+    # next time there is a change
 
     global _country_codes
     if _country_codes is not None:
     return _country_codes
 
 def us_states():
-    """USA states.
+    """List of USA states.
 
-    Return a list of (abbreviation, name) for all US states, sorted by name.
+    Return a list of ``(abbreviation, name)`` for all US states, sorted by name.
     Includes the District of Columbia.
     """
     # From http://www.usps.com/ncsc/lookups/abbreviations.html
 
 def us_territories():
     """USA postal abbreviations for territories, protectorates, and military.
+    
+    The return value is a list of ``(abbreviation, name)`` tuples. The
+    locations are sorted by name.
     """
     # From http://www.usps.com/ncsc/lookups/abbreviations.html
     # Updated 2008-05-01
     
 
 def canada_provinces():
-    """Canadian provinces and abbreviations.
+    """List of Canadian provinces.
 
-    Return a list of (abbreviation, name) for all Canadian
+    Return a list of ``(abbreviation, name)`` tuples for all Canadian
     provinces and territories, sorted by name.
     """
     # Based on:

webhelpers/containers.py

-"""Container objects and list/dict helpers.
+"""Container objects, and helpers for lists and dicts.
 
-I would have called this "collections" except that Python 2 can't import a
-top-level module that's the same name as a module in the current package.
+This would have been called this "collections" except that Python 2 can't
+import a top-level module that's the same name as a module in the current
+package.
 """
 
 import sys
 class Counter(object):
     """I count the number of occurrences of each value registered with me.
     
-    Usage:
-    >>> counter = Counter()
-    >>> counter("foo")
-    >>> counter("bar")
-    >>> counter("foo")
-    >>> sorted(counter.result.items())
-    [('bar', 1), ('foo', 2)]
+    Call the instance to register a value. The result is available as the
+    ``.result`` attribute.  Example::
 
-    >> counter.result
-    {'foo': 2, 'bar': 1}
+        >>> counter = Counter()
+        >>> counter("foo")
+        >>> counter("bar")
+        >>> counter("foo")
+        >>> sorted(counter.result.items())
+        [('bar', 1), ('foo', 2)]
 
-    To see the most frequently-occurring items in order:
+        >> counter.result
+        {'foo': 2, 'bar': 1}
 
-    >>> counter.get_popular(1)
-    [(2, 'foo')]
-    >>> counter.get_popular()
-    [(2, 'foo'), (1, 'bar')]
+    To see the most frequently-occurring items in order::
 
-    Or if you prefer the list in item order:
+        >>> counter.get_popular(1)
+        [(2, 'foo')]
+        >>> counter.get_popular()
+        [(2, 'foo'), (1, 'bar')]
 
-    >>> counter.get_sorted_items()
-    [('bar', 1), ('foo', 2)]
+    Or if you prefer the list in item order::
+
+        >>> counter.get_sorted_items()
+        [('bar', 1), ('foo', 2)]
     """
 
     def __init__(self):
         self.total += 1
 
     def get_popular(self, max_items=None):
-        """Return the results as as a list of (count, item) pairs, with the
+        """Return the results as as a list of ``(count, item)`` pairs, with the
         most frequently occurring items first.
+
         If ``max_items`` is provided, return no more than that many items.
         """
         data = [(x[1], x[0]) for x in self.result.iteritems()]
             return data
 
     def get_sorted_items(self):
-        """Return the result as a list of (item, count) pairs sorted by item.
+        """Return the result as a list of ``(item, count)`` pairs sorted by item.
         """
         data = self.result.items()
         data.sort()
         return data
 
-    #@classmethod
     def correlate(class_, iterable):
         """Build a Counter from an iterable in one step.
 
         This is the same as adding each item individually.
 
-        >>> counter = Counter.correlate(["A", "B", "A"])
-        >>> counter.result["A"]
-        2
-        >>> counter.result["B"]
-        1
+        ::
+
+            >>> counter = Counter.correlate(["A", "B", "A"])
+            >>> counter.result["A"]
+            2
+            >>> counter.result["B"]
+            1
         """
         counter = class_()
         for elm in iterable:
 class Accumulator(object):
     """Accumulate a dict of all values for each key.
 
-    Usage:
-    >>> bowling_scores = Accumulator()
-    >>> bowling_scores("Fred", 0)
-    >>> bowling_scores("Barney", 10)
-    >>> bowling_scores("Fred", 1)
-    >>> bowling_scores("Barney", 9)
-    >>> sorted(bowling_scores.result.items())
-    [('Barney', [10, 9]), ('Fred', [0, 1])]
+    Call the instance to register a value. The result is available as the
+    ``.result`` attribute.  Example::
 
-    >> bowling_scores.result
-    {'Fred': [0, 1], 'Barney': [10, 9]}
+        >>> bowling_scores = Accumulator()
+        >>> bowling_scores("Fred", 0)
+        >>> bowling_scores("Barney", 10)
+        >>> bowling_scores("Fred", 1)
+        >>> bowling_scores("Barney", 9)
+        >>> sorted(bowling_scores.result.items())
+        [('Barney', [10, 9]), ('Fred', [0, 1])]
+
+        >> bowling_scores.result
+        {'Fred': [0, 1], 'Barney': [10, 9]}
 
     The values are stored in the order they're registered.
 
         self.result = defaultdict(list)
 
     def __call__(self, key, value):
+        """Register a key-value pair."""
         self.result[key].append(value)
 
-    #@classmethod
     def correlate(class_, iterable, key):
-        """Correlate several items into an Accumulator in one step.
+        """Create an Accumulator based on several related values.
 
         ``key`` is a function to calculate the key for each item, akin to
         ``list.sort(key=)``.
     """Accumulate a dict of unique values for each key.
 
     The values are stored in an unordered set.
+
+    Call the instance to register a value. The result is available as the
+    ``.result`` attribute.
     """
 
     def __init__(self):
         self.result = defaultdict(set)
 
     def __call__(self, key, value):
+        """Register a key-value pair."""
         self.result[key].add(value)
 
 
 def unique(it):
     """Return a list of unique elements in the iterable, preserving the order.
 
-    Usage:
-    >>> unique([None, "spam", 2, "spam", "A", "spam", "spam", "eggs", "spam"])
-    [None, 'spam', 2, 'A', 'eggs']
+    Usage::
+
+        >>> unique([None, "spam", 2, "spam", "A", "spam", "spam", "eggs", "spam"])
+        [None, 'spam', 2, 'A', 'eggs']
     """
     seen = set()
     ret = []
 def only_some_keys(dic, keys):
     """Return a copy of the dict with only the specified keys present.  
     
-    ``dic`` may be any mapping; the return value is always a Python dict.
+    ``dic`` may be any mapping. The return value is always a Python dict.
 
-    >> only_some_keys({"A": 1, "B": 2, "C": 3}, ["A", "C"])
-    >>> sorted(only_some_keys({"A": 1, "B": 2, "C": 3}, ["A", "C"]).items())
-    [('A', 1), ('C', 3)]
+    ::
+
+        >> only_some_keys({"A": 1, "B": 2, "C": 3}, ["A", "C"])
+        >>> sorted(only_some_keys({"A": 1, "B": 2, "C": 3}, ["A", "C"]).items())
+        [('A', 1), ('C', 3)]
     """
     ret = {}
     for key in keys:
 def except_keys(dic, keys):
     """Return a copy of the dict without the specified keys.
 
-    >>> except_keys({"A": 1, "B": 2, "C": 3}, ["A", "C"])
-    {'B': 2}
+    ::
+
+        >>> except_keys({"A": 1, "B": 2, "C": 3}, ["A", "C"])
+        {'B': 2}
     """
     ret = dic.copy()
     for key in keys:
     """Return two copies of the dict.  The first has only the keys specified.
     The second has all the *other* keys from the original dict.
 
-    >> extract_keys({"From": "F", "To": "T", "Received", R"}, ["To", "From"]) 
-    ({"From": "F", "To": "T"}, {"Recived": "R"})
-    >>> regular, extra = extract_keys({"From": "F", "To": "T", "Received": "R"}, ["To", "From"]) 
-    >>> sorted(regular.keys())
-    ['From', 'To']
-    >>> sorted(extra.keys())
-    ['Received']
+    ::
+
+        >> extract_keys({"From": "F", "To": "T", "Received", R"}, ["To", "From"]) 
+        ({"From": "F", "To": "T"}, {"Recived": "R"})
+        >>> regular, extra = extract_keys({"From": "F", "To": "T", "Received": "R"}, ["To", "From"]) 
+        >>> sorted(regular.keys())
+        ['From', 'To']
+        >>> sorted(extra.keys())
+        ['Received']
     """
     for k in keys:
         if k not in dic:
     return r1, r2
 
 def ordered_items(dic, key_order, other_keys=True, default=NotGiven):
-    """Like dict.iteritems() but with a specified key order.
+    """Like ``dict.iteritems()`` but with a specified key order.
 
-    ``dic`` is any mapping.
-    ``key_order`` is a list of keys.  Items will be yielded in this order.
-    ``other_keys`` is a boolean.
-    ``default`` is a value returned if the key is not in the dict.
+    Arguments:
+
+    * ``dic`` is any mapping.
+    * ``key_order`` is a list of keys.  Items will be yielded in this order.
+    * ``other_keys`` is a boolean.
+    * ``default`` is a value returned if the key is not in the dict.
 
     This yields the items listed in ``key_order``.  If a key does not exist
     in the dict, yield the default value if specified, otherwise skip the
     missing key.  Afterwards, if ``other_keys`` is true, yield the remaining
     items in an arbitrary order.
 
-    Usage:
-    >>> dic = {"To": "you", "From": "me", "Date": "2008/1/4", "Subject": "X"}
-    >>> dic["received"] = "..."
-    >>> order = ["From", "To", "Subject"]
-    >>> list(ordered_items(dic, order, False))
-    [('From', 'me'), ('To', 'you'), ('Subject', 'X')]
+    Usage::
+
+        >>> dic = {"To": "you", "From": "me", "Date": "2008/1/4", "Subject": "X"}
+        >>> dic["received"] = "..."
+        >>> order = ["From", "To", "Subject"]
+        >>> list(ordered_items(dic, order, False))
+        [('From', 'me'), ('To', 'you'), ('Subject', 'X')]
     """
     d = dict(dic)
     for key in key_order:
     
     This modifies the dict in place.
 
-    >>> d ={"A": 1, "B": 2, "C": 3}
-    >>> del_quiet(d, ["A", "C"])
-    >>> d
-    {'B': 2}
+    ::
+
+        >>> d ={"A": 1, "B": 2, "C": 3}
+        >>> del_quiet(d, ["A", "C"])
+        >>> d
+        {'B': 2}
     """
     for key in keys:
         try:
 def correlate_dicts(dicts, key):
     """Correlate several dicts under one superdict.
 
-    E.g., If you have several dicts each with a 'name' key, this can
-    put them in a container dict keyed by name.
+    If you have several dicts each with a 'name' key, this 
+    puts them in a container dict keyed by name.
 
-    >>> d1 = {"name": "Fred", "age": 41}
-    >>> d2 = {"name": "Barney", "age": 31}
-    >>> flintstones = correlate_dicts([d1, d2], "name")
-    >>> sorted(flintstones.keys())
-    ['Barney', 'Fred']
-    >>> flintstones["Fred"]["age"]
-    41
+    ::
+
+        >>> d1 = {"name": "Fred", "age": 41}
+        >>> d2 = {"name": "Barney", "age": 31}
+        >>> flintstones = correlate_dicts([d1, d2], "name")
+        >>> sorted(flintstones.keys())
+        ['Barney', 'Fred']
+        >>> flintstones["Fred"]["age"]
+        41
 
     If you're having trouble spelling this method correctly, remember:
     "relate" has one 'l'.  The 'r' is doubled because it occurs after a prefix.
 def correlate_objects(objects, attr):
     """Correlate several objects under one dict.
 
-    E.g., If you have several objects each with a 'name' attribute, this can
-    create a dict containing each object keyed by name.
+    If you have several objects each with a 'name' attribute, this
+    puts them in a dict keyed by name.
 
-    >>> class Flintstone(DumbObject):
-    ...    pass
-    ...
-    >>> fred = Flintstone(name="Fred", age=41)
-    >>> barney = Flintstone(name="Barney", age=31)
-    >>> flintstones = correlate_objects([fred, barney], "name")
-    >>> sorted(flintstones.keys())
-    ['Barney', 'Fred']
-    >>> flintstones["Barney"].age
-    31
+    ::
+
+        >>> class Flintstone(DumbObject):
+        ...    pass
+        ...
+        >>> fred = Flintstone(name="Fred", age=41)
+        >>> barney = Flintstone(name="Barney", age=31)
+        >>> flintstones = correlate_objects([fred, barney], "name")
+        >>> sorted(flintstones.keys())
+        ['Barney', 'Fred']
+        >>> flintstones["Barney"].age
+        31
 
     If you're having trouble spelling this method correctly, remember:
     "relate" has one 'l'.  The 'r' is doubled because it occurs after a prefix.
         </table>
 
     In a horizontal table, each row is filled before going on to the next row.
-    This is the same as dividing the list into chunks.
+    This is the same as dividing the list into chunks::
 
-    .. code-block:: pycon
-    
         >>> distribute([1, 2, 3, 4, 5, 6, 7, 8], 3, "H")
         [[1, 2, 3], [4, 5, 6], [7, 8, None]]
 
     In a vertical table, the first element of each sublist is filled before
     going on to the second element.  This is useful for displaying an
     alphabetical list in columns, or when the entire column will be placed in
-    a single <td> with a <br /> between each element.
-
-    .. code-block:: pycon
+    a single <td> with a <br /> between each element::
 
         >>> food = ["apple", "banana", "carrot", "daikon", "egg", "fish", "gelato", "honey"]
         >>> table = distribute(food, 3, "V", "")
 def transpose(array):
     """Turn a list of lists sideways, making columns into rows and vice-versa.
 
-    The result is undefined if the array is not rectangular; i.e., if
-    ``len(array[n]) != len(array[0])``.  You may get an ``IndexError`` or
-    missing items.
+    ``array`` must be rectangular; i.e., all elements must be the same 
+    length. Otherwise the behavior is undefined: you may get ``IndexError``
+    or missing items.
 
-    Picture the first example as::
+    Examples::
+
+        >>> transpose([["A", "B", "C"], ["D", "E", "F"]])
+        [['A', 'D'], ['B', 'E'], ['C', 'F']]
+        >>> transpose([["A", "B"], ["C", "D"], ["E", "F"]])
+        [['A', 'C', 'E'], ['B', 'D', 'F']]
+        >>> transpose([])
+        []
+        
+    Here's a pictoral view of the first example::
 
        A B C    =>    A D
        D E F          B E
                       C F
 
-    The source array is row-major (``array[n]`` is a row, ``array[n][0]`` is
-    the first element of the row), which is good for an HTML table which is
-    also row-major (columns within rows).  The result is column-major
-    (``array[n]`` is a column, ``array[n][0]`` is the first row in the column),
-    which is good for a group of <div> columns with <br /> between rows.
-
-    >>> transpose([["A", "B", "C"], ["D", "E", "F"]])
-    [['A', 'D'], ['B', 'E'], ['C', 'F']]
-    >>> transpose([["A", "B"], ["C", "D"], ["E", "F"]])
-    [['A', 'C', 'E'], ['B', 'D', 'F']]
-    >>> transpose([])
-    []
+    This can be used to turn an HTML table into a group of div columns. An HTML
+    table is row major: it consists of several <tr> rows, each containing
+    several <td> cells.  But a <div> layout consists of only one row, each
+    containing an entire subarray. The <div>s have style "float:left", which
+    makes them appear horizonally. The items within each <div> are placed in
+    their own <div>'s or separatad by <br />, which makes them appear
+    vertically.  The point is that an HTML table is row major (``array[0]`` is
+    the first row), while a group of div columns is column major (``array[0]``
+    is the first column). ``transpose()`` can be used to switch between the
+    two.
     """
     if not array:
         return []

webhelpers/date.py

-"""Date/Time Helpers"""
+"""Date and time helpers."""
 
 from datetime import datetime
 import time
                               round=False):
     """
     Return the absolute time-distance string for two datetime objects,
-    ints or any combination of which you can dream
+    ints or any combination you can dream of.
     
-    If times are integers, they are interpreted as seconds from now
+    If times are integers, they are interpreted as seconds from now.
     
     ``granularity`` dictates where the string calculation is stopped.
     If set to seconds (default) you will receive the full string. If
-    another accuracy is supplied you will be provided with an
-    approximation stopping at the granularity supplied.  Available
-    parameter values are:
-    
+    another accuracy is supplied you will receive an approximation.
+    Available granularities are:
     'century', 'decade', 'year', 'month', 'day', 'hour', 'minute',
     'second'
     
-    Setting ``round`` to true will check the granularity finer than the
-    set granularity and if the value is greater than 50% of its range
-    the value at granularity will be increased by 1
+    Setting ``round`` to true will increase the result by 1 if the fractional
+    value is greater than 50% of the granularity unit.
     
     Examples:
 
                         'day': 15, 'hour': 24, 'minute': 60, 'second': 60 }
     
     if granularity not in granularities:
-        raise Exception("Please provide a valid granularity: %s" %
+        raise ValueError("Please provide a valid granularity: %s" %
                         (granularities))
     
     # Get everything into datetimes

webhelpers/html/builder.py

 
 ``literal`` is a subclass of ``unicode``, so it works with all string methods
 and expressions.  The only thing special about it is the ``.__html__`` method,
-which returns the string itself.  ``escape()`` follows a simple protocol: if
-the object has an ``.__html__`` method, it calls that rather than ``.__str__``
-to get the HTML representation.  Third-party libraries that do not want to
-import ``literal`` (and this create a dependency on WebHelpers) can put an
-``.__html__`` method in their own classes returning the desired HTML
+which returns the string itself.  The ``escape()`` function follows a simple
+protocol: if the object has an ``.__html__`` method, it calls that rather than
+``.__str__`` to get the HTML representation.  Third-party libraries that do not
+want to import ``literal`` (and this create a dependency on WebHelpers) can put
+an ``.__html__`` method in their own classes returning the desired HTML
 representation.
 
 When used in a mixed expression containing both literals and ordinary strings,

webhelpers/html/render.py

         u'I really like steak!'
         >>> sanitize(u'I <i>really</i> like <script language="javascript">NEFARIOUS CODE</script> steak!')
         u'I really like NEFARIOUS CODE steak!'
+
+    This is the same as ``webhelpers.render.sanitize`` but is an older
+    implementation.
     """
     p = HTMLSanitizer()
     p.feed(html)

webhelpers/html/tags.py

-"""Helpers producing simple HTML tags
+"""Helpers that produce simple HTML tags.
 
 Most helpers have an ``**attrs`` argument to specify additional HTML
 attributes.  A trailing underscore in the name will be deleted; this is 
 e.g., ``class_``.  Some helpers handle certain keywords specially; these are
 noted in the helpers' docstrings.
 
-A set of CSS styles complemeting these helpers is in
+to create your own custom tags, see ``webhelpers.html.builder``.
+
+A set of CSS styles complementing these helpers is in
 ``webhelpers/public/stylesheets/webhelpers.css``.
 """
 
         return label
 
 def link_to_unless(condition, label, url='', **attrs):
-    """Same as ``link_to`` but return just the label if the condition is true.
+    """The opposite of ``link_to``. Return just the label if the condition is 
+    true.
     """
     if not condition:
         return link_to(label, url, **attrs)

webhelpers/html/tools.py

                            """, re.X)
 
 
-def button_to(name, url='', **html_options):
+def button_to(name, url='', **html_attrs):
     """Generate a form containing a sole button that submits to
     ``url``. 
     
     the safe HTTP GET semantics implied by using a hypertext link.
     
     The parameters are the same as for ``link_to``.  Any 
-    ``html_options`` that you pass will be applied to the inner
+    ``html_attrs`` that you pass will be applied to the inner
     ``input`` element. In particular, pass
     
         disabled = True/False
     
-    as part of ``html_options`` to control whether the button is
+    as part of ``html_attrs`` to control whether the button is
     disabled.  The generated form element is given the class
     'button-to', to which you can attach CSS styles for display
     purposes.
         (Bottom line: Always validate your HTML before going public.)
     
     """
-    if html_options:
-        tags.convert_boolean_attrs(html_options, ['disabled'])
+    if html_attrs:
+        tags.convert_boolean_attrs(html_attrs, ['disabled'])
     
     method_tag = ''
-    method = html_options.pop('method', '')
+    method = html_attrs.pop('method', '')
     if method.upper() in ['PUT', 'DELETE']:
         method_tag = HTML.input(
             type='hidden', id='_method', name_='_method', value=method)
     
     url, name = url, name or url
     
-    submit_type = html_options.get('type')
-    img_source = html_options.get('src')
+    submit_type = html_attrs.get('type')
+    img_source = html_attrs.get('src')
     if submit_type == 'image' and img_source:
-        html_options["value"] = name
-        html_options.setdefault("alt", name)
+        html_attrs["value"] = name
+        html_attrs.setdefault("alt", name)
     else:
-        html_options["type"] = "submit"
-        html_options["value"] = name
+        html_attrs["type"] = "submit"
+        html_attrs["value"] = name
     
     return HTML.form(method=form_method, action=url, class_="button-to",
-                     c=[HTML.div(method_tag, HTML.input(**html_options))])
+                     c=[HTML.div(method_tag, HTML.input(**html_attrs))])
 
 def js_obfuscate(content):
     """Obfuscate data in a Javascript tag.
 
 
 def mail_to(email_address, name=None, cc=None, bcc=None, subject=None, 
-    body=None, replace_at=None, replace_dot=None, encode=None, **html_options):
+    body=None, replace_at=None, replace_dot=None, encode=None, **html_attrs):
     """Create a link tag for starting an email to the specified 
     ``email_address``.
     
     This ``email_address`` is also used as the name of the link unless
     ``name`` is specified. Additional HTML options, such as class or
-    id, can be passed in the ``html_options`` hash.
+    id, can be passed in the ``html_attrs`` hash.
     
     You can also make it difficult for spiders to harvest email address
     by obfuscating them.
     url = HTML.literal(protocol + email_address)
     if options_query:
         url += HTML.literal('?') + options_query
-    html_options['href'] = url
+    html_attrs['href'] = url
 
-    tag = HTML.a(name or email_address_obfuscated, **html_options)
+    tag = HTML.a(name or email_address_obfuscated, **html_attrs)
 
     if encode == 'javascript':
         tmp = "document.write('%s');" % tag
     return lit_sub(rx, highlighter, text)
     
 
-def auto_link(text, link="all", **href_options):
+def auto_link(text, link="all", **href_attrs):
     """
     Turn all urls and email addresses into clickable links.
     
     ``link``
         Used to determine what to link. Options are "all", 
         "email_addresses", or "urls"
+
+    ``href_attrs``
+        Additional attributes for generated <a> tags.
     
     Example::
     
         return literal(u"")
     text = escape(text)
     if link == "all":
-        return _auto_link_urls(_auto_link_email_addresses(text), **href_options)
+        return _auto_link_urls(_auto_link_email_addresses(text), **href_attrs)
     elif link == "email_addresses":
         return _auto_link_email_addresses(text)
     else:
-        return _auto_link_urls(text, **href_options)
+        return _auto_link_urls(text, **href_attrs)
 
-def _auto_link_urls(text, **href_options):
+def _auto_link_urls(text, **href_attrs):
     def handle_match(matchobj):
         all = matchobj.group()
         before, prefix, link, after = matchobj.group(1, 2, 3, 4)
         text = literal(prefix + link)
         if prefix == "www.":
             prefix = "http://www."
-        a_options = dict(href_options)
+        a_options = dict(href_attrs)
         a_options['href'] = literal(prefix + link)
         return literal(before) + HTML.a(text, **a_options) + literal(after)
     return literal(re.sub(AUTO_LINK_RE, handle_match, text))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.