Skip to content

Commit 82d7c49

Browse files
committed
Merge pull request pallets#1277 from iKevinY/doc-fixes
Documentation fixes (mostly in Tutorial)
2 parents 41b5d77 + 23fc2e5 commit 82d7c49

File tree

15 files changed

+101
-99
lines changed

15 files changed

+101
-99
lines changed

docs/_templates/sidebarintro.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ <h3>Useful Links</h3>
1717
<ul>
1818
<li><a href="http://flask.pocoo.org/">The Flask Website</a></li>
1919
<li><a href="http://pypi.python.org/pypi/Flask">Flask @ PyPI</a></li>
20-
<li><a href="http://github.com/mitsuhiko/flask">Flask @ github</a></li>
20+
<li><a href="http://github.com/mitsuhiko/flask">Flask @ GitHub</a></li>
2121
<li><a href="http://github.com/mitsuhiko/flask/issues">Issue Tracker</a></li>
2222
</ul>

docs/extensions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ depending on how the extension is distributed. If you want to develop an
3232
application that supports Flask 0.7 or earlier you should still import
3333
from the :data:`flask.ext` package. We provide you with a compatibility
3434
module that provides this package for older versions of Flask. You can
35-
download it from github: `flaskext_compat.py`_
35+
download it from GitHub: `flaskext_compat.py`_
3636

3737
And here is how you can use it::
3838

docs/foreword.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ What does "micro" mean?
99
-----------------------
1010

1111
“Micro” does not mean that your whole web application has to fit into a single
12-
Python file, although it certainly can. Nor does it mean that Flask is lacking
12+
Python file (although it certainly can), nor does it mean that Flask is lacking
1313
in functionality. The "micro" in microframework means Flask aims to keep the
1414
core simple but extensible. Flask won't make many decisions for you, such as
1515
what database to use. Those decisions that it does make, such as what
@@ -28,9 +28,9 @@ Configuration and Conventions
2828
-----------------------------
2929

3030
Flask has many configuration values, with sensible defaults, and a few
31-
conventions when getting started. By convention templates and static files are
31+
conventions when getting started. By convention, templates and static files are
3232
stored in subdirectories within the application's Python source tree, with the
33-
names :file:`templates` and :file:`static` respectively. While this can be changed you
33+
names :file:`templates` and :file:`static` respectively. While this can be changed, you
3434
usually don't have to, especially when getting started.
3535

3636
Growing with Flask

docs/patterns/jquery.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,4 @@ explanation of the little bit of code above:
165165
If you don't get the whole picture, download the `sourcecode
166166
for this example
167167
<https://github.com/mitsuhiko/flask/tree/master/examples/jqueryexample>`_
168-
from github.
168+
from GitHub.

docs/tutorial/css.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Step 7: Adding Style
44
====================
55

66
Now that everything else works, it's time to add some style to the
7-
application. Just create a stylesheet called :file:`style.css` in the :file:`static`
8-
folder we created before:
7+
application. Just create a stylesheet called :file:`style.css` in the
8+
:file:`static` folder we created before:
99

1010
.. sourcecode:: css
1111

docs/tutorial/dbcon.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ Step 3: Database Connections
44
----------------------------
55

66
We have created a function for establishing a database connection with
7-
`connect_db` but by itself that's not particularly useful. Creating and
7+
`connect_db`, but by itself, that's not particularly useful. Creating and
88
closing database connections all the time is very inefficient, so we want
99
to keep it around for longer. Because database connections encapsulate a
10-
transaction we also need to make sure that only one request at the time
11-
uses the connection. So how can we elegantly do that with Flask?
10+
transaction, we also need to make sure that only one request at the time
11+
uses the connection. How can we elegantly do that with Flask?
1212

13-
This is where the application context comes into play. So let's start
13+
This is where the application context comes into play, so let's start
1414
there.
1515

1616
Flask provides us with two contexts: the application context and the
17-
request context. For the time being all you have to know is that there
18-
are special variables that use these. For instance the
17+
request context. For the time being, all you have to know is that there
18+
are special variables that use these. For instance, the
1919
:data:`~flask.request` variable is the request object associated with
2020
the current request, whereas :data:`~flask.g` is a general purpose
2121
variable associated with the current application context. We will go into
2222
the details of this a bit later.
2323

24-
For the time being all you have to know is that you can store information
24+
For the time being, all you have to know is that you can store information
2525
safely on the :data:`~flask.g` object.
2626

2727
So when do you put it on there? To do that you can make a helper
28-
function. The first time the function is called it will create a database
29-
connection for the current context and successive calls will return the
28+
function. The first time the function is called, it will create a database
29+
connection for the current context, and successive calls will return the
3030
already established connection::
3131

