Permalink
Browse files

Finish automatic documentation

  • Loading branch information...
1 parent f6b3651 commit 96c2f2f21f6a9a406e6824471a36dafbd33201c3 @bdarnell bdarnell committed Jun 11, 2011
View
Oops, something went wrong.
View
@@ -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"):
View
@@ -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
@@ -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"
@@ -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
@@ -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:
@@ -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
View
@@ -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.
@@ -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):
@@ -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)...])
@@ -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
@@ -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):
@@ -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() {
View
@@ -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
@@ -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"
@@ -2,3 +2,4 @@
======================
.. automodule:: tornado.auth
+ :members:
@@ -2,3 +2,4 @@
======================
.. automodule:: tornado.autoreload
+ :members:
@@ -2,3 +2,4 @@
======================
.. automodule:: tornado.database
+ :members:
@@ -2,3 +2,4 @@
======================
.. automodule:: tornado.httputil
+ :members:
@@ -2,3 +2,4 @@
======================
.. automodule:: tornado.options
+ :members:
@@ -2,3 +2,4 @@
=========================
.. automodule:: tornado.stack_context
+ :members:
@@ -2,3 +2,4 @@
======================
.. automodule:: tornado.testing
+ :members:
@@ -2,3 +2,4 @@
======================
.. automodule:: tornado.websocket
+ :members:
@@ -2,3 +2,4 @@
======================
.. automodule:: tornado.wsgi
+ :members:

0 comments on commit 96c2f2f

Please sign in to comment.