Skip to content

Commit 55d3be1

Browse files
committed
Run coverage check and fill in the blanks
1 parent 300d231 commit 55d3be1

File tree

13 files changed

+51
-6
lines changed

13 files changed

+51
-6
lines changed

tornado/httpserver.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ def start(self, num_processes=1):
267267
ioloop.IOLoop.READ)
268268

269269
def stop(self):
270+
"""Stops listening for new connections.
271+
272+
Requests currently in progress may still continue after the
273+
server is stopped.
274+
"""
270275
for fd, sock in self._sockets.iteritems():
271276
self.io_loop.remove_handler(fd)
272277
sock.close()
@@ -331,11 +336,13 @@ def __init__(self, stream, address, request_callback, no_keep_alive=False,
331336
self.stream.read_until(b("\r\n\r\n"), self._header_callback)
332337

333338
def write(self, chunk):
339+
"""Writes a chunk of output to the stream."""
334340
assert self._request, "Request closed"
335341
if not self.stream.closed():
336342
self.stream.write(chunk, self._on_write_complete)
337343

338344
def finish(self):
345+
"""Finishes the request."""
339346
assert self._request, "Request closed"
340347
self._request_finished = True
341348
if not self.stream.writing():

tornado/ioloop.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def __init__(self, io_loop=None):
155155

156156
@classmethod
157157
def initialized(cls):
158+
"""Returns true if the singleton instance has been created."""
158159
return hasattr(cls, "_instance")
159160

160161
def add_handler(self, fd, handler, events):
@@ -428,6 +429,8 @@ class PeriodicCallback(object):
428429
"""Schedules the given callback to be called periodically.
429430
430431
The callback is called every callback_time milliseconds.
432+
433+
`start` must be called after the PeriodicCallback is created.
431434
"""
432435
def __init__(self, callback, callback_time, io_loop=None):
433436
self.callback = callback
@@ -436,11 +439,13 @@ def __init__(self, callback, callback_time, io_loop=None):
436439
self._running = False
437440

438441
def start(self):
442+
"""Starts the timer."""
439443
self._running = True
440444
timeout = time.time() + self.callback_time / 1000.0
441445
self.io_loop.add_timeout(timeout, self._run)
442446

443447
def stop(self):
448+
"""Stops the timer."""
444449
self._running = False
445450

446451
def _run(self):

tornado/iostream.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ def writing(self):
191191
return bool(self._write_buffer)
192192

193193
def closed(self):
194+
"""Returns true if the stream has been closed."""
194195
return self.socket is None
195196

196197
def _handle_events(self, fd, events):

tornado/locale.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ def get_supported_locales(cls):
177177

178178

179179
class Locale(object):
180+
"""Object representing a locale.
181+
182+
After calling one of `load_translations` or `load_gettext_translations`,
183+
call `get` or `get_closest` to get a Locale object.
184+
"""
180185
@classmethod
181186
def get_closest(cls, *locale_codes):
182187
"""Returns the closest match for the given locale code."""
@@ -235,6 +240,12 @@ def __init__(self, code, translations):
235240
_("Friday"), _("Saturday"), _("Sunday")]
236241

237242
def translate(self, message, plural_message=None, count=None):
243+
"""Returns the translation for the given message for this locale.
244+
245+
If plural_message is given, you must also provide count. We return
246+
plural_message when count != 1, and we return the singular form
247+
for the given message when count == 1.
248+
"""
238249
raise NotImplementedError()
239250

