Skip to content

Commit 89993db

Browse files
authored
Merge pull request #2586 from sadielbartholomew/minor-docs-improvements
docs: assorted minor e.g. formatting improvements
2 parents 84af944 + 49241f3 commit 89993db

File tree

18 files changed

+120
-109
lines changed

18 files changed

+120
-109
lines changed

docs/faq.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ See the :doc:`Asynchronous I/O <guide/async>` chapter of the Tornado
7474
user's guide for more on blocking and asynchronous functions.
7575

7676

77-
My code is asynchronous, but it's not running in parallel in two browser tabs.
78-
------------------------------------------------------------------------------
77+
My code is asynchronous. Why is it not running in parallel in two browser tabs?
78+
-------------------------------------------------------------------------------
7979

8080
Even when a handler is asynchronous and non-blocking, it can be surprisingly
8181
tricky to verify this. Browsers will recognize that you are trying to

docs/guide/coroutines.rst

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ decorator.
3939

4040
Native coroutines are the recommended form whenever possible. Only use
4141
decorated coroutines when compatibility with older versions of Python
42-
is required. Examples in the tornado documentation will generally use
42+
is required. Examples in the Tornado documentation will generally use
4343
the native form.
4444

4545
Translation between the two forms is generally straightforward::
@@ -58,30 +58,35 @@ Translation between the two forms is generally straightforward::
5858
# special exception. # Return normally
5959
raise gen.Return(b) return b
6060

61-
Other differences between the two forms of coroutine are:
62-
63-
- Native coroutines are generally faster.
64-
- Native coroutines can use ``async for`` and ``async with``
65-
statements which make some patterns much simpler.
66-
- Native coroutines do not run at all unless you ``await`` or
67-
``yield`` them. Decorated coroutines can start running "in the
68-
background" as soon as they are called. Note that for both kinds of
69-
coroutines it is important to use ``await`` or ``yield`` so that
70-
any exceptions have somewhere to go.
71-
- Decorated coroutines have additional integration with the
72-
`concurrent.futures` package, allowing the result of
73-
``executor.submit`` to be yielded directly. For native coroutines,
74-
use `.IOLoop.run_in_executor` instead.
75-
- Decorated coroutines support some shorthand for waiting on multiple
76-
objects by yielding a list or dict. Use `tornado.gen.multi` to do
77-
this in native coroutines.
78-
- Decorated coroutines can support integration with other packages
79-
including Twisted via a registry of conversion functions.
80-
To access this functionality in native coroutines, use
81-
`tornado.gen.convert_yielded`.
82-
- Decorated coroutines always return a `.Future` object. Native
83-
coroutines return an *awaitable* object that is not a `.Future`. In
84-
Tornado the two are mostly interchangeable.
61+
Other differences between the two forms of coroutine are outlined below.
62+
63+
- Native coroutines:
64+
65+
- are generally faster.
66+
- can use ``async for`` and ``async with``
67+
statements which make some patterns much simpler.
68+
- do not run at all unless you ``await`` or
69+
``yield`` them. Decorated coroutines can start running "in the
70+
background" as soon as they are called. Note that for both kinds of
71+
coroutines it is important to use ``await`` or ``yield`` so that
72+
any exceptions have somewhere to go.
73+
74+
- Decorated coroutines:
75+
76+
- have additional integration with the
77+
`concurrent.futures` package, allowing the result of
78+
``executor.submit`` to be yielded directly. For native coroutines,
79+
use `.IOLoop.run_in_executor` instead.
80+
- support some shorthand for waiting on multiple
81+
objects by yielding a list or dict. Use `tornado.gen.multi` to do
82+
this in native coroutines.
83+
- can support integration with other packages
84+
including Twisted via a registry of conversion functions.
85+
To access this functionality in native coroutines, use
86+
`tornado.gen.convert_yielded`.
87+
- always return a `.Future` object. Native
88+
coroutines return an *awaitable* object that is not a `.Future`. In
89+
Tornado the two are mostly interchangeable.
8590

8691
How it works
8792
~~~~~~~~~~~~

