1. xpahos
  2. WebHelpers


slug...@gmail.com  committed 0c28fc4

Module documentation.

  • Participants
  • Parent commits b3cfd71
  • Branches trunk

Comments (0)

Files changed (3)

File docs/_templates/index.html

View file
  • Ignore whitespace
 <img src="_images/webhelpers-logo.png" width="100" height="110" 
     style="float:left; margin-right:1em" />
-<p>WebHelpers is a collection of utility functions useful in web application
-templates, controller/view code, and non-web applications.  It consists of
-several independent subpackages:</p>
+<p>WebHelpers contains a wide variety of functions for web application
+templates, MVC controller code, and non-web applications.  Main features:
-<br clear="all" />
+    <ul>
+        <li>Works with any web framework</li>
+        <li>An HTML tag generator that smartly escapes text content
+        to prevent cross-site scripting attacks and double-escaping</li>
+        <li>Convenience functions to produce form tags, links, and other common
+        tags.</li>
+        <li>A <code>ModelTags</code> object </li>
+    </ul>
+It consists of
+several independent subpackages for generating HTML tags and form tags,
+text processing, displaying records a pageful at a time, generating Atom and
+RSS feeds, number formatting and  statistical calculations, handling MIME
+types, and more.  There are also high-level container types, including a value
+counter and accumulator.  There are lists of country names, country codes, US
+states, Canadian provinces, and UK counties.:</p>
 <table style="border:outset">
     <tr><th>constants</th><td>Countries &amp; states for address forms
-    <tr><th>containers</th><td>Helpers for collections</td></tr>
+    <tr><th>containers</th><td>High-level containers &amp; counters</td></tr>
     <tr><th>date</th><td>Date/time helpers</td></tr>
-    <tr><th>feedgenerator</th><td>Create RSS or Atom feeds</td></tr>
-    <tr><th>html</th><td>HTML tags and form tags</td></tr>
+    <tr><th>feedgenerator</th><td>Create Ato and RSS feeds</td></tr>
+    <tr><th>html</th><td>Generate HTML tags and form tags</td></tr>
     wiki-like text to HTML</td></tr>
-    <tr><th>media</th><td>Image files</td></tr>
+    <tr><th>media</th><td>Image file calculations</td></tr>
     <tr><th>mimehelper</th><td>MIME types</td></tr>
-    <tr><th>misc/util</th><td>Other helpers</td></tr>
     <tr><th>number</th><td>Formatters and statistics</td></tr>
     <tr><th>paginate</th><td>Display records a pageful at a time
     <tr><th>text</th><td>Text processing</td></tr>
+<br clear="all" />
 <p>WebHelpers is pure Python and has no dependencies.  However, a few
 helpers depend on 
 <a href="http://routes.groovie.org/">Routes</a>, 
-<a href="http://pylonshq.com/">Pylons</a>, 
 <a href="http://python.org/pypi/Unidecode/">unidecode</a>, 
 <a href="http://pythonpaste.org/webob/">WebOb</a>
-as noted in their documentation.  WebHelpers comes with an extensive set of
-unit tests.</p>
+as noted in their documentation.  The Pylons helpers are designed for <a
+href="http://pylonshq.com/">Pylons</a>' request/response/session objects but
+can easily be ported to another web framework.  WebHelpers comes with an
+extensive set of unit tests.</p>
 <p>For support/question/patches, please use the `
 <a href="http://groups.google.com/group/pylons-discuss">Pylons mailing list</a>.</p>
   <p>Download <a href="http://webhelpers.groovie.org/webhelpers.pdf">WebHelpers PDF documentation</a>.</p>
-  <h2>Developers / Source Code</h2>
-  <p>WebHelpers' Mercurial repository can be found at
-    <a href="http://bitbucket.org/bbangert/webhelpers/"><tt>http://bitbucket.org/bbangert/webhelpers/</tt></a>.</p>
+  <h2>Development</h2>
+  <p>WebHelpers source code is at BitBucket.</p>
+  <blockquote>
+    <a href="http://bitbucket.org/bbangert/webhelpers/">Overview</a> -
+    <a href="http://bitbucket.org/bbangert/webhelpers/wiki/">Wiki</a> -
+    <a href="http://bitbucket.org/bbangert/webhelpers/src/">Source code</a>  -
+    <a href="http://bitbucket.org/bbangert/webhelpers/issues/">Bug tracker</a>
+  </blockquote>
+  <p>To check out the Mercurial repository:</p>
-    <p>To check it out:</p>
-      <pre>hg clone http://www.bitbucket.org/bbangert/webhelpers</pre>
+  <pre>hg clone http://www.bitbucket.org/bbangert/webhelpers</pre>
 {% endblock %}

File docs/contents.rst

View file
  • Ignore whitespace
+   date
+   feedgenerator
 .. toctree::
    :maxdepth: 1

File webhelpers/date.py

View file
  • Ignore whitespace
 from datetime import datetime
 import time
-__all__ = ['distance_of_time_in_words']
+__all__ = ["distance_of_time_in_words", "time_ago_in_words"]
 def _process_carryover(deltas, carry_over):
     """A helper function to process negative deltas based on the deltas
     Setting ``round`` to true will check the granularity finer than the
-    set granularity and if the value is greater than 50% of it's range
+    set granularity and if the value is greater than 50% of its range
     the value at granularity will be increased by 1
     Return approximate-time-distance string for ``from_time`` till now.
-    See ``distance_of_time_in_words`` -- same here, but ``to_time`` is 
-    fixed to ``datetime.now()``.
+    Same as ``distance_of_time_in_words`` but the endpoint is now.
     return distance_of_time_in_words(from_time, datetime.now(), 
         granularity, round)