240251
def format_date(self, date, gmt_offset=0, relative=True, shorter=False,
@@ -374,12 +385,6 @@ def friendly_number(self, value):
374385
class CSVLocale(Locale):
375386
"""Locale implementation using tornado's CSV translation format."""
376387
def translate(self, message, plural_message=None, count=None):
377-
"""Returns the translation for the given message for this locale.
378-
379-
If plural_message is given, you must also provide count. We return
380-
plural_message when count != 1, and we return the singular form
381-
for the given message when count == 1.
382-
"""
383388
if plural_message is not None:
384389
assert count is not None
385390
if count != 1:

tornado/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ def _parse_string(self, value):
306306

307307

308308
class Error(Exception):
309+
"""Exception raised by errors in the options module."""
309310
pass
310311

311312

tornado/template.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def _get_ancestors(self, loader):
180180

181181

182182
class BaseLoader(object):
183+
"""Base class for template loaders."""
183184
def __init__(self, root_directory, autoescape=_DEFAULT_AUTOESCAPE):
184185
"""Creates a template loader.
185186
@@ -194,9 +195,11 @@ def __init__(self, root_directory, autoescape=_DEFAULT_AUTOESCAPE):
194195
self.templates = {}
195196

196197
def reset(self):
198+
"""Resets the cache of compiled templates."""
197199
self.templates = {}
198200

199201
def resolve_path(self, name, parent_path=None):
202+
"""Converts a possibly-relative path to absolute (used internally)."""
200203
if parent_path and not parent_path.startswith("<") and \
201204
not parent_path.startswith("/") and \
202205
not name.startswith("/"):
@@ -208,6 +211,7 @@ def resolve_path(self, name, parent_path=None):
208211
return name
209212

210213
def load(self, name, parent_path=None):
214+
"""Loads a template."""
211215
name = self.resolve_path(name, parent_path=parent_path)
212216
if name not in self.templates:
213217
self.templates[name] = self._create_template(name)

tornado/web.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ def require_setting(self, name, feature="this feature"):
882882
"application to use %s" % (name, feature))
883883

884884
def reverse_url(self, name, *args):
885+
"""Alias for `Application.reverse_url`."""
885886
return self.application.reverse_url(name, *args)
886887

887888
def compute_etag(self):
@@ -1591,6 +1592,7 @@ def __init__(self, handler):
15911592
self.locale = handler.locale
15921593

15931594
def render(self, *args, **kwargs):
1595+
"""Overridden in subclasses to return this module's output."""
15941596
raise NotImplementedError()
15951597

15961598
def embedded_javascript(self):
@@ -1618,6 +1620,7 @@ def html_body(self):
16181620
return None
16191621

16201622
def render_string(self, path, **kwargs):
1623+
"""Renders a template and returns it as a string."""
16211624
return self.handler.render_string(path, **kwargs)
16221625

16231626
class _linkify(UIModule):

tornado/wsgi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ def start_response(status, response_headers, exc_info=None):
235235

236236
@staticmethod
237237
def environ(request):
238+
"""Converts a `tornado.httpserver.HTTPRequest` to a WSGI environment.
239+
"""
238240
hostport = request.host.split(":")
239241
if len(hostport) == 2:
240242
host = hostport[0]

website/sphinx/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
"TemplateModule",
3434
"url",
3535
]
36+
37+
coverage_ignore_functions = [
38+
# various modules
39+
"doctests",
40+
"main",
41+
]
3642

3743
html_static_path = [os.path.abspath("../static")]
3844
html_style = "sphinx.css"

website/sphinx/httpserver.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@
1111
HTTP Server
1212
-----------
1313
.. autoclass:: HTTPServer
14+
:members:
15+
1416
.. autoclass:: HTTPConnection
17+
:members:

website/sphinx/ioloop.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
^^^^^^^^^^^^^^^^^
1313

1414
.. automethod:: IOLoop.instance
15+
.. automethod:: IOLoop.initialized
1516
.. automethod:: IOLoop.start
1617
.. automethod:: IOLoop.stop
1718
.. automethod:: IOLoop.running
@@ -30,6 +31,7 @@
3031
.. automethod:: IOLoop.add_timeout
3132
.. automethod:: IOLoop.remove_timeout
3233
.. autoclass:: PeriodicCallback
34+
:members:
3335

3436
Debugging and error handling
3537
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

website/sphinx/testing.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@
2222
-----------
2323

2424
.. autofunction:: main
25+
26+
Helper functions
27+
----------------
28+
29+
.. autofunction:: get_unused_port

website/sphinx/web.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
.. automethod:: RequestHandler.get_user_locale
8181
.. automethod:: RequestHandler.on_connection_close
8282
.. automethod:: RequestHandler.require_setting
83+
.. automethod:: RequestHandler.reverse_url
8384
.. autoattribute:: RequestHandler.settings
8485
.. automethod:: RequestHandler.static_url
8586
.. automethod:: RequestHandler.xsrf_form_html

0 commit comments

Comments
 (0)