docs/guide/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ alternative to `WSGI <http://www.python.org/dev/peps/pep-3333/>`_.
2929
While it is possible to use the Tornado HTTP server as a container for
3030
other WSGI frameworks (`.WSGIContainer`), this combination has
3131
limitations and to take full advantage of Tornado you will need to use
32-
the Tornado's web framework and HTTP server together.
32+
Tornado's web framework and HTTP server together.

docs/guide/running.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ configuring a WSGI container to find your application, you write a
2222
Configure your operating system or process manager to run this program to
2323
start the server. Please note that it may be necessary to increase the number
2424
of open files per process (to avoid "Too many open files"-Error).
25-
To raise this limit (setting it to 50000 for example) you can use the ulimit command,
26-
modify /etc/security/limits.conf or setting ``minfds`` in your supervisord config.
25+
To raise this limit (setting it to 50000 for example) you can use the
26+
``ulimit`` command, modify ``/etc/security/limits.conf`` or set
27+
``minfds`` in your `supervisord <http://www.supervisord.org>`_ config.
2728

2829
Processes and ports
2930
~~~~~~~~~~~~~~~~~~~
@@ -50,8 +51,8 @@ main function:
5051

5152
This is the easiest way to start multiple processes and have them all
5253
share the same port, although it has some limitations. First, each
53-
child process will have its own IOLoop, so it is important that
54-
nothing touch the global IOLoop instance (even indirectly) before the
54+
child process will have its own ``IOLoop``, so it is important that
55+
nothing touches the global ``IOLoop`` instance (even indirectly) before the
5556
fork. Second, it is difficult to do zero-downtime updates in this model.
5657
Finally, since all the processes share the same port it is more difficult
5758
to monitor them individually.
@@ -67,10 +68,10 @@ to present a single address to outside visitors.
6768
Running behind a load balancer
6869
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6970

70-
When running behind a load balancer like nginx, it is recommended to
71-
pass ``xheaders=True`` to the `.HTTPServer` constructor. This will tell
72-
Tornado to use headers like ``X-Real-IP`` to get the user's IP address
73-
instead of attributing all traffic to the balancer's IP address.
71+
When running behind a load balancer like `nginx <http://nginx.net/>`_,
72+
it is recommended to pass ``xheaders=True`` to the `.HTTPServer` constructor.
73+
This will tell Tornado to use headers like ``X-Real-IP`` to get the user's
74+
IP address instead of attributing all traffic to the balancer's IP address.
7475

7576
This is a barebones nginx config file that is structurally similar to
7677
the one we use at FriendFeed. It assumes nginx and the Tornado servers
@@ -169,7 +170,7 @@ You can serve static files from Tornado by specifying the
169170
], **settings)
170171

171172
This setting will automatically make all requests that start with
172-
``/static/`` serve from that static directory, e.g.,
173+
``/static/`` serve from that static directory, e.g.
173174
``http://localhost:8888/static/foo.png`` will serve the file
174175
``foo.png`` from the specified static directory. We also automatically
175176
serve ``/robots.txt`` and ``/favicon.ico`` from the static directory
@@ -248,7 +249,7 @@ individual flag takes precedence):
248249
server down in a way that debug mode cannot currently recover from.
249250
* ``compiled_template_cache=False``: Templates will not be cached.
250251
* ``static_hash_cache=False``: Static file hashes (used by the
251-
``static_url`` function) will not be cached
252+
``static_url`` function) will not be cached.
252253
* ``serve_traceback=True``: When an exception in a `.RequestHandler`
253254
is not caught, an error page including a stack trace will be
254255
generated.

docs/guide/structure.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ In addition to ``get()``/``post()``/etc, certain other methods in
178178
necessary. On every request, the following sequence of calls takes
179179
place:
180180

181-
1. A new `.RequestHandler` object is created on each request
181+
1. A new `.RequestHandler` object is created on each request.
182182
2. `~.RequestHandler.initialize()` is called with the initialization
183183
arguments from the `.Application` configuration. ``initialize``
184184
should typically just save the arguments passed into member
@@ -206,12 +206,12 @@ overridden methods include:
206206
disconnects; applications may choose to detect this case and halt
207207
further processing. Note that there is no guarantee that a closed
208208
connection can be detected promptly.
209-
- `~.RequestHandler.get_current_user` - see :ref:`user-authentication`
209+
- `~.RequestHandler.get_current_user` - see :ref:`user-authentication`.
210210
- `~.RequestHandler.get_user_locale` - returns `.Locale` object to use
211-
for the current user
211+
for the current user.
212212
- `~.RequestHandler.set_default_headers` - may be used to set
213213
additional headers on the response (such as a custom ``Server``
214-
header)
214+
header).
215215

