2011-05-27 18:49:47 +08:00
|
|
|
=====================
|
|
|
|
Writing documentation
|
|
|
|
=====================
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
We place a high importance on consistency and readability of documentation.
|
|
|
|
After all, Django was created in a journalism environment! So we treat our
|
|
|
|
documentation like we treat our code: we aim to improve it as often as
|
|
|
|
possible.
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
Documentation changes generally come in two forms:
|
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* General improvements: typo corrections, error fixes and better
|
|
|
|
explanations through clearer writing and more examples.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* New features: documentation of features that have been added to the
|
|
|
|
framework since the last release.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
This section explains how writers can craft their documentation changes
|
|
|
|
in the most useful and least error-prone ways.
|
|
|
|
|
2012-06-08 00:32:28 +08:00
|
|
|
Getting the raw documentation
|
2016-01-03 18:56:22 +08:00
|
|
|
=============================
|
2012-06-08 00:32:28 +08:00
|
|
|
|
|
|
|
Though Django's documentation is intended to be read as HTML at
|
2012-06-28 16:49:07 +08:00
|
|
|
https://docs.djangoproject.com/, we edit it as a collection of text files for
|
2012-06-08 00:32:28 +08:00
|
|
|
maximum flexibility. These files live in the top-level ``docs/`` directory of a
|
|
|
|
Django release.
|
|
|
|
|
|
|
|
If you'd like to start contributing to our docs, get the development version of
|
|
|
|
Django from the source code repository
|
|
|
|
(see :ref:`installing-development-version`). The development version has the
|
|
|
|
latest-and-greatest documentation, just as it has latest-and-greatest code.
|
2012-10-25 18:51:19 +08:00
|
|
|
We also backport documentation fixes and improvements, at the discretion of the
|
|
|
|
committer, to the last release branch. That's because it's highly advantageous
|
|
|
|
to have the docs for the last release be up-to-date and correct (see
|
2012-06-08 00:32:28 +08:00
|
|
|
:ref:`differences-between-doc-versions`).
|
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
Getting started with Sphinx
|
2016-01-03 18:56:22 +08:00
|
|
|
===========================
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
Django's documentation uses the Sphinx__ documentation system, which in turn
|
|
|
|
is based on docutils__. The basic idea is that lightly-formatted plain-text
|
2008-08-24 06:25:40 +08:00
|
|
|
documentation is transformed into HTML, PDF, and any other output format.
|
|
|
|
|
2020-01-29 13:04:15 +08:00
|
|
|
__ https://www.sphinx-doc.org/
|
2020-01-29 16:34:37 +08:00
|
|
|
__ https://docutils.sourceforge.io/
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2018-03-08 05:19:22 +08:00
|
|
|
To build the documentation locally, install Sphinx:
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2018-03-08 05:19:22 +08:00
|
|
|
.. console::
|
|
|
|
|
2019-04-14 23:02:36 +08:00
|
|
|
$ python -m pip install Sphinx
|
2018-03-08 05:19:22 +08:00
|
|
|
|
|
|
|
Then from the ``docs`` directory, build the HTML:
|
|
|
|
|
|
|
|
.. console::
|
|
|
|
|
|
|
|
$ make html
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2011-09-05 05:17:30 +08:00
|
|
|
To get started contributing, you'll want to read the :ref:`reStructuredText
|
2018-03-30 01:37:31 +08:00
|
|
|
reference <sphinx:rst-index>`.
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2016-06-03 02:00:01 +08:00
|
|
|
Your locally-built documentation will be themed differently than the
|
|
|
|
documentation at `docs.djangoproject.com <https://docs.djangoproject.com>`_.
|
|
|
|
This is OK! If your changes look good on your local machine, they'll look good
|
|
|
|
on the website.
|
|
|
|
|
2015-12-30 00:22:51 +08:00
|
|
|
How the documentation is organized
|
2016-01-03 18:56:22 +08:00
|
|
|
==================================
|
2015-12-30 00:22:51 +08:00
|
|
|
|
|
|
|
The documentation is organized into several categories:
|
|
|
|
|
|
|
|
* :doc:`Tutorials </intro/index>` take the reader by the hand through a series
|
|
|
|
of steps to create something.
|
|
|
|
|
|
|
|
The important thing in a tutorial is to help the reader achieve something
|
|
|
|
useful, preferably as early as possible, in order to give them confidence.
|
|
|
|
|
|
|
|
Explain the nature of the problem we're solving, so that the reader
|
|
|
|
understands what we're trying to achieve. Don't feel that you need to begin
|
|
|
|
with explanations of how things work - what matters is what the reader does,
|
|
|
|
not what you explain. It can be helpful to refer back to what you've done and
|
|
|
|
explain afterwards.
|
|
|
|
|
|
|
|
* :doc:`Topic guides </topics/index>` aim to explain a concept or subject at a
|
|
|
|
fairly high level.
|
|
|
|
|
|
|
|
Link to reference material rather than repeat it. Use examples and don't be
|
|
|
|
reluctant to explain things that seem very basic to you - it might be the
|
|
|
|
explanation someone else needs.
|
|
|
|
|
|
|
|
Providing background context helps a newcomer connect the topic to things
|
|
|
|
that they already know.
|
|
|
|
|
|
|
|
* :doc:`Reference guides </ref/index>` contain technical reference for APIs.
|
|
|
|
They describe the functioning of Django's internal machinery and instruct in
|
|
|
|
its use.
|
|
|
|
|
|
|
|
Keep reference material tightly focused on the subject. Assume that the
|
|
|
|
reader already understands the basic concepts involved but needs to know or
|
|
|
|
be reminded of how Django does it.
|
|
|
|
|
|
|
|
Reference guides aren't the place for general explanation. If you find
|
|
|
|
yourself explaining basic concepts, you may want to move that material to a
|
|
|
|
topic guide.
|
|
|
|
|
|
|
|
* :doc:`How-to guides </howto/index>` are recipes that take the reader through
|
|
|
|
steps in key subjects.
|
|
|
|
|
|
|
|
What matters most in a how-to guide is what a user wants to achieve.
|
|
|
|
A how-to should always be result-oriented rather than focused on internal
|
|
|
|
details of how Django implements whatever is being discussed.
|
|
|
|
|
|
|
|
These guides are more advanced than tutorials and assume some knowledge about
|
|
|
|
how Django works. Assume that the reader has followed the tutorials and don't
|
|
|
|
hesitate to refer the reader back to the appropriate tutorial rather than
|
|
|
|
repeat the same material.
|
|
|
|
|
2013-11-30 08:39:19 +08:00
|
|
|
Writing style
|
2016-01-03 18:56:22 +08:00
|
|
|
=============
|
2013-11-30 08:39:19 +08:00
|
|
|
|
|
|
|
When using pronouns in reference to a hypothetical person, such as "a user with
|
|
|
|
a session cookie", gender neutral pronouns (they/their/them) should be used.
|
|
|
|
Instead of:
|
|
|
|
|
|
|
|
* he or she... use they.
|
|
|
|
* him or her... use them.
|
|
|
|
* his or her... use their.
|
|
|
|
* his or hers... use theirs.
|
|
|
|
* himself or herself... use themselves.
|
|
|
|
|
2019-09-05 20:06:46 +08:00
|
|
|
Try to avoid using words that minimize the difficulty involved in a task or
|
2019-09-05 15:54:01 +08:00
|
|
|
operation, such as "easily", "simply", "just", "merely", "straightforward", and
|
|
|
|
so on. People's experience may not match your expectations, and they may become
|
|
|
|
frustrated when they do not find a step as "straightforward" or "simple" as it
|
|
|
|
is implied to be.
|
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
Commonly used terms
|
2016-01-03 18:56:22 +08:00
|
|
|
===================
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
Here are some style guidelines on commonly used terms throughout the
|
|
|
|
documentation:
|
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **Django** -- when referring to the framework, capitalize Django. It is
|
|
|
|
lowercase only in Python code and in the djangoproject.com logo.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **email** -- no hyphen.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **MySQL**, **PostgreSQL**, **SQLite**
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2013-09-06 06:23:48 +08:00
|
|
|
* **SQL** -- when referring to SQL, the expected pronunciation should be
|
|
|
|
"Ess Queue Ell" and not "sequel". Thus in a phrase like "Returns an
|
|
|
|
SQL expression", "SQL" should be preceded by "an" and not "a".
|
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **Python** -- when referring to the language, capitalize Python.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **realize**, **customize**, **initialize**, etc. -- use the American
|
|
|
|
"ize" suffix, not "ise."
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **subclass** -- it's a single word without a hyphen, both as a verb
|
|
|
|
("subclass that model") and as a noun ("create a subclass").
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **Web**, **World Wide Web**, **the Web** -- note Web is always
|
|
|
|
capitalized when referring to the World Wide Web.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2015-11-15 20:05:15 +08:00
|
|
|
* **website** -- use one word, without capitalization.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
Django-specific terminology
|
2016-01-03 18:56:22 +08:00
|
|
|
===========================
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **model** -- it's not capitalized.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **template** -- it's not capitalized.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **URLconf** -- use three capitalized letters, with no space before
|
|
|
|
"conf."
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* **view** -- it's not capitalized.
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
Guidelines for reStructuredText files
|
2016-01-03 18:56:22 +08:00
|
|
|
=====================================
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
These guidelines regulate the format of our reST (reStructuredText)
|
|
|
|
documentation:
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* In section titles, capitalize only initial words and proper nouns.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Wrap the documentation at 80 characters wide, unless a code example
|
|
|
|
is significantly less readable when split over two lines, or for another
|
|
|
|
good reason.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* The main thing to keep in mind as you write and edit docs is that the
|
|
|
|
more semantic markup you can add the better. So::
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
Add ``django.contrib.auth`` to your ``INSTALLED_APPS``...
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
Isn't nearly as helpful as::
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
Add :mod:`django.contrib.auth` to your :setting:`INSTALLED_APPS`...
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
This is because Sphinx will generate proper links for the latter, which
|
2016-03-16 07:05:54 +08:00
|
|
|
greatly helps readers.
|
|
|
|
|
2019-06-17 22:54:55 +08:00
|
|
|
You can prefix the target with a ``~`` (that's a tilde) to get only the
|
|
|
|
"last bit" of that path. So ``:mod:`~django.contrib.auth``` will
|
2016-03-16 07:05:54 +08:00
|
|
|
display a link with the title "auth".
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Use :mod:`~sphinx.ext.intersphinx` to reference Python's and Sphinx'
|
|
|
|
documentation.
|
2011-09-05 05:17:30 +08:00
|
|
|
|
2016-03-16 07:05:54 +08:00
|
|
|
* Add ``.. code-block:: <lang>`` to literal blocks so that they get
|
2019-06-17 22:54:55 +08:00
|
|
|
highlighted. Prefer relying on automatic highlighting using ``::``
|
2016-03-16 07:05:54 +08:00
|
|
|
(two colons). This has the benefit that if the code contains some invalid
|
|
|
|
syntax, it won't be highlighted. Adding ``.. code-block:: python``, for
|
|
|
|
example, will force highlighting despite invalid syntax.
|
|
|
|
|
2019-03-26 06:26:23 +08:00
|
|
|
* To improve readability, use ``.. admonition:: Descriptive title`` rather than
|
|
|
|
``.. note::``. Use these boxes sparingly.
|
|
|
|
|
2016-01-03 18:56:22 +08:00
|
|
|
* Use these heading styles::
|
|
|
|
|
|
|
|
===
|
|
|
|
One
|
|
|
|
===
|
|
|
|
|
|
|
|
Two
|
|
|
|
===
|
|
|
|
|
|
|
|
Three
|
|
|
|
-----
|
|
|
|
|
|
|
|
Four
|
|
|
|
~~~~
|
|
|
|
|
|
|
|
Five
|
|
|
|
^^^^
|
|
|
|
|
2019-12-04 00:26:46 +08:00
|
|
|
* Use :rst:role:`:rfc:<rfc>` to reference RFC and try to link to the relevant
|
|
|
|
section if possible. For example, use ``:rfc:`2324#section-2.3.2``` or
|
|
|
|
``:rfc:`Custom link text <2324#section-2.3.2>```.
|
2019-11-26 20:07:55 +08:00
|
|
|
|
2020-04-30 17:30:11 +08:00
|
|
|
* Use :rst:role:`:pep:<pep>` to reference a Python Enhancement Proposal (PEP)
|
|
|
|
and try to link to the relevant section if possible. For example, use
|
|
|
|
``:pep:`20#easter-egg``` or ``:pep:`Easter Egg <20#easter-egg>```.
|
|
|
|
|
2020-04-30 17:33:04 +08:00
|
|
|
* Use :rst:role:`:mimetype:<mimetype>` to refer to a MIME Type unless the value
|
|
|
|
is quoted for a code example.
|
|
|
|
|
2020-04-30 18:12:05 +08:00
|
|
|
* Use :rst:role:`:envvar:<envvar>` to refer to an environment variable. You may
|
|
|
|
also need to define a reference to the documentation for that environment
|
|
|
|
variable using :rst:dir:`.. envvar:: <envvar>`.
|
|
|
|
|
2008-08-24 06:25:40 +08:00
|
|
|
Django-specific markup
|
2016-01-03 18:56:22 +08:00
|
|
|
======================
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2018-03-30 01:37:31 +08:00
|
|
|
Besides :ref:`Sphinx's built-in markup <sphinx:rst-index>`, Django's docs
|
|
|
|
define some extra description units:
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Settings::
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
.. setting:: INSTALLED_APPS
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
To link to a setting, use ``:setting:`INSTALLED_APPS```.
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Template tags::
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
.. templatetag:: regroup
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
To link, use ``:ttag:`regroup```.
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Template filters::
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
.. templatefilter:: linebreaksbr
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
To link, use ``:tfilter:`linebreaksbr```.
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Field lookups (i.e. ``Foo.objects.filter(bar__exact=whatever)``)::
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
.. fieldlookup:: exact
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
To link, use ``:lookup:`exact```.
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``django-admin`` commands::
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2013-07-25 23:19:36 +08:00
|
|
|
.. django-admin:: migrate
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2013-07-25 23:19:36 +08:00
|
|
|
To link, use ``:djadmin:`migrate```.
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``django-admin`` command-line options::
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
.. django-admin-option:: --traceback
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
To link, use ``:option:`command_name --traceback``` (or omit ``command_name``
|
|
|
|
for the options shared by all commands like ``--verbosity``).
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2015-06-20 20:58:10 +08:00
|
|
|
* Links to Trac tickets (typically reserved for patch release notes)::
|
2014-08-19 22:22:51 +08:00
|
|
|
|
|
|
|
:ticket:`12345`
|
|
|
|
|
2018-01-21 01:38:48 +08:00
|
|
|
Django's documentation uses a custom ``console`` directive for documenting
|
2019-11-02 12:08:23 +08:00
|
|
|
command-line examples involving ``django-admin``, ``manage.py``, ``python``,
|
2018-01-21 01:38:48 +08:00
|
|
|
etc.). In the HTML documentation, it renders a two-tab UI, with one tab showing
|
|
|
|
a Unix-style command prompt and a second tab showing a Windows prompt.
|
|
|
|
|
|
|
|
For example, you can replace this fragment::
|
|
|
|
|
|
|
|
use this command:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ python manage.py shell
|
|
|
|
|
|
|
|
with this one::
|
|
|
|
|
|
|
|
use this command:
|
|
|
|
|
|
|
|
.. console::
|
|
|
|
|
|
|
|
$ python manage.py shell
|
|
|
|
|
|
|
|
Notice two things:
|
|
|
|
|
|
|
|
* You usually will replace occurrences of the ``.. code-block:: console``
|
|
|
|
directive.
|
|
|
|
* You don't need to change the actual content of the code example. You still
|
|
|
|
write it assuming a Unix-y environment (i.e. a ``'$'`` prompt symbol,
|
|
|
|
``'/'`` as filesystem path components separator, etc.)
|
|
|
|
|
|
|
|
The example above will render a code example block with two tabs. The first
|
|
|
|
one will show:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ python manage.py shell
|
|
|
|
|
|
|
|
(No changes from what ``.. code-block:: console`` would have rendered).
|
|
|
|
|
|
|
|
The second one will show:
|
|
|
|
|
|
|
|
.. code-block:: doscon
|
|
|
|
|
|
|
|
...\> py manage.py shell
|
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
.. _documenting-new-features:
|
|
|
|
|
|
|
|
Documenting new features
|
2016-01-03 18:56:22 +08:00
|
|
|
========================
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
Our policy for new features is:
|
|
|
|
|
2011-07-19 21:16:09 +08:00
|
|
|
All documentation of new features should be written in a way that
|
2011-05-27 18:49:47 +08:00
|
|
|
clearly designates the features are only available in the Django
|
|
|
|
development version. Assume documentation readers are using the latest
|
2011-07-19 21:16:09 +08:00
|
|
|
release, not the development version.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
Our preferred way for marking new features is by prefacing the features'
|
2014-04-23 07:05:14 +08:00
|
|
|
documentation with: "``.. versionadded:: X.Y``", followed by a mandatory
|
2015-06-04 18:35:47 +08:00
|
|
|
blank line and an optional description (indented).
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
General improvements, or other changes to the APIs that should be emphasized
|
|
|
|
should use the "``.. versionchanged:: X.Y``" directive (with the same format
|
|
|
|
as the ``versionadded`` mentioned above.
|
|
|
|
|
2015-01-10 01:52:54 +08:00
|
|
|
These ``versionadded`` and ``versionchanged`` blocks should be "self-contained."
|
|
|
|
In other words, since we only keep these annotations around for two releases,
|
|
|
|
it's nice to be able to remove the annotation and its contents without having
|
|
|
|
to reflow, reindent, or edit the surrounding text. For example, instead of
|
|
|
|
putting the entire description of a new or changed feature in a block, do
|
|
|
|
something like this::
|
|
|
|
|
|
|
|
.. class:: Author(first_name, last_name, middle_name=None)
|
|
|
|
|
|
|
|
A person who writes books.
|
|
|
|
|
|
|
|
``first_name`` is ...
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
|
|
``middle_name`` is ...
|
|
|
|
|
|
|
|
.. versionchanged:: A.B
|
|
|
|
|
|
|
|
The ``middle_name`` argument was added.
|
|
|
|
|
|
|
|
Put the changed annotation notes at the bottom of a section, not the top.
|
|
|
|
|
|
|
|
Also, avoid referring to a specific version of Django outside a
|
|
|
|
``versionadded`` or ``versionchanged`` block. Even inside a block, it's often
|
|
|
|
redundant to do so as these annotations render as "New in Django A.B:" and
|
|
|
|
"Changed in Django A.B", respectively.
|
|
|
|
|
|
|
|
If a function, attribute, etc. is added, it's also okay to use a
|
|
|
|
``versionadded`` annotation like this::
|
|
|
|
|
|
|
|
.. attribute:: Author.middle_name
|
|
|
|
|
|
|
|
.. versionadded:: A.B
|
|
|
|
|
|
|
|
An author's middle name.
|
|
|
|
|
2019-06-17 22:54:55 +08:00
|
|
|
We can remove the ``.. versionadded:: A.B`` annotation without any indentation
|
|
|
|
changes when the time comes.
|
2015-01-10 01:52:54 +08:00
|
|
|
|
2015-09-24 18:39:32 +08:00
|
|
|
Minimizing images
|
2016-01-03 18:56:22 +08:00
|
|
|
=================
|
2015-09-24 18:39:32 +08:00
|
|
|
|
|
|
|
Optimize image compression where possible. For PNG files, use OptiPNG and
|
|
|
|
AdvanceCOMP's ``advpng``:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2018-01-21 01:38:48 +08:00
|
|
|
$ cd docs
|
2015-09-24 18:39:32 +08:00
|
|
|
$ optipng -o7 -zm1-9 -i0 -strip all `find . -type f -not -path "./_build/*" -name "*.png"`
|
|
|
|
$ advpng -z4 `find . -type f -not -path "./_build/*" -name "*.png"`
|
|
|
|
|
|
|
|
This is based on OptiPNG version 0.7.5. Older versions may complain about the
|
|
|
|
``--strip all`` option being lossy.
|
|
|
|
|
2008-08-24 06:25:40 +08:00
|
|
|
An example
|
2016-01-03 18:56:22 +08:00
|
|
|
==========
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2010-08-20 03:27:44 +08:00
|
|
|
For a quick example of how it all fits together, consider this hypothetical
|
|
|
|
example:
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* First, the ``ref/settings.txt`` document could have an overall layout
|
|
|
|
like this:
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
.. code-block:: rst
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
========
|
|
|
|
Settings
|
|
|
|
========
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
...
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
.. _available-settings:
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
Available settings
|
|
|
|
==================
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
...
|
2010-08-20 03:27:44 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
.. _deprecated-settings:
|
2010-08-20 03:27:44 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
Deprecated settings
|
|
|
|
===================
|
2010-08-20 03:27:44 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
...
|
2010-08-20 03:27:44 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Next, the ``topics/settings.txt`` document could contain something like
|
|
|
|
this:
|
2010-08-20 03:27:44 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
.. code-block:: rst
|
2010-08-20 03:27:44 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
You can access a :ref:`listing of all available settings
|
|
|
|
<available-settings>`. For a list of deprecated settings see
|
|
|
|
:ref:`deprecated-settings`.
|
2010-08-20 03:27:44 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
You can find both in the :doc:`settings reference document
|
|
|
|
</ref/settings>`.
|
2010-08-20 03:27:44 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
We use the Sphinx :rst:role:`doc` cross reference element when we want to
|
|
|
|
link to another document as a whole and the :rst:role:`ref` element when
|
|
|
|
we want to link to an arbitrary location in a document.
|
2010-08-20 03:27:44 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Next, notice how the settings are annotated:
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
.. code-block:: rst
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2013-12-14 23:42:50 +08:00
|
|
|
.. setting:: ADMINS
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2013-12-14 23:42:50 +08:00
|
|
|
ADMINS
|
2016-01-03 18:56:22 +08:00
|
|
|
======
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2015-01-22 00:55:57 +08:00
|
|
|
Default: ``[]`` (Empty list)
|
2008-08-24 06:25:40 +08:00
|
|
|
|
2015-01-22 00:55:57 +08:00
|
|
|
A list of all the people who get code error notifications. When
|
2013-12-14 23:42:50 +08:00
|
|
|
``DEBUG=False`` and a view raises an exception, Django will email these people
|
2015-01-22 00:55:57 +08:00
|
|
|
with the full exception information. Each member of the list should be a tuple
|
2013-12-14 23:42:50 +08:00
|
|
|
of (Full name, email address). Example::
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2015-01-22 00:55:57 +08:00
|
|
|
[('John', 'john@example.com'), ('Mary', 'mary@example.com')]
|
2013-12-14 23:42:50 +08:00
|
|
|
|
|
|
|
Note that Django will email *all* of these people whenever an error happens.
|
|
|
|
See :doc:`/howto/error-reporting` for more information.
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
This marks up the following header as the "canonical" target for the
|
2013-12-14 23:42:50 +08:00
|
|
|
setting ``ADMINS``. This means any time I talk about ``ADMINS``,
|
|
|
|
I can reference it using ``:setting:`ADMINS```.
|
2008-09-10 12:04:57 +08:00
|
|
|
|
2008-08-24 06:25:40 +08:00
|
|
|
That's basically how everything fits together.
|
|
|
|
|
2014-06-03 04:07:28 +08:00
|
|
|
.. _documentation-spelling-check:
|
|
|
|
|
2014-02-23 01:46:31 +08:00
|
|
|
Spelling check
|
2016-01-03 18:56:22 +08:00
|
|
|
==============
|
2014-02-23 01:46:31 +08:00
|
|
|
|
|
|
|
Before you commit your docs, it's a good idea to run the spelling checker.
|
2020-06-01 13:07:56 +08:00
|
|
|
You'll need to install `sphinxcontrib-spelling
|
|
|
|
<https://pypi.org/project/sphinxcontrib-spelling/>`_ first. Then from the
|
|
|
|
``docs`` directory, run ``make spelling``. Wrong words (if any) along with the
|
|
|
|
file and line number where they occur will be saved to
|
2014-02-23 01:46:31 +08:00
|
|
|
``_build/spelling/output.txt``.
|
|
|
|
|
|
|
|
If you encounter false-positives (error output that actually is correct), do
|
|
|
|
one of the following:
|
|
|
|
|
|
|
|
* Surround inline code or brand/technology names with grave accents (`).
|
|
|
|
* Find synonyms that the spell checker recognizes.
|
|
|
|
* If, and only if, you are sure the word you are using is correct - add it
|
|
|
|
to ``docs/spelling_wordlist`` (please keep the list in alphabetical order).
|
2014-07-03 01:16:31 +08:00
|
|
|
|
|
|
|
Translating documentation
|
2016-01-03 18:56:22 +08:00
|
|
|
=========================
|
2014-07-03 01:16:31 +08:00
|
|
|
|
|
|
|
See :ref:`Localizing the Django documentation <translating-documentation>` if
|
|
|
|
you'd like to help translate the documentation into another language.
|
2015-03-07 18:40:30 +08:00
|
|
|
|
|
|
|
.. _django-admin-manpage:
|
|
|
|
|
|
|
|
``django-admin`` man page
|
2016-01-03 18:56:22 +08:00
|
|
|
=========================
|
2015-03-07 18:40:30 +08:00
|
|
|
|
|
|
|
Sphinx can generate a manual page for the
|
|
|
|
:doc:`django-admin </ref/django-admin>` command. This is configured in
|
|
|
|
``docs/conf.py``. Unlike other documentation output, this man page should be
|
|
|
|
included in the Django repository and the releases as
|
|
|
|
``docs/man/django-admin.1``. There isn't a need to update this file when
|
|
|
|
updating the documentation, as it's updated once as part of the release process.
|
|
|
|
|
|
|
|
To generate an updated version of the man page, run ``make man`` in the
|
|
|
|
``docs`` directory. The new man page will be written in
|
|
|
|
``docs/_build/man/django-admin.1``.
|