diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-11-17 05:32:33 -0500 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2016-11-19 12:22:04 -0500 |
commit | 1dc4bbf0b268246f6202c761016735933b6f0b99 (patch) | |
tree | 0bb12a6c59472d8167dbebac4fe6a68023956813 /Documentation | |
parent | 726d661fea3e3f76d36515c74e4ce58e7789418e (diff) |
docs-rst: doc-guide: split the kernel-documentation.rst contents
Having the kernel-documentation at the topmost level doesn't
allow generating a separate PDF file for it. Also, makes harder
to add extra contents. So, place it on a sub-dir.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/00-INDEX | 2 | ||||
-rw-r--r-- | Documentation/conf.py | 2 | ||||
-rw-r--r-- | Documentation/doc-guide/conf.py | 10 | ||||
-rw-r--r-- | Documentation/doc-guide/docbook.rst | 90 | ||||
-rw-r--r-- | Documentation/doc-guide/index.rst | 19 | ||||
-rw-r--r-- | Documentation/doc-guide/kernel-doc.rst (renamed from Documentation/kernel-documentation.rst) | 316 | ||||
-rw-r--r-- | Documentation/doc-guide/sphinx.rst | 219 | ||||
-rw-r--r-- | Documentation/index.rst | 2 | ||||
-rw-r--r-- | Documentation/kernel-doc-nano-HOWTO.txt | 2 | ||||
-rw-r--r-- | Documentation/process/4.Coding.rst | 4 | ||||
-rw-r--r-- | Documentation/process/coding-style.rst | 4 | ||||
-rw-r--r-- | Documentation/translations/zh_CN/CodingStyle | 2 |
12 files changed, 348 insertions, 324 deletions
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX index e2e74448d425..c08de5574d48 100644 --- a/Documentation/00-INDEX +++ b/Documentation/00-INDEX | |||
@@ -258,7 +258,7 @@ kdump/ | |||
258 | - directory with mini HowTo on getting the crash dump code to work. | 258 | - directory with mini HowTo on getting the crash dump code to work. |
259 | process/kernel-docs.rst | 259 | process/kernel-docs.rst |
260 | - listing of various WWW + books that document kernel internals. | 260 | - listing of various WWW + books that document kernel internals. |
261 | kernel-documentation.rst | 261 | doc-guide/ |
262 | - how to write and format reStructuredText kernel documentation | 262 | - how to write and format reStructuredText kernel documentation |
263 | admin-guide/kernel-parameters.rst | 263 | admin-guide/kernel-parameters.rst |
264 | - summary listing of command line / boot prompt args for the kernel. | 264 | - summary listing of command line / boot prompt args for the kernel. |
diff --git a/Documentation/conf.py b/Documentation/conf.py index ba38bcf485a9..1ac958c0333d 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py | |||
@@ -340,6 +340,8 @@ if major == 1 and minor > 3: | |||
340 | # (source start file, target name, title, | 340 | # (source start file, target name, title, |
341 | # author, documentclass [howto, manual, or own class]). | 341 | # author, documentclass [howto, manual, or own class]). |
342 | latex_documents = [ | 342 | latex_documents = [ |
343 | ('doc-guide/index', 'kernel-doc-guide.tex', 'Linux Kernel Documentation Guide', | ||
344 | 'The kernel development community', 'manual'), | ||
343 | ('admin-guide/index', 'linux-user.tex', 'Linux Kernel User Documentation', | 345 | ('admin-guide/index', 'linux-user.tex', 'Linux Kernel User Documentation', |
344 | 'The kernel development community', 'manual'), | 346 | 'The kernel development community', 'manual'), |
345 | ('core-api/index', 'core-api.tex', 'The kernel core API manual', | 347 | ('core-api/index', 'core-api.tex', 'The kernel core API manual', |
diff --git a/Documentation/doc-guide/conf.py b/Documentation/doc-guide/conf.py new file mode 100644 index 000000000000..fd3731182d5a --- /dev/null +++ b/Documentation/doc-guide/conf.py | |||
@@ -0,0 +1,10 @@ | |||
1 | # -*- coding: utf-8; mode: python -*- | ||
2 | |||
3 | project = 'Linux Kernel Documentation Guide' | ||
4 | |||
5 | tags.add("subproject") | ||
6 | |||
7 | latex_documents = [ | ||
8 | ('index', 'kernel-doc-guide.tex', 'Linux Kernel Documentation Guide', | ||
9 | 'The kernel development community', 'manual'), | ||
10 | ] | ||
diff --git a/Documentation/doc-guide/docbook.rst b/Documentation/doc-guide/docbook.rst new file mode 100644 index 000000000000..d8bf04308b43 --- /dev/null +++ b/Documentation/doc-guide/docbook.rst | |||
@@ -0,0 +1,90 @@ | |||
1 | DocBook XML [DEPRECATED] | ||
2 | ======================== | ||
3 | |||
4 | .. attention:: | ||
5 | |||
6 | This section describes the deprecated DocBook XML toolchain. Please do not | ||
7 | create new DocBook XML template files. Please consider converting existing | ||
8 | DocBook XML templates files to Sphinx/reStructuredText. | ||
9 | |||
10 | Converting DocBook to Sphinx | ||
11 | ---------------------------- | ||
12 | |||
13 | Over time, we expect all of the documents under ``Documentation/DocBook`` to be | ||
14 | converted to Sphinx and reStructuredText. For most DocBook XML documents, a good | ||
15 | enough solution is to use the simple ``Documentation/sphinx/tmplcvt`` script, | ||
16 | which uses ``pandoc`` under the hood. For example:: | ||
17 | |||
18 | $ cd Documentation/sphinx | ||
19 | $ ./tmplcvt ../DocBook/in.tmpl ../out.rst | ||
20 | |||
21 | Then edit the resulting rst files to fix any remaining issues, and add the | ||
22 | document in the ``toctree`` in ``Documentation/index.rst``. | ||
23 | |||
24 | Components of the kernel-doc system | ||
25 | ----------------------------------- | ||
26 | |||
27 | Many places in the source tree have extractable documentation in the form of | ||
28 | block comments above functions. The components of this system are: | ||
29 | |||
30 | - ``scripts/kernel-doc`` | ||
31 | |||
32 | This is a perl script that hunts for the block comments and can mark them up | ||
33 | directly into reStructuredText, DocBook, man, text, and HTML. (No, not | ||
34 | texinfo.) | ||
35 | |||
36 | - ``Documentation/DocBook/*.tmpl`` | ||
37 | |||
38 | These are XML template files, which are normal XML files with special | ||
39 | place-holders for where the extracted documentation should go. | ||
40 | |||
41 | - ``scripts/docproc.c`` | ||
42 | |||
43 | This is a program for converting XML template files into XML files. When a | ||
44 | file is referenced it is searched for symbols exported (EXPORT_SYMBOL), to be | ||
45 | able to distinguish between internal and external functions. | ||
46 | |||
47 | It invokes kernel-doc, giving it the list of functions that are to be | ||
48 | documented. | ||
49 | |||
50 | Additionally it is used to scan the XML template files to locate all the files | ||
51 | referenced herein. This is used to generate dependency information as used by | ||
52 | make. | ||
53 | |||
54 | - ``Makefile`` | ||
55 | |||
56 | The targets 'xmldocs', 'psdocs', 'pdfdocs', and 'htmldocs' are used to build | ||
57 | DocBook XML files, PostScript files, PDF files, and html files in | ||
58 | Documentation/DocBook. The older target 'sgmldocs' is equivalent to 'xmldocs'. | ||
59 | |||
60 | - ``Documentation/DocBook/Makefile`` | ||
61 | |||
62 | This is where C files are associated with SGML templates. | ||
63 | |||
64 | How to use kernel-doc comments in DocBook XML template files | ||
65 | ------------------------------------------------------------ | ||
66 | |||
67 | DocBook XML template files (\*.tmpl) are like normal XML files, except that they | ||
68 | can contain escape sequences where extracted documentation should be inserted. | ||
69 | |||
70 | ``!E<filename>`` is replaced by the documentation, in ``<filename>``, for | ||
71 | functions that are exported using ``EXPORT_SYMBOL``: the function list is | ||
72 | collected from files listed in ``Documentation/DocBook/Makefile``. | ||
73 | |||
74 | ``!I<filename>`` is replaced by the documentation for functions that are **not** | ||
75 | exported using ``EXPORT_SYMBOL``. | ||
76 | |||
77 | ``!D<filename>`` is used to name additional files to search for functions | ||
78 | exported using ``EXPORT_SYMBOL``. | ||
79 | |||
80 | ``!F<filename> <function [functions...]>`` is replaced by the documentation, in | ||
81 | ``<filename>``, for the functions listed. | ||
82 | |||
83 | ``!P<filename> <section title>`` is replaced by the contents of the ``DOC:`` | ||
84 | section titled ``<section title>`` from ``<filename>``. Spaces are allowed in | ||
85 | ``<section title>``; do not quote the ``<section title>``. | ||
86 | |||
87 | ``!C<filename>`` is replaced by nothing, but makes the tools check that all DOC: | ||
88 | sections and documented functions, symbols, etc. are used. This makes sense to | ||
89 | use when you use ``!F`` or ``!P`` only and want to verify that all documentation | ||
90 | is included. | ||
diff --git a/Documentation/doc-guide/index.rst b/Documentation/doc-guide/index.rst new file mode 100644 index 000000000000..695b7b6cf6ed --- /dev/null +++ b/Documentation/doc-guide/index.rst | |||
@@ -0,0 +1,19 @@ | |||
1 | .. _doc_guide: | ||
2 | |||
3 | ================================= | ||
4 | How to write kernel documentation | ||
5 | ================================= | ||
6 | |||
7 | .. toctree:: | ||
8 | :maxdepth: 1 | ||
9 | |||
10 | sphinx.rst | ||
11 | kernel-doc.rst | ||
12 | docbook.rst | ||
13 | |||
14 | .. only:: subproject and html | ||
15 | |||
16 | Indices | ||
17 | ======= | ||
18 | |||
19 | * :ref:`genindex` | ||
diff --git a/Documentation/kernel-documentation.rst b/Documentation/doc-guide/kernel-doc.rst index c66ab937c2ca..afc95c9e9626 100644 --- a/Documentation/kernel-documentation.rst +++ b/Documentation/doc-guide/kernel-doc.rst | |||
@@ -1,228 +1,3 @@ | |||
1 | ================================= | ||
2 | How to write kernel documentation | ||
3 | ================================= | ||
4 | |||
5 | Introduction | ||
6 | ============ | ||
7 | |||
8 | The Linux kernel uses `Sphinx`_ to generate pretty documentation from | ||
9 | `reStructuredText`_ files under ``Documentation``. To build the documentation in | ||
10 | HTML or PDF formats, use ``make htmldocs`` or ``make pdfdocs``. The generated | ||
11 | documentation is placed in ``Documentation/output``. | ||
12 | |||
13 | .. _Sphinx: http://www.sphinx-doc.org/ | ||
14 | .. _reStructuredText: http://docutils.sourceforge.net/rst.html | ||
15 | |||
16 | The reStructuredText files may contain directives to include structured | ||
17 | documentation comments, or kernel-doc comments, from source files. Usually these | ||
18 | are used to describe the functions and types and design of the code. The | ||
19 | kernel-doc comments have some special structure and formatting, but beyond that | ||
20 | they are also treated as reStructuredText. | ||
21 | |||
22 | There is also the deprecated DocBook toolchain to generate documentation from | ||
23 | DocBook XML template files under ``Documentation/DocBook``. The DocBook files | ||
24 | are to be converted to reStructuredText, and the toolchain is slated to be | ||
25 | removed. | ||
26 | |||
27 | Finally, there are thousands of plain text documentation files scattered around | ||
28 | ``Documentation``. Some of these will likely be converted to reStructuredText | ||
29 | over time, but the bulk of them will remain in plain text. | ||
30 | |||
31 | Sphinx Build | ||
32 | ============ | ||
33 | |||
34 | The usual way to generate the documentation is to run ``make htmldocs`` or | ||
35 | ``make pdfdocs``. There are also other formats available, see the documentation | ||
36 | section of ``make help``. The generated documentation is placed in | ||
37 | format-specific subdirectories under ``Documentation/output``. | ||
38 | |||
39 | To generate documentation, Sphinx (``sphinx-build``) must obviously be | ||
40 | installed. For prettier HTML output, the Read the Docs Sphinx theme | ||
41 | (``sphinx_rtd_theme``) is used if available. For PDF output, ``rst2pdf`` is also | ||
42 | needed. All of these are widely available and packaged in distributions. | ||
43 | |||
44 | To pass extra options to Sphinx, you can use the ``SPHINXOPTS`` make | ||
45 | variable. For example, use ``make SPHINXOPTS=-v htmldocs`` to get more verbose | ||
46 | output. | ||
47 | |||
48 | To remove the generated documentation, run ``make cleandocs``. | ||
49 | |||
50 | Writing Documentation | ||
51 | ===================== | ||
52 | |||
53 | Adding new documentation can be as simple as: | ||
54 | |||
55 | 1. Add a new ``.rst`` file somewhere under ``Documentation``. | ||
56 | 2. Refer to it from the Sphinx main `TOC tree`_ in ``Documentation/index.rst``. | ||
57 | |||
58 | .. _TOC tree: http://www.sphinx-doc.org/en/stable/markup/toctree.html | ||
59 | |||
60 | This is usually good enough for simple documentation (like the one you're | ||
61 | reading right now), but for larger documents it may be advisable to create a | ||
62 | subdirectory (or use an existing one). For example, the graphics subsystem | ||
63 | documentation is under ``Documentation/gpu``, split to several ``.rst`` files, | ||
64 | and has a separate ``index.rst`` (with a ``toctree`` of its own) referenced from | ||
65 | the main index. | ||
66 | |||
67 | See the documentation for `Sphinx`_ and `reStructuredText`_ on what you can do | ||
68 | with them. In particular, the Sphinx `reStructuredText Primer`_ is a good place | ||
69 | to get started with reStructuredText. There are also some `Sphinx specific | ||
70 | markup constructs`_. | ||
71 | |||
72 | .. _reStructuredText Primer: http://www.sphinx-doc.org/en/stable/rest.html | ||
73 | .. _Sphinx specific markup constructs: http://www.sphinx-doc.org/en/stable/markup/index.html | ||
74 | |||
75 | Specific guidelines for the kernel documentation | ||
76 | ------------------------------------------------ | ||
77 | |||
78 | Here are some specific guidelines for the kernel documentation: | ||
79 | |||
80 | * Please don't go overboard with reStructuredText markup. Keep it simple. | ||
81 | |||
82 | * Please stick to this order of heading adornments: | ||
83 | |||
84 | 1. ``=`` with overline for document title:: | ||
85 | |||
86 | ============== | ||
87 | Document title | ||
88 | ============== | ||
89 | |||
90 | 2. ``=`` for chapters:: | ||
91 | |||
92 | Chapters | ||
93 | ======== | ||
94 | |||
95 | 3. ``-`` for sections:: | ||
96 | |||
97 | Section | ||
98 | ------- | ||
99 | |||
100 | 4. ``~`` for subsections:: | ||
101 | |||
102 | Subsection | ||
103 | ~~~~~~~~~~ | ||
104 | |||
105 | Although RST doesn't mandate a specific order ("Rather than imposing a fixed | ||
106 | number and order of section title adornment styles, the order enforced will be | ||
107 | the order as encountered."), having the higher levels the same overall makes | ||
108 | it easier to follow the documents. | ||
109 | |||
110 | |||
111 | the C domain | ||
112 | ------------ | ||
113 | |||
114 | The `Sphinx C Domain`_ (name c) is suited for documentation of C API. E.g. a | ||
115 | function prototype: | ||
116 | |||
117 | .. code-block:: rst | ||
118 | |||
119 | .. c:function:: int ioctl( int fd, int request ) | ||
120 | |||
121 | The C domain of the kernel-doc has some additional features. E.g. you can | ||
122 | *rename* the reference name of a function with a common name like ``open`` or | ||
123 | ``ioctl``: | ||
124 | |||
125 | .. code-block:: rst | ||
126 | |||
127 | .. c:function:: int ioctl( int fd, int request ) | ||
128 | :name: VIDIOC_LOG_STATUS | ||
129 | |||
130 | The func-name (e.g. ioctl) remains in the output but the ref-name changed from | ||
131 | ``ioctl`` to ``VIDIOC_LOG_STATUS``. The index entry for this function is also | ||
132 | changed to ``VIDIOC_LOG_STATUS`` and the function can now referenced by: | ||
133 | |||
134 | .. code-block:: rst | ||
135 | |||
136 | :c:func:`VIDIOC_LOG_STATUS` | ||
137 | |||
138 | |||
139 | list tables | ||
140 | ----------- | ||
141 | |||
142 | We recommend the use of *list table* formats. The *list table* formats are | ||
143 | double-stage lists. Compared to the ASCII-art they might not be as | ||
144 | comfortable for | ||
145 | readers of the text files. Their advantage is that they are easy to | ||
146 | create or modify and that the diff of a modification is much more meaningful, | ||
147 | because it is limited to the modified content. | ||
148 | |||
149 | The ``flat-table`` is a double-stage list similar to the ``list-table`` with | ||
150 | some additional features: | ||
151 | |||
152 | * column-span: with the role ``cspan`` a cell can be extended through | ||
153 | additional columns | ||
154 | |||
155 | * row-span: with the role ``rspan`` a cell can be extended through | ||
156 | additional rows | ||
157 | |||
158 | * auto span rightmost cell of a table row over the missing cells on the right | ||
159 | side of that table-row. With Option ``:fill-cells:`` this behavior can | ||
160 | changed from *auto span* to *auto fill*, which automatically inserts (empty) | ||
161 | cells instead of spanning the last cell. | ||
162 | |||
163 | options: | ||
164 | |||
165 | * ``:header-rows:`` [int] count of header rows | ||
166 | * ``:stub-columns:`` [int] count of stub columns | ||
167 | * ``:widths:`` [[int] [int] ... ] widths of columns | ||
168 | * ``:fill-cells:`` instead of auto-spanning missing cells, insert missing cells | ||
169 | |||
170 | roles: | ||
171 | |||
172 | * ``:cspan:`` [int] additional columns (*morecols*) | ||
173 | * ``:rspan:`` [int] additional rows (*morerows*) | ||
174 | |||
175 | The example below shows how to use this markup. The first level of the staged | ||
176 | list is the *table-row*. In the *table-row* there is only one markup allowed, | ||
177 | the list of the cells in this *table-row*. Exceptions are *comments* ( ``..`` ) | ||
178 | and *targets* (e.g. a ref to ``:ref:`last row <last row>``` / :ref:`last row | ||
179 | <last row>`). | ||
180 | |||
181 | .. code-block:: rst | ||
182 | |||
183 | .. flat-table:: table title | ||
184 | :widths: 2 1 1 3 | ||
185 | |||
186 | * - head col 1 | ||
187 | - head col 2 | ||
188 | - head col 3 | ||
189 | - head col 4 | ||
190 | |||
191 | * - column 1 | ||
192 | - field 1.1 | ||
193 | - field 1.2 with autospan | ||
194 | |||
195 | * - column 2 | ||
196 | - field 2.1 | ||
197 | - :rspan:`1` :cspan:`1` field 2.2 - 3.3 | ||
198 | |||
199 | * .. _`last row`: | ||
200 | |||
201 | - column 3 | ||
202 | |||
203 | Rendered as: | ||
204 | |||
205 | .. flat-table:: table title | ||
206 | :widths: 2 1 1 3 | ||
207 | |||
208 | * - head col 1 | ||
209 | - head col 2 | ||
210 | - head col 3 | ||
211 | - head col 4 | ||
212 | |||
213 | * - column 1 | ||
214 | - field 1.1 | ||
215 | - field 1.2 with autospan | ||
216 | |||
217 | * - column 2 | ||
218 | - field 2.1 | ||
219 | - :rspan:`1` :cspan:`1` field 2.2 - 3.3 | ||
220 | |||
221 | * .. _`last row`: | ||
222 | |||
223 | - column 3 | ||
224 | |||
225 | |||
226 | Including kernel-doc comments | 1 | Including kernel-doc comments |
227 | ============================= | 2 | ============================= |
228 | 3 | ||
@@ -586,94 +361,3 @@ file. | |||
586 | 361 | ||
587 | Data structures visible in kernel include files should also be documented using | 362 | Data structures visible in kernel include files should also be documented using |
588 | kernel-doc formatted comments. | 363 | kernel-doc formatted comments. |
589 | |||
590 | DocBook XML [DEPRECATED] | ||
591 | ======================== | ||
592 | |||
593 | .. attention:: | ||
594 | |||
595 | This section describes the deprecated DocBook XML toolchain. Please do not | ||
596 | create new DocBook XML template files. Please consider converting existing | ||
597 | DocBook XML templates files to Sphinx/reStructuredText. | ||
598 | |||
599 | Converting DocBook to Sphinx | ||
600 | ---------------------------- | ||
601 | |||
602 | Over time, we expect all of the documents under ``Documentation/DocBook`` to be | ||
603 | converted to Sphinx and reStructuredText. For most DocBook XML documents, a good | ||
604 | enough solution is to use the simple ``Documentation/sphinx/tmplcvt`` script, | ||
605 | which uses ``pandoc`` under the hood. For example:: | ||
606 | |||
607 | $ cd Documentation/sphinx | ||
608 | $ ./tmplcvt ../DocBook/in.tmpl ../out.rst | ||
609 | |||
610 | Then edit the resulting rst files to fix any remaining issues, and add the | ||
611 | document in the ``toctree`` in ``Documentation/index.rst``. | ||
612 | |||
613 | Components of the kernel-doc system | ||
614 | ----------------------------------- | ||
615 | |||
616 | Many places in the source tree have extractable documentation in the form of | ||
617 | block comments above functions. The components of this system are: | ||
618 | |||
619 | - ``scripts/kernel-doc`` | ||
620 | |||
621 | This is a perl script that hunts for the block comments and can mark them up | ||
622 | directly into reStructuredText, DocBook, man, text, and HTML. (No, not | ||
623 | texinfo.) | ||
624 | |||
625 | - ``Documentation/DocBook/*.tmpl`` | ||
626 | |||
627 | These are XML template files, which are normal XML files with special | ||
628 | place-holders for where the extracted documentation should go. | ||
629 | |||
630 | - ``scripts/docproc.c`` | ||
631 | |||
632 | This is a program for converting XML template files into XML files. When a | ||
633 | file is referenced it is searched for symbols exported (EXPORT_SYMBOL), to be | ||
634 | able to distinguish between internal and external functions. | ||
635 | |||
636 | It invokes kernel-doc, giving it the list of functions that are to be | ||
637 | documented. | ||
638 | |||
639 | Additionally it is used to scan the XML template files to locate all the files | ||
640 | referenced herein. This is used to generate dependency information as used by | ||
641 | make. | ||
642 | |||
643 | - ``Makefile`` | ||
644 | |||
645 | The targets 'xmldocs', 'psdocs', 'pdfdocs', and 'htmldocs' are used to build | ||
646 | DocBook XML files, PostScript files, PDF files, and html files in | ||
647 | Documentation/DocBook. The older target 'sgmldocs' is equivalent to 'xmldocs'. | ||
648 | |||
649 | - ``Documentation/DocBook/Makefile`` | ||
650 | |||
651 | This is where C files are associated with SGML templates. | ||
652 | |||
653 | How to use kernel-doc comments in DocBook XML template files | ||
654 | ------------------------------------------------------------ | ||
655 | |||
656 | DocBook XML template files (\*.tmpl) are like normal XML files, except that they | ||
657 | can contain escape sequences where extracted documentation should be inserted. | ||
658 | |||
659 | ``!E<filename>`` is replaced by the documentation, in ``<filename>``, for | ||
660 | functions that are exported using ``EXPORT_SYMBOL``: the function list is | ||
661 | collected from files listed in ``Documentation/DocBook/Makefile``. | ||
662 | |||
663 | ``!I<filename>`` is replaced by the documentation for functions that are **not** | ||
664 | exported using ``EXPORT_SYMBOL``. | ||
665 | |||
666 | ``!D<filename>`` is used to name additional files to search for functions | ||
667 | exported using ``EXPORT_SYMBOL``. | ||
668 | |||
669 | ``!F<filename> <function [functions...]>`` is replaced by the documentation, in | ||
670 | ``<filename>``, for the functions listed. | ||
671 | |||
672 | ``!P<filename> <section title>`` is replaced by the contents of the ``DOC:`` | ||
673 | section titled ``<section title>`` from ``<filename>``. Spaces are allowed in | ||
674 | ``<section title>``; do not quote the ``<section title>``. | ||
675 | |||
676 | ``!C<filename>`` is replaced by nothing, but makes the tools check that all DOC: | ||
677 | sections and documented functions, symbols, etc. are used. This makes sense to | ||
678 | use when you use ``!F`` or ``!P`` only and want to verify that all documentation | ||
679 | is included. | ||
diff --git a/Documentation/doc-guide/sphinx.rst b/Documentation/doc-guide/sphinx.rst new file mode 100644 index 000000000000..96fe7ccb2c67 --- /dev/null +++ b/Documentation/doc-guide/sphinx.rst | |||
@@ -0,0 +1,219 @@ | |||
1 | Introduction | ||
2 | ============ | ||
3 | |||
4 | The Linux kernel uses `Sphinx`_ to generate pretty documentation from | ||
5 | `reStructuredText`_ files under ``Documentation``. To build the documentation in | ||
6 | HTML or PDF formats, use ``make htmldocs`` or ``make pdfdocs``. The generated | ||
7 | documentation is placed in ``Documentation/output``. | ||
8 | |||
9 | .. _Sphinx: http://www.sphinx-doc.org/ | ||
10 | .. _reStructuredText: http://docutils.sourceforge.net/rst.html | ||
11 | |||
12 | The reStructuredText files may contain directives to include structured | ||
13 | documentation comments, or kernel-doc comments, from source files. Usually these | ||
14 | are used to describe the functions and types and design of the code. The | ||
15 | kernel-doc comments have some special structure and formatting, but beyond that | ||
16 | they are also treated as reStructuredText. | ||
17 | |||
18 | There is also the deprecated DocBook toolchain to generate documentation from | ||
19 | DocBook XML template files under ``Documentation/DocBook``. The DocBook files | ||
20 | are to be converted to reStructuredText, and the toolchain is slated to be | ||
21 | removed. | ||
22 | |||
23 | Finally, there are thousands of plain text documentation files scattered around | ||
24 | ``Documentation``. Some of these will likely be converted to reStructuredText | ||
25 | over time, but the bulk of them will remain in plain text. | ||
26 | |||
27 | Sphinx Build | ||
28 | ============ | ||
29 | |||
30 | The usual way to generate the documentation is to run ``make htmldocs`` or | ||
31 | ``make pdfdocs``. There are also other formats available, see the documentation | ||
32 | section of ``make help``. The generated documentation is placed in | ||
33 | format-specific subdirectories under ``Documentation/output``. | ||
34 | |||
35 | To generate documentation, Sphinx (``sphinx-build``) must obviously be | ||
36 | installed. For prettier HTML output, the Read the Docs Sphinx theme | ||
37 | (``sphinx_rtd_theme``) is used if available. For PDF output, ``rst2pdf`` is also | ||
38 | needed. All of these are widely available and packaged in distributions. | ||
39 | |||
40 | To pass extra options to Sphinx, you can use the ``SPHINXOPTS`` make | ||
41 | variable. For example, use ``make SPHINXOPTS=-v htmldocs`` to get more verbose | ||
42 | output. | ||
43 | |||
44 | To remove the generated documentation, run ``make cleandocs``. | ||
45 | |||
46 | Writing Documentation | ||
47 | ===================== | ||
48 | |||
49 | Adding new documentation can be as simple as: | ||
50 | |||
51 | 1. Add a new ``.rst`` file somewhere under ``Documentation``. | ||
52 | 2. Refer to it from the Sphinx main `TOC tree`_ in ``Documentation/index.rst``. | ||
53 | |||
54 | .. _TOC tree: http://www.sphinx-doc.org/en/stable/markup/toctree.html | ||
55 | |||
56 | This is usually good enough for simple documentation (like the one you're | ||
57 | reading right now), but for larger documents it may be advisable to create a | ||
58 | subdirectory (or use an existing one). For example, the graphics subsystem | ||
59 | documentation is under ``Documentation/gpu``, split to several ``.rst`` files, | ||
60 | and has a separate ``index.rst`` (with a ``toctree`` of its own) referenced from | ||
61 | the main index. | ||
62 | |||
63 | See the documentation for `Sphinx`_ and `reStructuredText`_ on what you can do | ||
64 | with them. In particular, the Sphinx `reStructuredText Primer`_ is a good place | ||
65 | to get started with reStructuredText. There are also some `Sphinx specific | ||
66 | markup constructs`_. | ||
67 | |||
68 | .. _reStructuredText Primer: http://www.sphinx-doc.org/en/stable/rest.html | ||
69 | .. _Sphinx specific markup constructs: http://www.sphinx-doc.org/en/stable/markup/index.html | ||
70 | |||
71 | Specific guidelines for the kernel documentation | ||
72 | ------------------------------------------------ | ||
73 | |||
74 | Here are some specific guidelines for the kernel documentation: | ||
75 | |||
76 | * Please don't go overboard with reStructuredText markup. Keep it simple. | ||
77 | |||
78 | * Please stick to this order of heading adornments: | ||
79 | |||
80 | 1. ``=`` with overline for document title:: | ||
81 | |||
82 | ============== | ||
83 | Document title | ||
84 | ============== | ||
85 | |||
86 | 2. ``=`` for chapters:: | ||
87 | |||
88 | Chapters | ||
89 | ======== | ||
90 | |||
91 | 3. ``-`` for sections:: | ||
92 | |||
93 | Section | ||
94 | ------- | ||
95 | |||
96 | 4. ``~`` for subsections:: | ||
97 | |||
98 | Subsection | ||
99 | ~~~~~~~~~~ | ||
100 | |||
101 | Although RST doesn't mandate a specific order ("Rather than imposing a fixed | ||
102 | number and order of section title adornment styles, the order enforced will be | ||
103 | the order as encountered."), having the higher levels the same overall makes | ||
104 | it easier to follow the documents. | ||
105 | |||
106 | |||
107 | the C domain | ||
108 | ------------ | ||
109 | |||
110 | The `Sphinx C Domain`_ (name c) is suited for documentation of C API. E.g. a | ||
111 | function prototype: | ||
112 | |||
113 | .. code-block:: rst | ||
114 | |||
115 | .. c:function:: int ioctl( int fd, int request ) | ||
116 | |||
117 | The C domain of the kernel-doc has some additional features. E.g. you can | ||
118 | *rename* the reference name of a function with a common name like ``open`` or | ||
119 | ``ioctl``: | ||
120 | |||
121 | .. code-block:: rst | ||
122 | |||
123 | .. c:function:: int ioctl( int fd, int request ) | ||
124 | :name: VIDIOC_LOG_STATUS | ||
125 | |||
126 | The func-name (e.g. ioctl) remains in the output but the ref-name changed from | ||
127 | ``ioctl`` to ``VIDIOC_LOG_STATUS``. The index entry for this function is also | ||
128 | changed to ``VIDIOC_LOG_STATUS`` and the function can now referenced by: | ||
129 | |||
130 | .. code-block:: rst | ||
131 | |||
132 | :c:func:`VIDIOC_LOG_STATUS` | ||
133 | |||
134 | |||
135 | list tables | ||
136 | ----------- | ||
137 | |||
138 | We recommend the use of *list table* formats. The *list table* formats are | ||
139 | double-stage lists. Compared to the ASCII-art they might not be as | ||
140 | comfortable for | ||
141 | readers of the text files. Their advantage is that they are easy to | ||
142 | create or modify and that the diff of a modification is much more meaningful, | ||
143 | because it is limited to the modified content. | ||
144 | |||
145 | The ``flat-table`` is a double-stage list similar to the ``list-table`` with | ||
146 | some additional features: | ||
147 | |||
148 | * column-span: with the role ``cspan`` a cell can be extended through | ||
149 | additional columns | ||
150 | |||
151 | * row-span: with the role ``rspan`` a cell can be extended through | ||
152 | additional rows | ||
153 | |||
154 | * auto span rightmost cell of a table row over the missing cells on the right | ||
155 | side of that table-row. With Option ``:fill-cells:`` this behavior can | ||
156 | changed from *auto span* to *auto fill*, which automatically inserts (empty) | ||
157 | cells instead of spanning the last cell. | ||
158 | |||
159 | options: | ||
160 | |||
161 | * ``:header-rows:`` [int] count of header rows | ||
162 | * ``:stub-columns:`` [int] count of stub columns | ||
163 | * ``:widths:`` [[int] [int] ... ] widths of columns | ||
164 | * ``:fill-cells:`` instead of auto-spanning missing cells, insert missing cells | ||
165 | |||
166 | roles: | ||
167 | |||
168 | * ``:cspan:`` [int] additional columns (*morecols*) | ||
169 | * ``:rspan:`` [int] additional rows (*morerows*) | ||
170 | |||
171 | The example below shows how to use this markup. The first level of the staged | ||
172 | list is the *table-row*. In the *table-row* there is only one markup allowed, | ||
173 | the list of the cells in this *table-row*. Exceptions are *comments* ( ``..`` ) | ||
174 | and *targets* (e.g. a ref to ``:ref:`last row <last row>``` / :ref:`last row | ||
175 | <last row>`). | ||
176 | |||
177 | .. code-block:: rst | ||
178 | |||
179 | .. flat-table:: table title | ||
180 | :widths: 2 1 1 3 | ||
181 | |||
182 | * - head col 1 | ||
183 | - head col 2 | ||
184 | - head col 3 | ||
185 | - head col 4 | ||
186 | |||
187 | * - column 1 | ||
188 | - field 1.1 | ||
189 | - field 1.2 with autospan | ||
190 | |||
191 | * - column 2 | ||
192 | - field 2.1 | ||
193 | - :rspan:`1` :cspan:`1` field 2.2 - 3.3 | ||
194 | |||
195 | * .. _`last row`: | ||
196 | |||
197 | - column 3 | ||
198 | |||
199 | Rendered as: | ||
200 | |||
201 | .. flat-table:: table title | ||
202 | :widths: 2 1 1 3 | ||
203 | |||
204 | * - head col 1 | ||
205 | - head col 2 | ||
206 | - head col 3 | ||
207 | - head col 4 | ||
208 | |||
209 | * - column 1 | ||
210 | - field 1.1 | ||
211 | - field 1.2 with autospan | ||
212 | |||
213 | * - column 2 | ||
214 | - field 2.1 | ||
215 | - :rspan:`1` :cspan:`1` field 2.2 - 3.3 | ||
216 | |||
217 | * .. _`last row`: | ||
218 | |||
219 | - column 3 | ||
diff --git a/Documentation/index.rst b/Documentation/index.rst index 286d92bad208..bf3eb3ad6ad5 100644 --- a/Documentation/index.rst +++ b/Documentation/index.rst | |||
@@ -38,7 +38,7 @@ merged much easier. | |||
38 | 38 | ||
39 | process/index | 39 | process/index |
40 | dev-tools/index | 40 | dev-tools/index |
41 | kernel-documentation | 41 | doc-guide/index |
42 | 42 | ||
43 | Kernel API documentation | 43 | Kernel API documentation |
44 | ------------------------ | 44 | ------------------------ |
diff --git a/Documentation/kernel-doc-nano-HOWTO.txt b/Documentation/kernel-doc-nano-HOWTO.txt index 062e3af271b7..104740ea0041 100644 --- a/Documentation/kernel-doc-nano-HOWTO.txt +++ b/Documentation/kernel-doc-nano-HOWTO.txt | |||
@@ -1,5 +1,5 @@ | |||
1 | NOTE: this document is outdated and will eventually be removed. See | 1 | NOTE: this document is outdated and will eventually be removed. See |
2 | Documentation/kernel-documentation.rst for current information. | 2 | Documentation/doc-guide/ for current information. |
3 | 3 | ||
4 | kernel-doc nano-HOWTO | 4 | kernel-doc nano-HOWTO |
5 | ===================== | 5 | ===================== |
diff --git a/Documentation/process/4.Coding.rst b/Documentation/process/4.Coding.rst index 983d628c1112..2a728d898fc5 100644 --- a/Documentation/process/4.Coding.rst +++ b/Documentation/process/4.Coding.rst | |||
@@ -358,8 +358,8 @@ them, as appropriate, for externally-available functions. Even in areas | |||
358 | which have not been so documented, there is no harm in adding kerneldoc | 358 | which have not been so documented, there is no harm in adding kerneldoc |
359 | comments for the future; indeed, this can be a useful activity for | 359 | comments for the future; indeed, this can be a useful activity for |
360 | beginning kernel developers. The format of these comments, along with some | 360 | beginning kernel developers. The format of these comments, along with some |
361 | information on how to create kerneldoc templates can be found in the file | 361 | information on how to create kerneldoc templates can be found at |
362 | Documentation/kernel-documentation.rst. | 362 | :ref:`Documentation/doc-guide/ <doc_guide>`. |
363 | 363 | ||
364 | Anybody who reads through a significant amount of existing kernel code will | 364 | Anybody who reads through a significant amount of existing kernel code will |
365 | note that, often, comments are most notable by their absence. Once again, | 365 | note that, often, comments are most notable by their absence. Once again, |
diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst index 3e7905172000..d20d52a4d812 100644 --- a/Documentation/process/coding-style.rst +++ b/Documentation/process/coding-style.rst | |||
@@ -525,8 +525,8 @@ of the function, telling people what it does, and possibly WHY it does | |||
525 | it. | 525 | it. |
526 | 526 | ||
527 | When commenting the kernel API functions, please use the kernel-doc format. | 527 | When commenting the kernel API functions, please use the kernel-doc format. |
528 | See the files Documentation/kernel-documentation.rst and scripts/kernel-doc | 528 | See the files at :ref:`Documentation/doc-guide/ <doc_guide>` and |
529 | for details. | 529 | ``scripts/kernel-doc`` for details. |
530 | 530 | ||
531 | The preferred style for long (multi-line) comments is: | 531 | The preferred style for long (multi-line) comments is: |
532 | 532 | ||
diff --git a/Documentation/translations/zh_CN/CodingStyle b/Documentation/translations/zh_CN/CodingStyle index b02738042799..dc101f48e713 100644 --- a/Documentation/translations/zh_CN/CodingStyle +++ b/Documentation/translations/zh_CN/CodingStyle | |||
@@ -399,7 +399,7 @@ C是一个简朴的语言,你的命名也应该这样。和 Modula-2 和 Pasca | |||
399 | 些事情的原因。 | 399 | 些事情的原因。 |
400 | 400 | ||
401 | 当注释内核API函数时,请使用 kernel-doc 格式。请看 | 401 | 当注释内核API函数时,请使用 kernel-doc 格式。请看 |
402 | Documentation/kernel-documentation.rst和scripts/kernel-doc 以获得详细信息。 | 402 | Documentation/doc-guide/和scripts/kernel-doc 以获得详细信息。 |
403 | 403 | ||
404 | Linux的注释风格是 C89 “/* ... */” 风格。不要使用 C99 风格 “// ...” 注释。 | 404 | Linux的注释风格是 C89 “/* ... */” 风格。不要使用 C99 风格 “// ...” 注释。 |
405 | 405 | ||