2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
6 .. _building_documentation:
11 The main GCC documentation uses `Sphinx`_ to generate pretty documentation
12 from `reStructuredText`_ format.
13 These are input for Manual pages format (:command:`make man`),
14 Info format (:command:`make info`), HTML format (:command:`make html`)
15 and PDF format (:command:`make pdf`).
17 .. _Sphinx: http://www.sphinx-doc.org/
18 .. _reStructuredText: http://docutils.sourceforge.net/rst.html
25 The ReST markups currently used by the documentation files are meant to be
26 built with ``Sphinx`` version |needs_sphinx| or higher.
28 Most distributions are shipped with Sphinx, but its toolchain is fragile,
29 and it is not uncommon that upgrading it or some other Python packages
30 on your machine would cause the documentation build to break.
32 A way to avoid that is to use a different version than the one shipped
33 with your distributions. In order to do so, it is recommended to install
34 Sphinx inside a virtual environment, using ``virtualenv-3``
35 or ``virtualenv``, depending on how your distribution packaged Python 3.
37 .. code-block:: shell-session
39 $ virtualenv /tmp/venv
40 $ source /tmp/venv/bin/activate
41 $ pip install -r requirements.txt
43 Note the :file:`requirements.txt` file is placed in :rst:dir:`gcc/doc` folder and contains the following packages:
45 .. literalinclude:: ../../../../../doc/requirements.txt
46 :caption: requirements.txt
48 Then the virtualenv can be provided to the configure script :option:`install:--with-sphinx-build`
49 and will be used by the build system:
51 .. code-block:: shell-session
53 $ configure --with-sphinx-build=/tmp/venv/bin/sphinx-build
55 If you want to build the PDF documentation, you will need ``python3-Sphinx-latex`` sub-package.
59 When building **manual** and **info** pages (built by default), the only dependency
60 is Sphinx package and one can ignore other dependencies mentioned in :file:`requirements.txt`.
65 Adding new documentation can be as simple as:
67 1. Add a new ``.rst`` file somewhere under a ``doc`` subfolder.
68 2. Refer to it from the Sphinx main `TOC tree`_ in a ``index.rst`` file.
70 .. _TOC tree: http://www.sphinx-doc.org/en/stable/markup/toctree.html
72 This is usually good enough for simple documentation (like the one you're
73 reading right now), but for larger documents it may be advisable to create a
74 subdirectory (or use an existing one).
76 See the documentation for `Sphinx`_ and `reStructuredText`_ on what you can do
77 with them. In particular, the Sphinx `reStructuredText Primer`_ is a good place
78 to get started with reStructuredText. There are also some `Sphinx specific
79 markup constructs`_ and `Usefull RST cheatsheet`_.
81 .. _reStructuredText Primer: http://www.sphinx-doc.org/en/stable/rest.html
82 .. _Sphinx specific markup constructs: http://www.sphinx-doc.org/en/stable/markup/index.html
83 .. _Usefull RST cheatsheet: https://github.com/ralsina/rst-cheatsheet/blob/master/rst-cheatsheet.rst
85 Specific guidelines for the GCC documentation
86 ---------------------------------------------
88 Here are some specific guidelines for the GCC documentation:
90 * Please stick to this order of heading adornments:
92 1. ``=`` with overline for document title:
100 2. ``-`` for chapters:
107 3. ``*`` for sections:
114 4. ``^`` for subsections:
121 5. ``~`` for subsubsections:
128 Although RST doesn't mandate a specific order ("Rather than imposing a fixed
129 number and order of section title adornment styles, the order enforced will be
130 the order as encountered."), having the higher levels the same overall makes
131 it easier to follow the documents.
133 * For inserting fixed width text blocks (for code examples, use case
134 examples, etc.), use ``::`` for anything that doesn't really benefit
135 from syntax highlighting, especially short snippets. Use
136 ``.. code-block:: <language>`` for longer code blocks that benefit
137 from highlighting. For a short snippet of code embedded in the text, use ````code snippet````.
139 * For parts of documentation that needs to be written or enhanced, use ``.. todo::`` directive
140 (part of the official ``sphinx.ext.todo`` extension). In development mode, all items
141 are listed at the very end of the documentation for easier navigation.
143 GCC-specific directives and roles
144 ---------------------------------
146 GCC uses its own extension (:file:`gcc_sphinx.py`) that defined various directives. For the complete
147 list of target-specific attributes, please take a look at the extension definition:
156 - Generic GCC attribute
167 * - ``$target-fn-attr``
168 - Target-specific function attribute (e.g. ``.. x86-fn-attr:: interrupt``)
169 * - ``$target-var-attr``
170 - Target-specific variable attribute
171 * - ``$target-type-attr``
172 - Target-specific type attribute
174 - GCC parameter directive, (e.g. ``.. gcc-param: inline-unit-growth``)
176 Apart from the directives, we also define various inline roles:
185 - Link to WG21 - The C++ Standards Committee (e.g. ``:P:`2003```)
187 - Link to GCC bugzilla entry
188 * - ``:openmp:`$version```
189 - Link to OpenMP documentation version ``$version`` (e.g. ``:openmp:`4.5```)
190 * - ``:openacc:`$version```
191 - Link to OpenACC documentation version ``$version``
192 * - ``|gcc_version|``
193 - Version of the documentation (e.g. |gcc_version|, taken from :file:`BASE-VER`)
194 * - ``|needs_sphinx|``
195 - Minimal required Sphinx version (e.g. |needs_sphinx|, taken from :file:`baseconf.py`)
197 - URL to bugzilla instance (e.g. |bugurl|)
198 * - ``|package_version|``
199 - Package version (e.g. |package_version|)
201 - Line break used for PDF version
203 - Non-breaking space character
205 .. _miscellaneous-docs:
207 Miscellaneous Documentation
208 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
210 In addition to the formal documentation that is installed by GCC,
211 there are several other text files in the :samp:`gcc` subdirectory
212 with miscellaneous documentation:
214 :samp:`ABOUT-GCC-NLS`
215 Notes on GCC's Native Language Support.
217 .. todo:: this should be part of this manual rather than a separate file
220 Notes on the Free Translation Project.
223 The GNU General Public License, Versions 2 and 3.
225 :samp:`COPYING.LIB` :samp:`COPYING3.LIB`
226 The GNU Lesser General Public License, Versions 2.1 and 3.
228 :samp:`*ChangeLog*` :samp:`*/ChangeLog*`
229 Change log files for various parts of GCC.
232 Details of a few changes to the GCC front-end interface.
234 .. todo:: the information in this file should be part of general documentation of
235 the front-end interface in this manual.
238 Information about new features in old versions of GCC. (For recent
239 versions, the information is on the GCC web site.)
241 :samp:`README.Portability`
242 Information about portability issues when writing code in GCC.
244 .. todo:: why isn't this part of this manual or of the GCC Coding Conventions?
246 .. todo:: document such files in subdirectories, at least :samp:`config`,
247 :samp:`c`, :samp:`cp`, :samp:`objc`, :samp:`testsuite`.