Permalink
Browse files

Run coverage check and fill in the blanks

  • Loading branch information...
1 parent 300d231 commit 55d3be101ebf0821d19b5aadf799e8f65ff16276 @bdarnell bdarnell committed Jun 19, 2011
View
@@ -267,6 +267,11 @@ def start(self, num_processes=1):
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 @@ def __init__(self, stream, address, request_callback, no_keep_alive=False,
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():
View
@@ -155,6 +155,7 @@ def __init__(self, io_loop=None):
@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 @@ def __init__(self, callback, callback_time, io_loop=None):
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):
View
@@ -191,6 +191,7 @@ def writing(self):
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):
View
@@ -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 @@ def __init__(self, code, translations):
_("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 @@ def friendly_number(self, value):
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:
View
@@ -306,6 +306,7 @@ def _parse_string(self, value):
class Error(Exception):
+ """Exception raised by errors in the options module."""
pass
View
@@ -180,6 +180,7 @@ def _get_ancestors(self, loader):
class BaseLoader(object):
+ """Base class for template loaders."""
def __init__(self, root_directory, autoescape=_DEFAULT_AUTOESCAPE):
"""Creates a template loader.
@@ -194,9 +195,11 @@ def __init__(self, root_directory, autoescape=_DEFAULT_AUTOESCAPE):
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 @@ def resolve_path(self, name, parent_path=None):
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)
View
@@ -882,6 +882,7 @@ def require_setting(self, name, feature="this feature"):
"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 @@ def __init__(self, handler):
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 @@ def html_body(self):
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):
View
@@ -235,6 +235,8 @@ def start_response(status, response_headers, exc_info=None):
@staticmethod
def environ(request):
+ """Converts a `tornado.httpserver.HTTPRequest` to a WSGI environment.
+ """
hostport = request.host.split(":")
if len(hostport) == 2:
host = hostport[0]
View
@@ -33,6 +33,12 @@
"TemplateModule",
"url",
]
+
+coverage_ignore_functions = [
+ # various modules
+ "doctests",
+ "main",
+]
html_static_path = [os.path.abspath("../static")]
html_style = "sphinx.css"
@@ -11,4 +11,7 @@
HTTP Server
-----------
.. autoclass:: HTTPServer
+ :members:
+
.. autoclass:: HTTPConnection
+ :members:
@@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -22,3 +22,8 @@
-----------
.. autofunction:: main
+
+ Helper functions
+ ----------------
+
+ .. autofunction:: get_unused_port
View
@@ -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

0 comments on commit 55d3be1

Please sign in to comment.