Commits

Anonymous committed c7cb340

[svn] fixing many doctests, mostly whitespace and lacking surrounding quotes. some bug fixes

  • Participants
  • Parent commits 0d81739

Comments (0)

Files changed (7)

File webhelpers/rails/form_options.py

     Examples (call, result)::
     
         >>> options_for_select([["Dollar", "$"], ["Kroner", "DKK"]])
-        <option value="$">Dollar</option>\\n<option value="DKK">Kroner</option>
+        '<option value="$">Dollar</option>\\n<option value="DKK">Kroner</option>'
         >>> options_for_select([ "VISA", "MasterCard" ], "MasterCard")
-        <option value="VISA">VISA</option>\\n<option value="MasterCard" selected="selected">MasterCard</option>
+        '<option value="VISA">VISA</option>\\n<option value="MasterCard" selected="selected">MasterCard</option>'
         >>> options_for_select(dict(Basic="$20", Plus="$40"), "$40")
-        <option value="$20">Basic</option>\\n<option value="$40" selected="selected">Plus</option>
+        <option value="$40" selected="selected">Plus</option>\n<option value="$20">Basic</option>
         >>> options_for_select([ "VISA", "MasterCard", "Discover" ], ["VISA", "Discover"])
-        <option value="VISA" selected="selected">VISA</option>\\n<option value="MasterCard">MasterCard</option>\\n
-        <option value="Discover" selected="selected">Discover</option>
+        '<option value="VISA" selected="selected">VISA</option>\\n<option value="MasterCard">MasterCard</option>\\n<option value="Discover" selected="selected">Discover</option>'
 
     Note: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
     """

File webhelpers/rails/form_tag.py

     ``option_tags`` is a string containing the option tags for the select box::
 
         >>> select("people", "<option>George</option>")
-        <select id="people" name="people"><option>George</option></select>
+        '<select id="people" name="people"><option>George</option></select>'
     
     Options:
     
     Example::
     
         >>> text_area("body", '', size="25x10")
-        <textarea name="body" id="body" cols="25" rows="10"></textarea>
+        '<textarea cols="25" id="body" name="body" rows="10"></textarea>'
     """
     if 'size' in options:
         options["cols"], options["rows"] = options["size"].split("x")

File webhelpers/rails/javascript.py

     
     Example::
     