3232
def get_db():
@@ -39,7 +39,7 @@ already established connection::
3939

4040

4141
So now we know how to connect, but how do we properly disconnect? For
42-
that flask provides us with the :meth:`~flask.Flask.teardown_appcontext`
42+
that, Flask provides us with the :meth:`~flask.Flask.teardown_appcontext`
4343
decorator. It's executed every time the application context tears down::
4444

4545
@app.teardown_appcontext
@@ -49,11 +49,11 @@ decorator. It's executed every time the application context tears down::
4949
g.sqlite_db.close()
5050

5151
Functions marked with :meth:`~flask.Flask.teardown_appcontext` are called
52-
every time the app context tears down. So what does this mean?
53-
Essentially the app context is created before the request comes in and is
52+
every time the app context tears down. What does this mean?
53+
Essentially, the app context is created before the request comes in and is
5454
destroyed (torn down) whenever the request finishes. A teardown can
5555
happen because of two reasons: either everything went well (the error
56-
parameter will be ``None``) or an exception happened in which case the error
56+
parameter will be ``None``) or an exception happened, in which case the error
5757
is passed to the teardown function.
5858

5959
Curious about what these contexts mean? Have a look at the

docs/tutorial/dbinit.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ Step 4: Creating The Database
55

66
As outlined earlier, Flaskr is a database powered application, and more
77
precisely, it is an application powered by a relational database system. Such
8-
systems need a schema that tells them how to store that information. So
9-
before starting the server for the first time it's important to create
8+
systems need a schema that tells them how to store that information.
9+
Before starting the server for the first time, it's important to create
1010
that schema.
1111

12-
Such a schema can be created by piping the `schema.sql` file into the
12+
Such a schema can be created by piping the ``schema.sql`` file into the
1313
`sqlite3` command as follows::
1414

1515
sqlite3 /tmp/flaskr.db < schema.sql
1616

17-
The downside of this is that it requires the sqlite3 command to be
18-
installed which is not necessarily the case on every system. This also
19-
requires that we provide the path to the database which can introduce
17+
The downside of this is that it requires the ``sqlite3`` command to be
18+
installed, which is not necessarily the case on every system. This also
19+
requires that we provide the path to the database, which can introduce
2020
errors. It's a good idea to add a function that initializes the database
2121
for you to the application.
2222

23-
To do this we can create a function and hook it into the :command:`flask` command
24-
that initializes the database. Let me show you the code first. Just add
25-
this function below the `connect_db` function in :file:`flaskr.py`::
23+
To do this, we can create a function and hook it into the :command:`flask`
24+
command that initializes the database. Let me show you the code first. Just
25+
add this function below the `connect_db` function in :file:`flaskr.py`::
2626

2727
def init_db():
2828
db = get_db()
@@ -37,36 +37,36 @@ this function below the `connect_db` function in :file:`flaskr.py`::
3737
print 'Initialized the database.'
3838

3939
The ``app.cli.command()`` decorator registers a new command with the
40-
:command:`flask` script. When the command executes Flask will automatically
40+
:command:`flask` script. When the command executes, Flask will automatically
4141
create a application context for us bound to the right application.
42-
Within the function we can then access :attr:`flask.g` and other things as
42+
Within the function, we can then access :attr:`flask.g` and other things as
4343
we would expect. When the script ends, the application context tears down
4444
and the database connection is released.
4545

