Add Django-1.2.1
[frozenviper.git] / Django-1.2.1 / docs / internals / documentation.txt
blob81480abf9ab62dae097c4eb4328f41e3827d2948
1 .. _internals-documentation:
3 How the Django documentation works
4 ==================================
6 \... and how to contribute.
8 Django's documentation uses the Sphinx__ documentation system, which in turn is
9 based on docutils__. The basic idea is that lightly-formatted plain-text
10 documentation is transformed into HTML, PDF, and any other output format.
12 __ http://sphinx.pocoo.org/
13 __ http://docutils.sourceforge.net/
15 To actually build the documentation locally, you'll currently need to install
16 Sphinx -- ``easy_install Sphinx`` should do the trick.
18 Then, building the html is easy; just ``make html`` from the ``docs`` directory.
20 To get started contributing, you'll want to read the `ReStructuredText
21 Primer`__. After that, you'll want to read about the `Sphinx-specific markup`__
22 that's used to manage metadata, indexing, and cross-references.
24 __ http://sphinx.pocoo.org/rest.html
25 __ http://sphinx.pocoo.org/markup/
27 The main thing to keep in mind as you write and edit docs is that the more
28 semantic markup you can add the better. So::
30     Add ``django.contrib.auth`` to your ``INSTALLED_APPS``...
32 Isn't nearly as helpful as::
34     Add :mod:`django.contrib.auth` to your :setting:`INSTALLED_APPS`...
36 This is because Sphinx will generate proper links for the latter, which greatly
37 helps readers. There's basically no limit to the amount of useful markup you can
38 add.
40 Django-specific markup
41 ----------------------
43 Besides the `Sphinx built-in markup`__, Django's docs defines some extra description units:
45 __ http://sphinx.pocoo.org/markup/desc.html
47     * Settings::
49             .. setting:: INSTALLED_APPS
51       To link to a setting, use ``:setting:`INSTALLED_APPS```.
53     * Template tags::
55             .. templatetag:: regroup
57       To link, use ``:ttag:`regroup```.
59     * Template filters::
61             .. templatefilter:: linebreaksbr
63       To link, use ``:tfilter:`linebreaksbr```.
65     * Field lookups (i.e. ``Foo.objects.filter(bar__exact=whatever)``)::
67             .. fieldlookup:: exact
69       To link, use ``:lookup:`exact```.
71     * ``django-admin`` commands::
73             .. django-admin:: syncdb
75       To link, use ``:djadmin:`syncdb```.
77     * ``django-admin`` command-line options::
79             .. django-admin-option:: --traceback
81       To link, use ``:djadminopt:`--traceback```.
83 An example
84 ----------
86 For a quick example of how it all fits together, check this out:
88     * First, the ``ref/settings.txt`` document starts out like this::
90         .. _ref-settings:
92         Available settings
93         ==================
95         ...
97     * Next, if you look at the ``topics/settings.txt`` document, you can see how
98       a link to ``ref/settings`` works::
100         Available settings
101         ==================
103         For a full list of available settings, see the :ref:`settings reference
104         <ref-settings>`.
106     * Next, notice how the settings (right now just the top few) are annotated::
108         .. setting:: ADMIN_FOR
110         ADMIN_FOR
111         ---------
113         Default: ``()`` (Empty tuple)
115         Used for admin-site settings modules, this should be a tuple of settings
116         modules (in the format ``'foo.bar.baz'``) for which this site is an
117         admin.
119         The admin site uses this in its automatically-introspected
120         documentation of models, views and template tags.
122       This marks up the following header as the "canonical" target for the
123       setting ``ADMIN_FOR`` This means any time I talk about ``ADMIN_FOR``, I
124       can reference it using ``:setting:`ADMIN_FOR```.
126 That's basically how everything fits together.
128 TODO
129 ----
131 The work is mostly done, but here's what's left, in rough order of priority.
133     * Most of the various ``index.txt`` documents have *very* short or even
134       non-existent intro text. Each of those documents needs a good short intro
135       the content below that point.
137     * The glossary is very perfunctory. It needs to be filled out.
139     * Add more metadata targets: there's lots of places that look like::
141             ``File.close()``
142             ~~~~~~~~~~~~~~~~
144       \... these should be::
146             .. method:: File.close()
148       That is, use metadata instead of titles.
150     * Add more links -- nearly everything that's an inline code literal
151       right now can probably be turned into a xref.
153       See the ``literals_to_xrefs.py`` file in ``_ext`` -- it's a shell script
154       to help do this work.
156       This will probably be a continuing, never-ending project.
158     * Add `info field lists`__ where appropriate.
160       __ http://sphinx.pocoo.org/markup/desc.html#info-field-lists
162     * Add ``.. code-block:: <lang>`` to literal blocks so that they get
163       highlighted.
165 Hints
166 -----
168 Some hints for making things look/read better:
170     * Whenever possible, use links. So, use ``:setting:`ADMIN_FOR``` instead of
171       ````ADMIN_FOR````.
173     * Some directives (``.. setting::``, for one) are prefix-style directives;
174       they go *before* the unit they're describing. These are known as
175       "crossref" directives. Others (``.. class::``, e.g.) generate their own
176       markup; these should go inside the section they're describing. These are
177       called "description units".
179       You can tell which are which by looking at in :file:`_ext/djangodocs.py`;
180       it registers roles as one of the other.
182     * When referring to classes/functions/modules, etc., you'll want to use the
183       fully-qualified name of the target
184       (``:class:`django.contrib.contenttypes.models.ContentType```).
186       Since this doesn't look all that awesome in the output -- it shows the
187       entire path to the object -- you can prefix the target with a ``~``
188       (that's a tilde) to get just the "last bit" of that path. So
189       ``:class:`~django.contrib.contenttypes.models.ContentType``` will just
190       display a link with the title "ContentType".