-        >>> javascript_tag("alert('All is good')"
-        '<script type="text/javascript">alert('All is good')</script>'
+        >>> javascript_tag("alert('All is good')")
+        '<script type="text/javascript">\n//<![CDATA[\nalert(\'All is good\')\n//]]>\n</script>'
     """
     return content_tag("script", javascript_cdata_section(content), type="text/javascript",
                        **html_options)

File webhelpers/rails/number.py

     Examples::
     
         >>> number_to_phone(1235551234)
-        123-555-1234
+        '123-555-1234'
         >>> number_to_phone(1235551234, area_code=True)
-        (123) 555-1234
+        '(123) 555-1234'
         >>> number_to_phone(1235551234, delimiter=" ")
-        123 555 1234
+        '123 555 1234'
         >>> number_to_phone(1235551234, area_code=True, extension=555)
-        (123) 555-1234 x 555
+        '(123) 555-1234 x 555'
         >>> number_to_phone(1235551234, country_code=1)
-        1-123-555-1234
+        '1-123-555-1234'
     """
     number = str(number).strip()
     if area_code:
     Examples::
     
         >>> number_to_currency(1234567890.50)
-        $1,234,567,890.50
+        '$1,234,567,890.50'
         >>> number_to_currency(1234567890.506)
-        $1,234,567,890.51
+        '$1,234,567,890.51'
         >>> number_to_currency(1234567890.50, unit="&pound;", separator=",", delimiter="")
-        &pound;1234567890,50
+        '&pound;1234567890,50'
     """
     if precision < 1:
         separator = ""
     Examples::
     
         >>> number_to_percentage(100)
-        100.000%
+        '100.000%'
         >>> number_to_percentage(100, precision=0)
-        100%
+        '100%'
         >>> number_to_percentage(302.0574, precision=2)
-        302.06%
+        '302.06%'
     """
     number = number_with_precision(number, precision)
     parts = number.split('.')
     Examples::
     
         >>> number_to_human_size(123)
-        123 Bytes
+        '123 Bytes'
         >>> number_to_human_size(1234)
-        1.2 KB
+        '1.2 KB'
         >>> number_to_human_size(12345)
-        12.1 KB
+        '12.1 KB'
         >>> number_to_human_size(1234567)
-        1.2 MB
+        '1.2 MB'
         >>> number_to_human_size(1234567890)
-        1.1 GB
+        '1.1 GB'
         >>> number_to_human_size(1234567890123)
-        1.1 TB
+        '1.1 TB'
         >>> number_to_human_size(1234567, 2)
-        1.18 TB
+        '1.18 MB'
     """
     if size == 1:
         return "1 Byte"
     Example::
     
         >>> number_with_delimiter(12345678)
-        12,345,678
+        '12,345,678'
         >>> number_with_delimiter(12345678.05)
-        12,345,678.05
+        '12,345,678.05'
         >>> number_with_delimiter(12345678, delimiter=".")
-        12.345.678
+        '12.345.678'
     """
     parts = str(number).split('.')
     parts[0] = re.sub(r'(\d)(?=(\d\d\d)+(?!\d))', r'\1%s' % delimiter, str(parts[0]))
     Example::
     
         >>> number_with_precision(111.2345)
-        111.235
+        '111.234'
         >>> number_with_precision(111.2345, 2)
-        111.23
+        '111.23'
     """
     formstr = '%01.' + str(precision) + 'f'
     return formstr % number

File webhelpers/rails/tags.py

     Examples::
     
         >>> tag("br")
-        <br />
+        '<br />'
         >>> tag("br", True)
-        <br>
+        '<br>'
         >>> tag("input", type="text")
-        <input type="text" />
-        >>> tag("input", type='text', disabled=True))
-        <input disabled="disabled" type="text" />
+        '<input type="text" />'
+        >>> tag("input", type='text', disabled=True)
+        '<input disabled="disabled" type="text" />'
     """
     tag = '<%s%s%s' % (name, (options and tag_options(**options)) or '', (open and '>') or ' />')
     return tag
     Examples::
     
         >>> content_tag("p", "Hello world!")
-        <p>Hello world!</p>
+        '<p>Hello world!</p>'
         >>> content_tag("div", content_tag("p", "Hello world!"), class_="strong")
-        <div class="strong"><p>Hello world!</p></div>
+        '<div class="strong"><p>Hello world!</p></div>'
     """
     if content is None:
         content = ''
     """Escapes a given string without affecting existing escaped entities.
 
     >>> escape_once("1 < 2 &amp; 3")
-    1 &lt; 2 &amp; 3
+    '1 &lt; 2 &amp; 3'
     """
     return fix_double_escape(html_escape(html))
 

File webhelpers/rails/text.py

     Example::
     
         >>> excerpt("hello my world", "my", 3)
-        "...lo my wo..."
+        '...lo my wo...'
     """
     if not text or not phrase:
         return text
     Example::
     
         >>> auto_link("Go to http://www.planetpython.com and say hello to guido@python.org")
-        'Go to <a href="http://www.planetpython.com">http://www.planetpython.com</a> and say
-        hello to <a href="mailto:guido@python.org">guido@python.org</a>'
+        'Go to <a href="http://www.planetpython.com">http://www.planetpython.com</a> and say hello to <a href="mailto:guido@python.org">guido@python.org</a>'
     """
     if not text:
         return ""
     
     Example::
     
-        >>> strip_links("<a href="something">else</a>")
-        "else"
+        >>> strip_links('<a href="something">else</a>')
+        'else'
     """
     strip_re = re.compile(r'<a\b.*?>(.*?)<\/a>', re.I | re.M)
     return strip_re.sub(r'\1', text)

File webhelpers/rails/urls.py

     Examples::
     
         >>> mail_to("me@domain.com", "My email", encode = "javascript")
-        <script type="text/javascript" language="javascript">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>
+        '<script type="text/javascript">\n//<![CDATA[\neval(unescape(\'%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b\'))\n//]]>\n</script>'
     
         >>> mail_to("me@domain.com", "My email", encode = "hex")
-        <a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">My email</a>
+        '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">My email</a>'
     
     You can also specify the cc address, bcc address, subject, and body parts
     of the message header to create a complex e-mail using the corresponding
     
         >>> mail_to("me@domain.com", "My email", cc="ccaddress@domain.com", bcc="bccaddress@domain.com", 
         subject="This is an examjust    ple email", body= "This is the body of the message.")
-        <a href="mailto:me@domain.com?cc="ccaddress@domain.com"&bcc="bccaddress@domain.com"&body="This%20is%20the%20body%20of%20the%20message."&subject="This%20is%20an%20example%20email">My email</a>
+        '<a href="mailto:me@domain.com?cc="ccaddress@domain.com"&bcc="bccaddress@domain.com"&body="This%20is%20the%20body%20of%20the%20message."&subject="This%20is%20an%20example%20email">My email</a>'
     """
     extras = {}
     for key, option in ('cc', cc), ('bcc', bcc), ('subject', subject), ('body', body):