]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Run coverage check and fill in the blanks
authorBen Darnell <ben@bendarnell.com>
Sun, 19 Jun 2011 18:23:53 +0000 (11:23 -0700)
committerBen Darnell <ben@bendarnell.com>
Sun, 19 Jun 2011 18:23:53 +0000 (11:23 -0700)
13 files changed:
tornado/httpserver.py
tornado/ioloop.py
tornado/iostream.py
tornado/locale.py
tornado/options.py
tornado/template.py
tornado/web.py
tornado/wsgi.py
website/sphinx/conf.py
website/sphinx/httpserver.rst
website/sphinx/ioloop.rst
website/sphinx/testing.rst
website/sphinx/web.rst

index dcaff6429d94f1c7069622565b06c3cce20079a1..922232f6e6481595ed10b4cda62dd17b67e62b4a 100644 (file)
@@ -267,6 +267,11 @@ class HTTPServer(object):
                                          ioloop.IOLoop.READ)
 
     def stop(self):
+        """Stops listening for new connections.
+
+        Requests currently in progress may still continue after the
+        server is stopped.
+        """
         for fd, sock in self._sockets.iteritems():
             self.io_loop.remove_handler(fd)
             sock.close()
@@ -331,11 +336,13 @@ class HTTPConnection(object):
         self.stream.read_until(b("\r\n\r\n"), self._header_callback)
 
     def write(self, chunk):
+        """Writes a chunk of output to the stream."""
         assert self._request, "Request closed"
         if not self.stream.closed():
             self.stream.write(chunk, self._on_write_complete)
 
     def finish(self):
+        """Finishes the request."""
         assert self._request, "Request closed"
         self._request_finished = True
         if not self.stream.writing():
index b92ce1d3f3be61f2c086f66f1236d0061b896c40..a08afe22a5cd0f8c522414e202c521dc85dc077f 100644 (file)
@@ -155,6 +155,7 @@ class IOLoop(object):
 
     @classmethod
     def initialized(cls):
+        """Returns true if the singleton instance has been created."""
         return hasattr(cls, "_instance")
 
     def add_handler(self, fd, handler, events):
@@ -428,6 +429,8 @@ class PeriodicCallback(object):
     """Schedules the given callback to be called periodically.
 
     The callback is called every callback_time milliseconds.
+
+    `start` must be called after the PeriodicCallback is created.
     """
     def __init__(self, callback, callback_time, io_loop=None):
         self.callback = callback
@@ -436,11 +439,13 @@ class PeriodicCallback(object):
         self._running = False
 
     def start(self):
+        """Starts the timer."""
         self._running = True
         timeout = time.time() + self.callback_time / 1000.0
         self.io_loop.add_timeout(timeout, self._run)
 
     def stop(self):
+        """Stops the timer."""
         self._running = False
 
     def _run(self):
index bce6e633fc1ac984c4ae211530e5e5b374387416..d4b59b703446bbbb4bdff52fbdd8175976c2354f 100644 (file)
@@ -191,6 +191,7 @@ class IOStream(object):
         return bool(self._write_buffer)
 
     def closed(self):
+        """Returns true if the stream has been closed."""
         return self.socket is None
 
     def _handle_events(self, fd, events):
index f4b0b630ab9249fb01e2ba63e862a9eee3abe367..5d8def8e85e932b53f267765cc4746a73a5c24dc 100644 (file)
@@ -177,6 +177,11 @@ def get_supported_locales(cls):
 
 
 class Locale(object):
+    """Object representing a locale.
+
+    After calling one of `load_translations` or `load_gettext_translations`,
+    call `get` or `get_closest` to get a Locale object.
+    """
     @classmethod
     def get_closest(cls, *locale_codes):
         """Returns the closest match for the given locale code."""
@@ -235,6 +240,12 @@ class Locale(object):
             _("Friday"), _("Saturday"), _("Sunday")]
 
     def translate(self, message, plural_message=None, count=None):
