blob: b1a2db6c6bda8f1af329d3b271f08d0145ab3193 [file] [log] [blame]
Minos Galanakisc13a5d82020-10-27 11:57:27 +00001#####################################
2Documentation Contribution Guidelines
3#####################################
4
5The Trusted Firmware-M project uses `Sphinx`_ to generated the Official
6Documentation from `Restructed Text`_ `.rst` source files,
7
8The aim is to align as much as possible with the official
9`Python Documentation Guidelines`_ while keeping the consistency with the
10already existing files.
11
12The guidance below is provided as a help. It is not meant to be a definitive
13list.
14
15********
16Overview
17********
18
19The following short-list provides a quick summary of the rules.
20
21- If the patch modifies a present file, the file's style should be followed
22- If creating a new file,
Anton Komlev91281f02022-04-22 09:24:20 +010023 :doc:`integration guide </integration_guide/index>` can be used as a reference.
Minos Galanakisc13a5d82020-10-27 11:57:27 +000024- When a new style is to be expressed, consult the `Python Documentation Guidelines`_
25
26*************
27List of rules
28*************
29The following rules should be considered:
30
31#. H1 document title headers should be expressed by # with over-line
32 (rows on top and bottom) of the text
33#. Only ONE H1 header should allowed per document, ideally placed
34 on top of the page.
35#. H2 headers should be expressed by * with over-line
36#. H2 header's text should be UNIQUE in per document basis
37#. H3 headers should be expressed by an underline of '='
38#. H4 headers should be expressed by an underline of '-'
39#. H3 and H4 headers have no limitation about naming.
40 They can have similar names on the same document, as long as
41 they have different parents.
42#. H5 headers should be expressed by an underline of '^'
43#. H5 headers will be rendered in document body but not in
44 menus on the navigation bar
45#. Do not use more than 5 levels of heading
46#. When writing guides, which are expected to be able to be readable by
47 command line tools, it would be best practice to add long complicated
48 tables, and UML diagrams in the bottom of the page and using internal
49 references(auto-label)
50#. No special formatting should be allowed in Headers
51 (code, underline, strike-through etc)
52#. Long URLs and external references should be placed at the bottom of the
53 page and referenced in the body of the document
54#. New introduced terms and abbreviations should be added to Glossary and
55 directly linked by the `:term:` notation across all documents using it.
56
Minos Galanakisc13a5d82020-10-27 11:57:27 +000057**********************
58Platform Documentation
59**********************
60
61The Documentation Build system provides an interface with the platform directory
Anton Komlev90657c12023-01-17 13:01:22 +000062allowing maintainers to bundle platform specific documentation. Platforms are
63grouped by vendor. **This behaviour needs to be explicitly enabled for each
64vendor's space** by providing the `<vendor>/index.rst` (responsible for generating the
Anton Komlevde14f452022-06-19 15:45:26 +010065:doc:`Platform Index File </platform/index>`) and adding a table of
Anton Komlev90657c12023-01-17 13:01:22 +000066contents entry for the corresponding vendor's space.
Minos Galanakisc13a5d82020-10-27 11:57:27 +000067The format and structure of this entry is not strictly defined, and allows
Anton Komlev90657c12023-01-17 13:01:22 +000068flexible control of vendor's and platform's documentation space.
69Follow the :ref:`platform_documentation` document for more details.
Minos Galanakisc13a5d82020-10-27 11:57:27 +000070
71****************
72Common Use Cases
73****************
74
75The section below describes with examples, a rule compliant implementation
76for most common documentation elements.
77
78Headers
79=======
80
Minos Galanakisc13a5d82020-10-27 11:57:27 +000081.. code-block:: restructuredtext
82
83 ###################
84 Document Title (H1)
85 ###################
86
87 ******************
88 Chapter Ttitle(H2)
89 ******************
90
91 Chapter Section (H3)
92 ====================
93
94 Chapter Sub-Section (H4)
95 ------------------------
96
97 Subsection of Chapter sub-section (H5)
98 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99
100Code Blocks
101===========
102
Minos Galanakisc13a5d82020-10-27 11:57:27 +0000103The recommendation for code content, is to use the explicit code-block directive,
104ideally with a defined lexer for the language the block contains.
105
106A list of compatible lexers can be found at `Pygments Lexers`_
107
108.. code-block:: restructuredtext
109
110 .. code-block:: bash
111
112 ls
113 pwd
114
115 .. code-block:: doscon
116
117 dir
118
119 .. code-block:: c
120
121 static struct rn_object_t;
122
123 .. code-block:: python3
124
125 print("Hello TF-M")
126
127
128Restructured Text supports implicit code-blocks by indenting a section of text,
129surrounded by new lines. While this formatting is
130allowed, it should be avoided if possible.
131
132.. code-block:: restructuredtext
133
134 The quick brown fox jumps over the lazy dog
135
136 ls
137 pwd
138
139.. Note::
140
141 Mixing two different code-block formats in the same document will break
142 the whole document's rendering. When editing an existing document, please
143 follow the existing format.
144
145 **New documents should always use the explicit format.**
146
147Tables
148======
149
150For adding new tables the `table::` notation should be used.
151
152.. code-block:: restructuredtext
153
154 .. table:: Components table
155 :widths: auto
156
157 +--------------+--------------+-------------+
158 | **Title A** | **Title B** | **Title C** |
159 +==============+==============+=============+
160 | Text A | Text B | Text C |
161 +--------------+--------------+-------------+
162
163
164While the equivalent simple table code will render correctly in the output, it
165will not be added to the index (So it cannot be referenced if needed)
166
167.. code-block:: restructuredtext
168
169 +--------------+--------------+-------------+
170 | **Title A** | **Title B** | **Title C** |
171 +==============+==============+=============+
172 | Text A | Text B | Text C |
173 +--------------+--------------+-------------+
174
175Other types of tables such as list-tables and csv-tables are also permitted, as
Anton Komlev3356ba32022-03-31 22:02:11 +0100176seen on :doc:`/getting_started/tfm_getting_started` and
177:doc:`/releases/1.0`
Minos Galanakisc13a5d82020-10-27 11:57:27 +0000178
179
180External Links
181==============
182
183External links should be placed in the bottom of a document.
184
185.. code-block:: restructuredtext
186
187 The quick brown fox jumps over the lazy dog according to `Link_A`_
188
189 .. _Link_A: https://www.aaa.org
190 .. _Link_B: https://www.bbb.org
191
192 --------------
193
194 *Copyright (c) XYZ *
195
196Creating in-line links is permitted, but should be avoided if possible. It
197should be only used for consistency purposes or for a small ammount
198of short links.
199
200.. code-block:: restructuredtext
201
202 The quick brown fox jumps over the lazy dog according to `Link_A <https://www.aaa.org>`_
203
204If for the purposes of content, a link is to be referenced by multiple
205labels, internal linking is the recommended approach.
206
207.. code-block:: restructuredtext
208
209 The quick brown fox jumps over the lazy dog according to `Link_A_New`_
210
211 .. _Link_A: https://www.aaa.org
212 .. _Link_A_New: `Link_A`_
213
214 --------------
215
216 *Copyright (c) XYZ *
217
Minos Galanakisc13a5d82020-10-27 11:57:27 +0000218Document Links
219==============
220
221A document included in the documentation can be referenced by the `doc:` notation
222
223.. code-block:: restructuredtext
224
Anton Komlev3356ba32022-03-31 22:02:11 +0100225 :doc:`integration guide </integration_guide/tfm_integration_guide>`
Minos Galanakisc13a5d82020-10-27 11:57:27 +0000226
227The path is relative to the root of the Trusted Firmware-M code.
228
229Reference specific section of a document
230========================================
231
232In order to reference a specific section of a document, up to level 4 headers
233(if they are included in the index), the `ref:` keyword can be used
234
235.. code-block:: restructuredtext
236
Summer Qin6d5c91c2021-05-24 15:32:44 +0800237 :ref:`docs/getting_started/tfm_getting_started:Tool & Dependency overview`
Minos Galanakisc13a5d82020-10-27 11:57:27 +0000238
239This can also be used to quickly scroll to the specific section of the current
240document. This technique can be used to add complex table in the bottom of a
241document and create clickable quick access references to it for improved user
242experience.
243
Minos Galanakisc13a5d82020-10-27 11:57:27 +0000244Glossary term
245=============
246
247For technical terms and abbreviations, the recommended guidance is to add an
Anton Komlev3356ba32022-03-31 22:02:11 +0100248entry to the :doc:`/glossary` and refer to it, using the `term:`
Minos Galanakisc13a5d82020-10-27 11:57:27 +0000249directive
250
Minos Galanakisc13a5d82020-10-27 11:57:27 +0000251.. code-block:: restructuredtext
252
253 HAL
254 Hardware Abstraction Layer
255 Interface to abstract hardware-oriented operations and provides a set of
256 APIs to the upper layers.
257
258 .....
259
260 As described in the design document :term:`HAL` abstracts the
261 hardware-oriented and platform specific
262 .......
263
264.. Note::
265
266 The ":term:" directive does not work when used in special formatting.
267 Using \*:term:`HAL`\* **will not link to the glossary term**.
268
269References
270==========
271
272#. `Sphinx`_
273#. `Restructed Text`_
274#. `Python Documentation Guidelines`_
275#. `Pygments Lexers`_
276
277.. _Sphinx: https://www.sphinx-doc.org/en/master/
278.. _Restructed Text: https://docutils.sourceforge.io/rst.html
Awadhy Mohammed3ba2d062023-03-02 10:43:07 +0000279.. _Python Documentation Guidelines: https://devguide.python.org/documentation/style-guide/
280.. _Pygments Lexers: https://pygments.org/docs/api/#lexers
Minos Galanakisc13a5d82020-10-27 11:57:27 +0000281
282--------------
283
Anton Komlev90657c12023-01-17 13:01:22 +0000284*Copyright (c) 2020-2023, Arm Limited. All rights reserved.*