More autodoc fixes
This commit is contained in:
parent
050797cc5e
commit
f6b365158d
|
@ -211,11 +211,15 @@ def linkify(text, shorten=False, extra_params="",
|
|||
Hello <a href="http://tornadoweb.org">http://tornadoweb.org</a>!
|
||||
|
||||
Parameters:
|
||||
|
||||
shorten: Long urls will be shortened for display.
|
||||
|
||||
extra_params: Extra text to include in the link tag,
|
||||
e.g. linkify(text, extra_params='rel="nofollow" class="external"')
|
||||
|
||||
require_protocol: Only linkify urls which include a protocol. If this is
|
||||
False, urls such as www.facebook.com will also be linkified.
|
||||
|
||||
permitted_protocols: List (or set) of protocols which should be linkified,
|
||||
e.g. linkify(text, permitted_protocols=["http", "ftp", "mailto"]).
|
||||
It is very unsafe to include protocols such as "javascript".
|
||||
|
|
|
@ -13,7 +13,7 @@ from tornado.util import import_object, bytes_type
|
|||
class HTTPClient(object):
|
||||
"""A blocking HTTP client.
|
||||
|
||||
Typical usage looks like this:
|
||||
Typical usage looks like this::
|
||||
|
||||
http_client = httpclient.HTTPClient()
|
||||
try:
|
||||
|
@ -51,7 +51,7 @@ class HTTPClient(object):
|
|||
class AsyncHTTPClient(object):
|
||||
"""An non-blocking HTTP client.
|
||||
|
||||
Example usage:
|
||||
Example usage::
|
||||
|
||||
import ioloop
|
||||
|
||||
|
@ -208,13 +208,21 @@ class HTTPResponse(object):
|
|||
"""HTTP Response object.
|
||||
|
||||
Attributes:
|
||||
|
||||
* request: HTTPRequest object
|
||||
|
||||
* code: numeric HTTP status code, e.g. 200 or 404
|
||||
|
||||
* headers: httputil.HTTPHeaders object
|
||||
|
||||
* buffer: cStringIO object for response body
|
||||
|
||||
* body: respose body as string (created on demand from self.buffer)
|
||||
|
||||
* error: Exception object, if any
|
||||
|
||||
* request_time: seconds from request start to finish
|
||||
|
||||
* time_info: dictionary of diagnostic timing information from the request.
|
||||
Available data are subject to change, but currently uses timings
|
||||
available from http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html,
|
||||
|
@ -266,8 +274,10 @@ class HTTPError(Exception):
|
|||
"""Exception thrown for an unsuccessful HTTP request.
|
||||
|
||||
Attributes:
|
||||
|
||||
code - HTTP error integer error code, e.g. 404. Error code 599 is
|
||||
used when no HTTP response was received, e.g. for a timeout.
|
||||
|
||||
response - HTTPResponse object, if any.
|
||||
|
||||
Note that if follow_redirects is False, redirects become HTTPErrors,
|
||||
|
|
|
@ -64,14 +64,14 @@ def _cpu_count():
|
|||
|
||||
|
||||
class HTTPServer(object):
|
||||
"""A non-blocking, single-threaded HTTP server.
|
||||
r"""A non-blocking, single-threaded HTTP server.
|
||||
|
||||
A server is defined by a request callback that takes an HTTPRequest
|
||||
instance as an argument and writes a valid HTTP response with
|
||||
request.write(). request.finish() finishes the request (but does not
|
||||
necessarily close the connection in the case of HTTP/1.1 keep-alive
|
||||
requests). A simple example server that echoes back the URI you
|
||||
requested:
|
||||
requested::
|
||||
|
||||
import httpserver
|
||||
import ioloop
|
||||
|
@ -105,7 +105,7 @@ class HTTPServer(object):
|
|||
HTTPServer can serve HTTPS (SSL) traffic with Python 2.6+ and OpenSSL.
|
||||
To make this server serve SSL traffic, send the ssl_options dictionary
|
||||
argument with the arguments required for the ssl.wrap_socket() method,
|
||||
including "certfile" and "keyfile":
|
||||
including "certfile" and "keyfile"::
|
||||
|
||||
HTTPServer(applicaton, ssl_options={
|
||||
"certfile": os.path.join(data_dir, "mydomain.crt"),
|
||||
|
@ -114,7 +114,7 @@ class HTTPServer(object):
|
|||
|
||||
By default, listen() runs in a single thread in a single process. You
|
||||
can utilize all available CPUs on this machine by calling bind() and
|
||||
start() instead of listen():
|
||||
start() instead of listen()::
|
||||
|
||||
http_server = httpserver.HTTPServer(handle_request)
|
||||
http_server.bind(8888)
|
||||
|
@ -503,7 +503,8 @@ class HTTPRequest(object):
|
|||
"""Returns the client's SSL certificate, if any.
|
||||
|
||||
To use client certificates, the HTTPServer must have been constructed
|
||||
with cert_reqs set in ssl_options, e.g.:
|
||||
with cert_reqs set in ssl_options, e.g.::
|
||||
|
||||
server = HTTPServer(app,
|
||||
ssl_options=dict(
|
||||
certfile="foo.crt",
|
||||
|
|
|
@ -49,7 +49,7 @@ class IOLoop(object):
|
|||
connections, you should use Linux and either compile our epoll module or
|
||||
use Python 2.6+ to get epoll support.
|
||||
|
||||
Example usage for a simple TCP server:
|
||||
Example usage for a simple TCP server::
|
||||
|
||||
import errno
|
||||
import functools
|
||||
|
@ -132,7 +132,7 @@ class IOLoop(object):
|
|||
|
||||
A common pattern for classes that depend on IOLoops is to use
|
||||
a default argument to enable programs with multiple IOLoops
|
||||
but not require the argument for simpler applications:
|
||||
but not require the argument for simpler applications::
|
||||
|
||||
class MyClass(object):
|
||||
def __init__(self, io_loop=None):
|
||||
|
@ -296,10 +296,12 @@ class IOLoop(object):
|
|||
will return immediately.
|
||||
|
||||
To use asynchronous methods from otherwise-synchronous code (such as
|
||||
unit tests), you can start and stop the event loop like this:
|
||||
unit tests), you can start and stop the event loop like this::
|
||||
|
||||
ioloop = IOLoop()
|
||||
async_method(ioloop=ioloop, callback=ioloop.stop)
|
||||
ioloop.start()
|
||||
|
||||
ioloop.start() will return after async_method has run its callback,
|
||||
whether that callback was invoked before or after ioloop.start.
|
||||
"""
|
||||
|
|
|
@ -34,7 +34,7 @@ except ImportError:
|
|||
ssl = None
|
||||
|
||||
class IOStream(object):
|
||||
"""A utility class to write to and read from a non-blocking socket.
|
||||
r"""A utility class to write to and read from a non-blocking socket.
|
||||
|
||||
We support three methods: write(), read_until(), and read_bytes().
|
||||
All of the methods take callbacks (since writing and reading are
|
||||
|
@ -48,7 +48,7 @@ class IOStream(object):
|
|||
and may either be connected before passing it to the IOStream or
|
||||
connected with IOStream.connect.
|
||||
|
||||
A very simple (and broken) HTTP client using this class:
|
||||
A very simple (and broken) HTTP client using this class::
|
||||
|
||||
from tornado import ioloop
|
||||
from tornado import iostream
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
|
||||
"""Translation methods for generating localized strings.
|
||||
|
||||
To load a locale and generate a translated string:
|
||||
To load a locale and generate a translated string::
|
||||
|
||||
user_locale = locale.get("es_LA")
|
||||
print user_locale.translate("Sign out")
|
||||
|
||||
locale.get() returns the closest matching locale, not necessarily the
|
||||
specific locale you requested. You can support pluralization with
|
||||
additional arguments to translate(), e.g.:
|
||||
additional arguments to translate(), e.g.::
|
||||
|
||||
people = [...]
|
||||
message = user_locale.translate(
|
||||
|
|
|
@ -16,19 +16,19 @@
|
|||
|
||||
"""A simple template system that compiles templates to Python code.
|
||||
|
||||
Basic usage looks like:
|
||||
Basic usage looks like::
|
||||
|
||||
t = template.Template("<html>{{ myvalue }}</html>")
|
||||
print t.generate(myvalue="XXX")
|
||||
|
||||
Loader is a class that loads templates from a root directory and caches
|
||||
the compiled templates:
|
||||
the compiled templates::
|
||||
|
||||
loader = template.Loader("/home/btaylor")
|
||||
print loader.load("test.html").generate(myvalue="XXX")
|
||||
|
||||
We compile all templates to raw Python. Error-reporting is currently... uh,
|
||||
interesting. Syntax for the templates
|
||||
interesting. Syntax for the templates::
|
||||
|
||||
### base.html
|
||||
<html>
|
||||
|
@ -57,7 +57,7 @@ interesting. Syntax for the templates
|
|||
|
||||
Unlike most other template systems, we do not put any restrictions on the
|
||||
expressions you can include in your statements. if and for blocks get
|
||||
translated exactly into Python, do you can do complex expressions like:
|
||||
translated exactly into Python, do you can do complex expressions like::
|
||||
|
||||
{% for student in [p for p in people if p.student and p.age > 23] %}
|
||||
<li>{{ escape(student.name) }}</li>
|
||||
|
@ -65,7 +65,7 @@ translated exactly into Python, do you can do complex expressions like:
|
|||
|
||||
Translating directly to Python means you can apply functions to expressions
|
||||
easily, like the escape() function in the examples above. You can pass
|
||||
functions in to your template just like any other variable:
|
||||
functions in to your template just like any other variable::
|
||||
|
||||
### Python code
|
||||
def add(x, y):
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
======================
|
||||
|
||||
.. automodule:: tornado.escape
|
||||
:members:
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
======================
|
||||
|
||||
.. automodule:: tornado.httpclient
|
||||
:members:
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
======================
|
||||
|
||||
.. automodule:: tornado.httpserver
|
||||
:members:
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
======================
|
||||
|
||||
.. automodule:: tornado.ioloop
|
||||
:members:
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
======================
|
||||
|
||||
.. automodule:: tornado.iostream
|
||||
:members:
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
======================
|
||||
|
||||
.. automodule:: tornado.locale
|
||||
:members:
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
======================
|
||||
|
||||
.. automodule:: tornado.template
|
||||
:members:
|
||||
|
|
Loading…
Reference in New Issue