46-
We want to keep an actual functions around that initializes the database
47-
though so that we can easily create databases in unittests later. (For
46+
We want to keep an actual functions around that initializes the database,
47+
though, so that we can easily create databases in unit tests later on. (For
4848
more information see :ref:`testing`.)
4949

5050
The :func:`~flask.Flask.open_resource` method of the application object
5151
is a convenient helper function that will open a resource that the
5252
application provides. This function opens a file from the resource
53-
location (your `flaskr` folder) and allows you to read from it. We are
53+
location (your ``flaskr`` folder) and allows you to read from it. We are
5454
using this here to execute a script on the database connection.
5555

5656
The connection object provided by SQLite can give us a cursor object.
57-
On that cursor there is a method to execute a complete script. Finally we
58-
only have to commit the changes. SQLite 3 and other transactional
57+
On that cursor, there is a method to execute a complete script. Finally, we
58+
only have to commit the changes. SQLite3 and other transactional
5959
databases will not commit unless you explicitly tell it to.
6060

61-
Now it is possible to create a database with the :command:`flask` script::
61+
Now, it is possible to create a database with the :command:`flask` script::
6262

6363
flask --app=flaskr initdb
6464
Initialized the database.
6565

6666
.. admonition:: Troubleshooting
6767

68-
If you get an exception later that a table cannot be found check that
69-
you did execute the `initdb` command and that your table names are
70-
correct (singular vs. plural for example).
68+
If you get an exception later on stating that a table cannot be found, check
69+
that you did execute the ``initdb`` command and that your table names are
70+
correct (singular vs. plural, for example).
7171

7272
Continue with :ref:`tutorial-views`

docs/tutorial/folders.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ application::
1010
/static
1111
/templates
1212

13-
The `flaskr` folder is not a python package, but just something where we
14-
drop our files. We will then put our database schema as well as main module
15-
into this folder. It is done in the following way. The files inside
13+
The ``flaskr`` folder is not a Python package, but just something where we
14+
drop our files. Later on, we will put our database schema as well as main
15+
module into this folder. It is done in the following way. The files inside
1616
the :file:`static` folder are available to users of the application via HTTP.
17-
This is the place where css and javascript files go. Inside the
18-
:file:`templates` folder Flask will look for `Jinja2`_ templates. The
19-
templates you create later in the tutorial will go in this directory.
17+
This is the place where CSS and Javascript files go. Inside the
18+
:file:`templates` folder, Flask will look for `Jinja2`_ templates. The
19+
templates you create later on in the tutorial will go in this directory.
2020

2121
Continue with :ref:`tutorial-schema`.
2222

docs/tutorial/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Tutorial
44
========
55

66
You want to develop an application with Python and Flask? Here you have
7-
the chance to learn that by example. In this tutorial we will create a
8-
simple microblog application. It only supports one user that can create
7+
the chance to learn by example. In this tutorial, we will create a simple
8+
microblogging application. It only supports one user that can create
99
text-only entries and there are no feeds or comments, but it still
1010
features everything you need to get started. We will use Flask and SQLite
11-
as database which comes out of the box with Python, so there is nothing
11+
as a database (which comes out of the box with Python) so there is nothing
1212
else you need.
1313

1414
If you want the full source code in advance or for comparison, check out

docs/tutorial/introduction.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
Introducing Flaskr
44
==================
55

6-
We will call our blogging application flaskr here, feel free to choose a
7-
less web-2.0-ish name ;) Basically we want it to do the following things:
6+
We will call our blogging application flaskr, but feel free to choose your own
7+
less Web-2.0-ish name ;) Essentially, we want it to do the following things:
88

9-
1. let the user sign in and out with credentials specified in the
9+
1. Let the user sign in and out with credentials specified in the
1010
configuration. Only one user is supported.
11-
2. when the user is logged in they can add new entries to the page
11+
2. When the user is logged in, they can add new entries to the page
1212
consisting of a text-only title and some HTML for the text. This HTML
1313
is not sanitized because we trust the user here.
14-
3. the page shows all entries so far in reverse order (newest on top) and
15-
the user can add new ones from there if logged in.
14+
3. The index page shows all entries so far in reverse chronological order
15+
(newest on top) and the user can add new ones from there if logged in.
1616

17-
We will be using SQLite3 directly for that application because it's good
18-
enough for an application of that size. For larger applications however
19-
it makes a lot of sense to use `SQLAlchemy`_ that handles database
20-
connections in a more intelligent way, allows you to target different
17+
We will be using SQLite3 directly for this application because it's good
18+
enough for an application of this size. For larger applications, however,
19+
it makes a lot of sense to use `SQLAlchemy`_, as it handles database
20+
connections in a more intelligent way, allowing you to target different
2121
relational databases at once and more. You might also want to consider
2222
one of the popular NoSQL databases if your data is more suited for those.
2323

24-
Here a screenshot from the final application:
24+
Here a screenshot of the final application:
2525

2626
.. image:: ../_static/flaskr.png
2727
:align: center

docs/tutorial/schema.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Step 1: Database Schema
44
=======================
55

6-
First we want to create the database schema. Only a single table is needed
7-
for this application and we only want to support SQLite so creating the
6+
First, we want to create the database schema. Only a single table is needed
7+
for this application and we only want to support SQLite, so creating the
88
database schema is quite easy. Just put the following contents into a file
99
named `schema.sql` in the just created `flaskr` folder:
1010

@@ -17,8 +17,8 @@ named `schema.sql` in the just created `flaskr` folder:
1717
'text' text not null
1818
);
1919

20-
This schema consists of a single table called `entries` and each row in
21-
this table has an `id`, a `title` and a `text`. The `id` is an
20+
This schema consists of a single table called ``entries``. Each row in
21+
this table has an ``id``, a ``title``, and a ``text``. The ``id`` is an
2222
automatically incrementing integer and a primary key, the other two are
2323
strings that must not be null.
2424

0 commit comments

Comments
 (0)