Skip to content

Commit 53f5f3c

Browse files
committed
Fix up docs for web.py
1 parent 4fec6ae commit 53f5f3c

File tree

2 files changed

+87
-14
lines changed

2 files changed

+87
-14
lines changed

tornado/web.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17-
"""The Tornado web framework.
18-
17+
"""
1918
The Tornado web framework looks a bit like web.py (http://webpy.org/) or
2019
Google's webapp (http://code.google.com/appengine/docs/python/tools/webapp/),
2120
but with additional tools and optimizations to take advantage of the
2221
Tornado non-blocking web server and tools.
2322
24-
Here is the canonical "Hello, world" example app:
23+
Here is the canonical "Hello, world" example app::
2524
2625
import tornado.ioloop
2726
import tornado.web
@@ -40,7 +39,8 @@ def get(self):
4039
See the Tornado walkthrough on http://tornadoweb.org for more details
4140
and a good getting started guide.
4241
43-
Thread-safety notes:
42+
Thread-safety notes
43+
-------------------
4444
4545
In general, methods on RequestHandler and elsewhere in tornado are not
4646
thread-safe. In particular, methods such as write(), finish(), and
@@ -120,7 +120,7 @@ def initialize(self):
120120
A dictionary passed as the third argument of a url spec will be
121121
supplied as keyword arguments to initialize().
122122
123-
Example:
123+
Example::
124124
class ProfileHandler(RequestHandler):
125125
def initialize(self, database):
126126
self.database = database
@@ -984,7 +984,7 @@ def asynchronous(method):
984984
If this decorator is given, the response is not finished when the
985985
method returns. It is up to the request handler to call self.finish()
986986
to finish the HTTP request. Without this decorator, the request is
987-
automatically finished when the get() or post() method returns.
987+
automatically finished when the get() or post() method returns. ::
988988
989989
class MyRequestHandler(web.RequestHandler):
990990
@web.asynchronous
@@ -1009,9 +1009,9 @@ def wrapper(self, *args, **kwargs):
10091009
def removeslash(method):
10101010
"""Use this decorator to remove trailing slashes from the request path.
10111011
1012-
For example, a request to '/foo/' would redirect to '/foo' with this
1012+
For example, a request to ``'/foo/'`` would redirect to ``'/foo'`` with this
10131013
decorator. Your request handler mapping should use a regular expression
1014-
like r'/foo/*' in conjunction with using the decorator.
1014+
like ``r'/foo/*'`` in conjunction with using the decorator.
10151015
"""
10161016
@functools.wraps(method)
10171017
def wrapper(self, *args, **kwargs):
@@ -1052,7 +1052,7 @@ class Application(object):
10521052
"""A collection of request handlers that make up a web application.
10531053
10541054
Instances of this class are callable and can be passed directly to
1055-
HTTPServer to serve the application:
1055+
HTTPServer to serve the application::
10561056
10571057
application = web.Application([
10581058
(r"/", MainPageHandler),
@@ -1069,14 +1069,14 @@ class Application(object):
10691069
Each tuple can contain an optional third element, which should be a
10701070
dictionary if it is present. That dictionary is passed as keyword
10711071
arguments to the contructor of the handler. This pattern is used
1072-
for the StaticFileHandler below:
1072+
for the StaticFileHandler below::
10731073
10741074
application = web.Application([
10751075
(r"/static/(.*)", web.StaticFileHandler, {"path": "/var/www"}),
10761076
])
10771077
10781078
We support virtual hosts with the add_handlers method, which takes in
1079-
a host regular expression as the first argument:
1079+
a host regular expression as the first argument::
10801080
10811081
application.add_handlers(r"www\.myhost\.com", [
10821082
(r"/article/([0-9]+)", ArticleHandler),
@@ -1333,7 +1333,7 @@ def prepare(self):
13331333
class RedirectHandler(RequestHandler):
13341334
"""Redirects the client to the given URL for all GET requests.
13351335
1336-
You should provide the keyword argument "url" to the handler, e.g.:
1336+
You should provide the keyword argument "url" to the handler, e.g.::
13371337
13381338
application = web.Application([
13391339
(r"/oldpath", web.RedirectHandler, {"url": "/newpath"}),
@@ -1351,7 +1351,7 @@ class StaticFileHandler(RequestHandler):
13511351
"""A simple handler that can serve static content from a directory.
13521352
13531353
To map a path to this handler for a static data directory /var/www,
1354-
you would add a line to your application like:
1354+
you would add a line to your application like::
13551355
13561356
application = web.Application([
13571357
(r"/static/(.*)", web.StaticFileHandler, {"path": "/var/www"}),
@@ -1438,7 +1438,8 @@ class FallbackHandler(RequestHandler):
14381438
The fallback is a callable object that accepts an HTTPRequest,
14391439
such as an Application or tornado.wsgi.WSGIContainer. This is most
14401440
useful to use both tornado RequestHandlers and WSGI in the same server.
1441-
Typical usage:
1441+
Typical usage::
1442+
14421443
wsgi_app = tornado.wsgi.WSGIContainer(
14431444
django.core.handlers.wsgi.WSGIHandler())
14441445
application = tornado.web.Application([

website/sphinx/web.rst

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,75 @@
22
===============
33

44
.. automodule:: tornado.web
5+
:exclude-members: RequestHandler, Application, asynchronous, addslash, removeslash, URLSpec, url
6+
7+
Request handlers
8+
----------------
9+
.. autoclass:: RequestHandler
10+
:exclude-members: initialize, prepare, get, post, put, delete, head, options, get_argument, get_arguments, decode_argument, set_status, set_header, write, flush, finish, render, render_string, send_error, get_error_html, cookies, get_cookie, set_cookie, clear_cookie, clear_all_cookies, get_secure_cookie, set_secure_cookie, create_signed_value
11+
12+
**Entry points**
13+
14+
.. automethod:: initialize
15+
.. automethod:: prepare
16+
17+
Implement any of the following methods to handle the corresponding
18+
HTTP method.
19+
20+
.. automethod:: get
21+
.. automethod:: post
22+
.. automethod:: put
23+
.. automethod:: delete
24+
.. automethod:: head
25+
.. automethod:: options
26+
27+
**Input**
28+
29+
.. automethod:: get_argument
30+
.. automethod:: get_arguments
31+
.. automethod:: decode_argument
32+
33+
**Output**
34+
35+
.. automethod:: set_status
36+
.. automethod:: set_header
37+
.. automethod:: write
38+
.. automethod:: flush
39+
.. automethod:: finish
40+
.. automethod:: render
41+
.. automethod:: render_string
42+
.. automethod:: send_error
43+
.. automethod:: get_error_html
44+
45+
**Cookies**
46+
47+
.. autoattribute:: cookies
48+
.. automethod:: get_cookie
49+
.. automethod:: set_cookie
50+
.. automethod:: clear_cookie
51+
.. automethod:: clear_all_cookies
52+
.. automethod:: get_secure_cookie
53+
.. automethod:: set_secure_cookie
54+
.. automethod:: create_signed_value
55+
56+
**Other**
57+
58+
59+
60+
Application configuration
61+
-----------------------------
62+
.. autoclass:: Application
63+
64+
.. autoclass:: URLSpec
65+
66+
The ``URLSpec`` class is also available under the name ``tornado.web.url``.
67+
68+
Decorators
69+
----------
70+
.. autofunction:: asynchronous
71+
.. autofunction:: authenticated
72+
.. autofunction:: addslash
73+
.. autofunction:: removeslash
74+
75+
Everything else
76+
---------------

0 commit comments

Comments
 (0)