216216
Error Handling
217217
~~~~~~~~~~~~~~
@@ -260,7 +260,7 @@ redirect users elsewhere. There is also an optional parameter
260260
considered permanent. The default value of ``permanent`` is
261261
``False``, which generates a ``302 Found`` HTTP response code and is
262262
appropriate for things like redirecting users after successful
263-
``POST`` requests. If ``permanent`` is true, the ``301 Moved
263+
``POST`` requests. If ``permanent`` is ``True``, the ``301 Moved
264264
Permanently`` HTTP response code is used, which is useful for
265265
e.g. redirecting to a canonical URL for a page in an SEO-friendly
266266
manner.

docs/guide/templates.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ directory as your Python file, you could render this template with:
6666
:hide:
6767

6868
Tornado templates support *control statements* and *expressions*.
69-
Control statements are surrounded by ``{%`` and ``%}``, e.g.,
69+
Control statements are surrounded by ``{%`` and ``%}``, e.g.
7070
``{% if len(items) > 2 %}``. Expressions are surrounded by ``{{`` and
71-
``}}``, e.g., ``{{ items[0] }}``.
71+
``}}``, e.g. ``{{ items[0] }}``.
7272

7373
Control statements more or less map exactly to Python statements. We
7474
support ``if``, ``for``, ``while``, and ``try``, all of which are
@@ -78,7 +78,7 @@ detail in the documentation for the `tornado.template`.
7878

