Debian Codegraph @

Documentation/getting_started/writing_documentation.md

raw symbols SCIP
1 # coreboot documentation guidelines
2
3 > Documentation is like sex: when it is good, it is very, very good;
4 > and when it is bad, it is better than nothing.
5
6 That said please always try to write documentation! One problem in the
7 firmware development is the missing documentation. In this document
8 you will get a brief introduction how to write, submit and publish
9 documentation to coreboot.
10
11 ## Preparations
12
13 coreboot uses [Sphinx] documentation tool. We prefer the markdown format
14 over reStructuredText so only embedded ReST is supported. Checkout the
15 [Markdown Guide] for more information.
16
17 ### Option 1: Use the docker image
18
19 The easiest way to build the documentation is using a docker image.
20 To build the image run the following in the base directory:
21
22 make -C util/docker/ doc.coreboot.org
23
24 To build the documentation:
25
26 make -C util/docker docker-build-docs
27
28 To have the documentation build and served over a web server live run:
29
30 make -C util/docker docker-livehtml-docs
31
32 On the host machine, open a browser to the address <http://0.0.0.0:8000>.
33
34 ### Option 2: Install Sphinx
35
36 Please follow this official [guide] to install sphinx. You will also need
37 myst-parser for sphinx to be able to handle markdown documentation.
38
39 Since some Linux distributions don't package every needed sphinx extension,
40 the installation via pip in a venv is recommended. You'll need these python3
41 modules:
42
43 * sphinx
44 * myst-parser
45 * sphinx-rtd-theme
46
47 The following combination of versions has been tested: sphinx 8.1.3,
48 myst-parser 4.0.0, and sphinx-rtd-theme 2.0.0.
49
50 Now change into the `Documentation` folder in the coreboot directory and run
51 this command in there
52
53 make
54
55 If no error occurs, you can find the generated HTML documentation in
56 `Documentation/_build/html` now.
57
58 ### Optional
59
60 Install [sphinx-autobuild] for rebuilding markdown/rst sources on the fly!
61
62 ## Basic and simple rules
63
64 The following rules should be followed in order to get it at least reviewed
65 on [review.coreboot.org].
66
67 Documentation:
68
69 1. Must be written in **markdown** with **embedded reStructuredText**
70 format.
71 2. Must be written in **English**.
72 3. Must be placed into **Documentation/** directory subfolder.
73 4. Should follow the same directory structure as **src/** when practical.
74 5. Must be referenced from within other markdown files
75 6. The commit must follow the [Gerrit Guidelines].
76 7. Must have all **lowercase filenames**.
77 8. Running text should have a visible width of about **72 chars**.
78 9. Should not **duplicate** documentation, but reference it instead.
79 10. Must not include the same picture in multiple markdown files.
80 11. Images should be kept small. They should be under 700px in width, as
81 the current theme doesn't allow bigger images.
82 12. Shouldn't cover implementation details; for details, the code is the
83 reference.
84
85 ## Markdown and Tables
86
87 Markdown tables are supported:
88
89 | Header 1 | Header 2 | Header 3 |
90 |------------|-----------|-----------|
91 | body row 1 | column 2 | column 3 |
92 | body row 2 | column 2 | column 3 |
93
94 Tables can also be written using embedded reStructured Text, which provides
95 additional features like the ability to merge cells:
96
97 ```{eval-rst}
98 +------------+------------+-----------+
99 | Header 1 | Header 2 | Header 3 |
100 +============+============+===========+
101 | body row 1 | column 2 | column 3 |
102 +------------+------------+-----------+
103 | body row 2 | Cells may span columns.|
104 +------------+------------+-----------+
105 | body row 3 | Cells may | - Cells |
106 +------------+ span rows. | - contain |
107 | body row 4 | | - blocks. |
108 +------------+------------+-----------+
109 ``` #just a code block is enough
110
111 ## TocTree
112
113 To make sure that all documents are included into the final documentation, you
114 must reference each document from at least one *toctree*. The *toctree* must
115 only reference files in the same folder or in subfolders !
116 To create a toctree, you must use the following syntax to invoke the
117 Sphinx toctree directive:
118
119 **Example toctree:**
120
121 ```{toctree}
122 :maxdepth: 1
123
124 Chapter 1 <chapter1.md>
125 Chapter 2 <chapter2.md>
126 Subchapter <sub/index.md>
127 ```
128
129 References in regular text aren't considered as *toctree* .
130
131 If you do only reference the document, but do not include it in any toctree,
132 you'll see the following warning:
133 **WARNING: document isn't included in any toctree**
134
135 ## CSV
136
137 You can import CSV files and let sphinx automatically convert them to human
138 readable tables, using the following reStructuredText snipped:
139
140 ```{eval-rst}
141 .. csv-table::
142 :header: "Key", "Value"
143 :file: keyvalues.csv
144 ```
145
146 Of course this can only be done from a markdown file that is included in the
147 TOC tree.
148
149 [sphinx-autobuild]: https://github.com/sphinx-doc/sphinx-autobuild
150 [guide]: https://www.sphinx-doc.org/en/master/usage/installation.html
151 [Sphinx]: https://www.sphinx-doc.org/en/master/
152 [Markdown Guide]: https://www.markdownguide.org/
153 [Gerrit Guidelines]: ../contributing/gerrit_guidelines.md
154 [review.coreboot.org]: https://review.coreboot.org