Skip to content

Commit

Permalink
Finish automatic documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Jun 11, 2011
1 parent f6b3651 commit 96c2f2f
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 174 deletions.
315 changes: 158 additions & 157 deletions tornado/auth.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tornado/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Connection(object):
"""A lightweight wrapper around MySQLdb DB-API connections.
The main value we provide is wrapping rows in a dict/object so that
columns can be accessed by name. Typical usage:
columns can be accessed by name. Typical usage::
db = database.Connection("localhost", "mydatabase")
for article in db.query("SELECT * FROM articles"):
Expand Down
8 changes: 4 additions & 4 deletions tornado/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

"""A command line parsing module that lets modules define their own options.
Each module defines its own options, e.g.,
Each module defines its own options, e.g.::
from tornado.options import define, options
Expand All @@ -31,14 +31,14 @@ def connect():
The main() method of your application does not need to be aware of all of
the options used throughout your program; they are all automatically loaded
when the modules are loaded. Your main() method can parse the command line
or parse a config file with:
or parse a config file with::
import tornado.options
tornado.options.parse_config_file("/etc/server.conf")
tornado.options.parse_command_line()
Command line formats are what you would expect ("--myoption=myvalue").
Config files are just Python files. Global names become options, e.g.,
Config files are just Python files. Global names become options, e.g.::
myoption = "myvalue"
myotheroption = "myothervalue"
Expand Down Expand Up @@ -77,7 +77,7 @@ def define(name, default=None, type=None, help=None, metavar=None,
turns into range(x, y) - very useful for long integer ranges.
help and metavar are used to construct the automatically generated
command line help string. The help message is formatted like:
command line help string. The help message is formatted like::
--name=METAVAR help string
Expand Down
10 changes: 7 additions & 3 deletions tornado/stack_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
that transfer control from one context to another (e.g. AsyncHTTPClient
itself, IOLoop, thread pools, etc).
Example usage:
Example usage::
@contextlib.contextmanager
def die_on_error():
try:
Expand Down Expand Up @@ -65,9 +66,12 @@ def __init__(self, context_factory):
Note that the parameter is a callable that returns a context
manager, not the context itself. That is, where for a
non-transferable context manager you would say
non-transferable context manager you would say::
with my_context():
StackContext takes the function itself rather than its result:
StackContext takes the function itself rather than its result::
with StackContext(my_context):
'''
self.context_factory = context_factory
Expand Down
16 changes: 12 additions & 4 deletions tornado/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
"""Support classes for automated testing.
This module contains three parts:
* AsyncTestCase/AsyncHTTPTestCase: Subclasses of unittest.TestCase
with additional support for testing asynchronous (IOLoop-based) code.
* LogTrapTestCase: Subclass of unittest.TestCase that discards log output
from tests that pass and only produces output for failing tests.
* main(): A simple test runner (wrapper around unittest.main()) with support
for the tornado.autoreload module to rerun the tests when code changes.
Expand Down Expand Up @@ -56,7 +59,8 @@ class AsyncTestCase(unittest.TestCase):
returned from self.wait. It is possible to have multiple
wait/stop cycles in the same test.
Example:
Example::
# This test uses an asynchronous style similar to most async
# application code.
class MyTestCase(AsyncTestCase):
Expand Down Expand Up @@ -196,7 +200,8 @@ class AsyncHTTPTestCase(AsyncTestCase):
Tests will typically use the provided self.http_client to fetch
URLs from this server.
Example:
Example::
class MyHTTPTest(AsyncHTTPTestCase):
def get_app(self):
return Application([('/', MyHandler)...])
Expand Down Expand Up @@ -303,16 +308,19 @@ def run(self, result=None):
def main():
"""A simple test runner with autoreload support.
The easiest way to run a test is via the command line:
The easiest way to run a test is via the command line::
python -m tornado.testing --autoreload tornado.test.stack_context_test
See the standard library unittest module for ways in which tests can
be specified.
Projects with many tests may wish to define a test script like
tornado/test/runtests.py. This script should define a method all()
which returns a test suite and then call tornado.testing.main().
Note that even when a test script is used, the all() test suite may
be overridden by naming a single test on the command line.
be overridden by naming a single test on the command line::
# Runs all tests
tornado/test/runtests.py --autoreload
# Runs one test
Expand Down
4 changes: 2 additions & 2 deletions tornado/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class WebSocketHandler(tornado.web.RequestHandler):
http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76.
Here is an example Web Socket handler that echos back all received messages
back to the client:
back to the client::
class EchoWebSocket(websocket.WebSocketHandler):
def open(self):
Expand All @@ -53,7 +53,7 @@ def on_close(self):
implement open() method rather than get() or post().
If you map the handler above to "/websocket" in your application, you can
invoke it in JavaScript with:
invoke it in JavaScript with::
var ws = new WebSocket("ws://localhost:8888/websocket");
ws.onopen = function() {
Expand Down
6 changes: 3 additions & 3 deletions tornado/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
asynchronous methods in your request handlers running in a WSGIApplication,
we throw an exception.
Example usage:
Example usage::
import tornado.web
import tornado.wsgi
Expand Down Expand Up @@ -165,10 +165,10 @@ def request_time(self):


class WSGIContainer(object):
"""Makes a WSGI-compatible function runnable on Tornado's HTTP server.
r"""Makes a WSGI-compatible function runnable on Tornado's HTTP server.
Wrap a WSGI function in a WSGIContainer and pass it to HTTPServer to
run it. For example:
run it. For example::
def simple_app(environ, start_response):
status = "200 OK"
Expand Down
1 change: 1 addition & 0 deletions website/sphinx/auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
======================

.. automodule:: tornado.auth
:members:
1 change: 1 addition & 0 deletions website/sphinx/autoreload.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
======================

.. automodule:: tornado.autoreload
:members:
1 change: 1 addition & 0 deletions website/sphinx/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
======================

.. automodule:: tornado.database
:members:
1 change: 1 addition & 0 deletions website/sphinx/httputil.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
======================

.. automodule:: tornado.httputil
:members:
1 change: 1 addition & 0 deletions website/sphinx/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
======================

.. automodule:: tornado.options
:members:
1 change: 1 addition & 0 deletions website/sphinx/stack_context.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
=========================

.. automodule:: tornado.stack_context
:members:
1 change: 1 addition & 0 deletions website/sphinx/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
======================

.. automodule:: tornado.testing
:members:
1 change: 1 addition & 0 deletions website/sphinx/websocket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
======================

.. automodule:: tornado.websocket
:members:
1 change: 1 addition & 0 deletions website/sphinx/wsgi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
======================

.. automodule:: tornado.wsgi
:members:

0 comments on commit 96c2f2f

Please sign in to comment.