7979
Expressions can be any Python expression, including function calls.
8080
Template code is executed in a namespace that includes the following
81-
objects and functions (Note that this list applies to templates
81+
objects and functions. (Note that this list applies to templates
8282
rendered using `.RequestHandler.render` and
8383
`~.RequestHandler.render_string`. If you're using the
8484
`tornado.template` module directly outside of a `.RequestHandler` many
@@ -136,7 +136,8 @@ that appear in certain locations, such as in Javascript or CSS, may need
136136
additional escaping. Additionally, either care must be taken to always
137137
use double quotes and `.xhtml_escape` in HTML attributes that may contain
138138
untrusted content, or a separate escaping function must be used for
139-
attributes (see e.g. http://wonko.com/post/html-escaping)
139+
attributes (see e.g.
140+
`this blog post <http://wonko.com/post/html-escaping>`_).
140141

141142
Internationalization
142143
~~~~~~~~~~~~~~~~~~~~
@@ -212,7 +213,7 @@ formats: the ``.mo`` format used by `gettext` and related tools, and a
212213
simple ``.csv`` format. An application will generally call either
213214
`tornado.locale.load_translations` or
214215
`tornado.locale.load_gettext_translations` once at startup; see those
215-
methods for more details on the supported formats..
216+
methods for more details on the supported formats.
216217

217218
You can get the list of supported locales in your application with
218219
`tornado.locale.get_supported_locales()`. The user's locale is chosen
@@ -234,7 +235,7 @@ packaged with their own CSS and JavaScript.
234235
For example, if you are implementing a blog, and you want to have blog
235236
entries appear on both the blog home page and on each blog entry page,
236237
you can make an ``Entry`` module to render them on both pages. First,
237-
create a Python module for your UI modules, e.g., ``uimodules.py``::
238+
create a Python module for your UI modules, e.g. ``uimodules.py``::
238239

239240
class Entry(tornado.web.UIModule):
240241
def render(self, entry, show_comments=False):

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Quick links
2121
-----------
2222

2323
* Current version: |version| (`download from PyPI <https://pypi.python.org/pypi/tornado>`_, :doc:`release notes <releases>`)
24-
* `Source (github) <https://github.com/tornadoweb/tornado>`_
24+
* `Source (GitHub) <https://github.com/tornadoweb/tornado>`_
2525
* Mailing lists: `discussion <http://groups.google.com/group/python-tornado>`_ and `announcements <http://groups.google.com/group/python-tornado-announce>`_
2626
* `Stack Overflow <http://stackoverflow.com/questions/tagged/tornado>`_
2727
* `Wiki <https://github.com/tornadoweb/tornado/wiki/Links>`_

docs/web.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
The arguments to these methods come from the `.URLSpec`: Any
2929
capturing groups in the regular expression become arguments to the
3030
HTTP verb methods (keyword arguments if the group is named,
31-
positional arguments if its unnamed).
31+
positional arguments if it's unnamed).
3232

3333
To support a method not on this list, override the class variable
3434
``SUPPORTED_METHODS``::
@@ -159,7 +159,8 @@
159159

160160

161161
Application configuration
162-
-----------------------------
162+
-------------------------
163+
163164
.. autoclass:: Application(handlers: List[Union[Rule, Tuple]] = None, default_host: str = None, transforms: List[Type[OutputTransform]] = None, **settings)
164165

165166
.. attribute:: settings
@@ -197,7 +198,7 @@
197198
`RequestHandler` object). The default implementation
198199
writes to the `logging` module's root logger. May also be
199200
customized by overriding `Application.log_request`.
200-
* ``serve_traceback``: If true, the default error page
201+
* ``serve_traceback``: If ``True``, the default error page
201202
will include the traceback of the error. This option is new in
202203
Tornado 3.2; previously this functionality was controlled by
203204
the ``debug`` setting.
@@ -224,7 +225,7 @@
224225
* ``login_url``: The `authenticated` decorator will redirect
225226
to this url if the user is not logged in. Can be further
226227
customized by overriding `RequestHandler.get_login_url`
227-
* ``xsrf_cookies``: If true, :ref:`xsrf` will be enabled.
228+
* ``xsrf_cookies``: If ``True``, :ref:`xsrf` will be enabled.
228229
* ``xsrf_cookie_version``: Controls the version of new XSRF
229230
cookies produced by this server. Should generally be left
230231
at the default (which will always be the highest supported

tornado/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ class GoogleOAuth2Mixin(OAuth2Mixin):
840840
* In the OAuth section of the page, select Create New Client ID.
841841
* Set the Redirect URI to point to your auth handler
842842
* Copy the "Client secret" and "Client ID" to the application settings as
843-
{"google_oauth": {"key": CLIENT_ID, "secret": CLIENT_SECRET}}
843+
``{"google_oauth": {"key": CLIENT_ID, "secret": CLIENT_SECRET}}``
844844
845845
.. versionadded:: 3.2
846846
"""

tornado/concurrent.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def future_set_result_unless_cancelled(
176176
) -> None:
177177
"""Set the given ``value`` as the `Future`'s result, if not cancelled.
178178
179-
Avoids asyncio.InvalidStateError when calling set_result() on
179+
Avoids ``asyncio.InvalidStateError`` when calling ``set_result()`` on
180180
a cancelled `asyncio.Future`.
181181
182182
.. versionadded:: 5.0
@@ -192,10 +192,10 @@ def future_set_exception_unless_cancelled(
192192
193193
If the Future is already canceled, logs the exception instead. If
194194
this logging is not desired, the caller should explicitly check
195-
the state of the Future and call Future.set_exception instead of
195+
the state of the Future and call ``Future.set_exception`` instead of
196196
this wrapper.
197197
198-
Avoids asyncio.InvalidStateError when calling set_exception() on
198+
Avoids ``asyncio.InvalidStateError`` when calling ``set_exception()`` on
199199
a cancelled `asyncio.Future`.
200200
201201
.. versionadded:: 6.0
@@ -223,7 +223,7 @@ def future_set_exc_info(
223223
.. versionchanged:: 6.0
224224
225225
If the future is already cancelled, this function is a no-op.
226-
(previously asyncio.InvalidStateError would be raised)
226+
(previously ``asyncio.InvalidStateError`` would be raised)
227227
228228
"""
229229
if exc_info[1] is None:

0 commit comments

Comments
 (0)