+        """Returns the translation for the given message for this locale.
+
+        If plural_message is given, you must also provide count. We return
+        plural_message when count != 1, and we return the singular form
+        for the given message when count == 1.
+        """
         raise NotImplementedError()
 
     def format_date(self, date, gmt_offset=0, relative=True, shorter=False,
@@ -374,12 +385,6 @@ class Locale(object):
 class CSVLocale(Locale):
     """Locale implementation using tornado's CSV translation format."""
     def translate(self, message, plural_message=None, count=None):
-        """Returns the translation for the given message for this locale.
-
-        If plural_message is given, you must also provide count. We return
-        plural_message when count != 1, and we return the singular form
-        for the given message when count == 1.
-        """
         if plural_message is not None:
             assert count is not None
             if count != 1:
index 2a89e51d28836775e8bc3b845688f507dff9f5c6..b539e8e1b530740d56d54963651bddfdb396c9ca 100644 (file)
@@ -306,6 +306,7 @@ class _Option(object):
 
 
 class Error(Exception):
+    """Exception raised by errors in the options module."""
     pass
 
 
index 018a954ebb0e8cc42128cd8503324f25806f043f..4f9d51b4dd3a357ef7bf001dee350f7b0138ad0f 100644 (file)
@@ -180,6 +180,7 @@ class Template(object):
 
 
 class BaseLoader(object):
+    """Base class for template loaders."""
     def __init__(self, root_directory, autoescape=_DEFAULT_AUTOESCAPE):
         """Creates a template loader.
 
@@ -194,9 +195,11 @@ class BaseLoader(object):
         self.templates = {}
 
     def reset(self):
+        """Resets the cache of compiled templates."""
         self.templates = {}
 
     def resolve_path(self, name, parent_path=None):
+        """Converts a possibly-relative path to absolute (used internally)."""
         if parent_path and not parent_path.startswith("<") and \
            not parent_path.startswith("/") and \
            not name.startswith("/"):
@@ -208,6 +211,7 @@ class BaseLoader(object):
         return name
 
     def load(self, name, parent_path=None):
+        """Loads a template."""
         name = self.resolve_path(name, parent_path=parent_path)
         if name not in self.templates:
             self.templates[name] = self._create_template(name)
index ec2f2a77c8fd2dea6087ee05a36607eb6773f7f1..55989468e22101b0cacb5b28771cf6c257adb472 100644 (file)
@@ -882,6 +882,7 @@ class RequestHandler(object):
                             "application to use %s" % (name, feature))
 
     def reverse_url(self, name, *args):
+        """Alias for `Application.reverse_url`."""
         return self.application.reverse_url(name, *args)
 
     def compute_etag(self):
@@ -1591,6 +1592,7 @@ class UIModule(object):
         self.locale = handler.locale
 
     def render(self, *args, **kwargs):
+        """Overridden in subclasses to return this module's output."""
         raise NotImplementedError()
 
     def embedded_javascript(self):
@@ -1618,6 +1620,7 @@ class UIModule(object):
         return None
 
     def render_string(self, path, **kwargs):
+        """Renders a template and returns it as a string."""
         return self.handler.render_string(path, **kwargs)
 
 class _linkify(UIModule):
index 6527d30c892c16e9f17c9916bf8dcb8c95f5f28d..fb8bd49678251cb58c1cf4332a81f1c56d7feda5 100644 (file)
@@ -235,6 +235,8 @@ class WSGIContainer(object):
 
     @staticmethod
     def environ(request):
+        """Converts a `tornado.httpserver.HTTPRequest` to a WSGI environment.
+        """
         hostport = request.host.split(":")
         if len(hostport) == 2:
             host = hostport[0]
index fd7c5db93f8fe88bd6cab948dfda6df3b45683b3..1b89d28be99aabbc57e7aa65b0a85c20a9a31825 100644 (file)
@@ -33,6 +33,12 @@ coverage_ignore_classes = [
     "TemplateModule",
     "url",
     ]
+
+coverage_ignore_functions = [
+    # various modules
+    "doctests",
+    "main",
+]
     
 html_static_path = [os.path.abspath("../static")]
 html_style = "sphinx.css"
index b38bb497138d342943c15f7ef726874f8fbd3938..4498d0911dfa085297d938b4f829775005d561ea 100644 (file)
@@ -11,4 +11,7 @@
    HTTP Server
    -----------
    .. autoclass:: HTTPServer
+      :members:
+
    .. autoclass:: HTTPConnection
+      :members:
index 58d6ec4aa848681e76ea90648fed1d9aae237e23..1ff1723194bd3db324a7dad9a4249eefeeaf889d 100644 (file)
@@ -12,6 +12,7 @@
    ^^^^^^^^^^^^^^^^^
 
    .. automethod:: IOLoop.instance
+   .. automethod:: IOLoop.initialized
    .. automethod:: IOLoop.start
    .. automethod:: IOLoop.stop
    .. automethod:: IOLoop.running
@@ -30,6 +31,7 @@
    .. automethod:: IOLoop.add_timeout
    .. automethod:: IOLoop.remove_timeout
    .. autoclass:: PeriodicCallback
+      :members:
 
    Debugging and error handling
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index fdb1008d58c0ed8d64908d74da664dc1ef598566..5b8758c3847593aea73b7c05744a5d7928b8b7f1 100644 (file)
@@ -22,3 +22,8 @@
    -----------
 
    .. autofunction:: main
+
+   Helper functions
+   ----------------
+
+   .. autofunction:: get_unused_port
index 3cd91aec37291a72af3d756e4a9a03c1e49d5244..fd1af5b8735865f0bd00cf7d19b3fa48064c237a 100644 (file)
@@ -80,6 +80,7 @@
    .. automethod:: RequestHandler.get_user_locale
    .. automethod:: RequestHandler.on_connection_close
    .. automethod:: RequestHandler.require_setting
+   .. automethod:: RequestHandler.reverse_url
    .. autoattribute:: RequestHandler.settings
    .. automethod:: RequestHandler.static_url
    .. automethod:: RequestHandler.xsrf_form_html