Debian Codegraph @

src/bonsai/docs/guides/development/writing_docs.rst

raw
1 Writing documentation
2 =====================
3
4 A great way to contribute without writing code is to help writing
5 documentation. Please reach out before contributing as the software is still in
6 an alpha state and portions may not be worth documenting as it changes too
7 frequently.
8
9 Philosophy
10 ----------
11
12 The documentation is split into three sections:
13
14 1. **Quickstart**: a crash course where a user should be able to go from
15 nothing to doing the most basic, common tasks. It is not comprehensive, but
16 a highly focused tutorial style "taster" of what's available. It should be
17 kept very short, aiming to acquaint new users within an hour.
18 2. **Guides**: a guidebook style, topic-driven series of articles discussing
19 things of interest, or tutorials that cover common workflows. This should
20 contain lots of images.
21 3. **Reference**: a comprehensive index of the entire interface and all
22 available features.
23
24 Documentation should not be a guide to IFC. Users should not have to know what
25 IFC is.
26
27 Official documentation should be polished and maintained. Less documentation of
28 a higher quality that is kept updated with every release is preferred to more
29 documentation with stubs, incomplete or inaccurate information.
30
31 Syntax
32 ------
33
34 All documentation is written in ReStructured Text and is available in the
35 `Bonsai docs directory
36 <https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.8.0/src/bonsai/docs>`_.
37 You can press the edit button on the top right on any documentation page to
38 quickly edit their content.
39
40 Links
41 ^^^^^
42
43 You can link to
44
45 .. code-block:: restructuredtext
46
47 `external websites
48 <https://docs.readthedocs.io/en/stable/guides/cross-referencing-with-sphinx.html>`_
49
50 (note the space between the url and the link text). You can also link to
51 sections on the same page, like
52
53 .. code-block:: restructuredtext
54
55 :ref:`guides/development/writing_docs:Writing technical documentation`
56
57 or with
58
59 .. code-block:: restructuredtext
60
61 :ref:`custom text<guides/development/writing_docs:writing technical documentation>`.
62
63 Traditional references like
64
65 .. code-block:: restructuredtext
66
67 `Writing technical documentation`_
68
69 work too but are discouraged. You can link to other pages, like this:
70
71 .. code-block:: restructuredtext
72
73 :doc:`Hello World<guides/development/writing_docs>`
74
75 or sections within other pages, like this:
76
77 .. code-block:: restructuredtext
78
79 :ref:`guides/development/installation:unstable installation`
80
81 We have ``autosectionlabel`` enabled so it is not necessary to manually create labels. The depth of sections
82 with automatic labels is set to 2, so the third level of titles
83 will not get automatic labels to avoid duplication.
84
85 You can still create labels manually. This way you would ensure links still works when documentation is refactored.
86
87 .. code-block:: restructuredtext
88
89 .. _My label:
90
91 My Section
92 ==========
93
94 :ref:`Link to My Section <My label>`
95
96 This link will work across the documentation. Make sure the label is globally unique.
97
98 Images
99 ^^^^^^
100
101 The following colours and annotation styles should be used for annotating
102 images. All stroke widths are 3px with a corner radius of 3px. Horizontal
103 underlines are 5px with a corner radius of 2px. The dark green is ``39b54a`` and
104 the light green is ``d9e021``.
105
106 .. image:: images/documentation-style.png
107
108 Special keywords such as **Technical Terminology** that the user should be
109 aware of should be bolded, titlecased, and used consistently. You *may*
110 use italics to emphasize words or phrases. Inline code must be ``quoted`` and
111 longer code snippets may use code blocks.
112
113 .. code-block:: bash
114
115 cd /path/to/bonsai
116 ls
117
118 Be sure to specify the language to enable syntax highlighting.
119
120 .. code-block:: python
121
122 print("Hello, world!")
123
124 A button may be used to point users to a critical sample file or
125 download.
126
127 .. container:: blockbutton
128
129 `Visit critical link <https://bonsaibim.org>`__
130
131 You can use bulleted lists:
132
133 - Like.
134 - This.
135
136 Or ordered lists:
137
138 1. Like.
139 2. This.
140
141 .. note::
142
143 Instead of writing "Note that XYZ ..." you should use notes sparingly to
144 highlight "gotchas".
145
146 .. tip::
147
148 Tips may be used to add a useful but optional suggestion.
149
150 .. warning::
151
152 Warnings may be used to highlight common mistakes.
153
154 .. seealso::
155
156 See also blocks should be used to reference `further reading
157 <https://bonsaibim.org>`__ links.
158
159 Tables can be very annoying to format. You can use a CSV table instead.
160
161 .. csv-table::
162 :header: "Foo", "Bar", "Baz"
163
164 "ABC", "01", "02"
165 "DEF", "03", "04"
166
167 Building documentation
168 ----------------------
169
170 If you want to build the documentation locally, the documentation system uses
171 `Sphinx <https://www.sphinx-doc.org/en/master/>`_. First, install the theme and
172 theme dependencies:
173
174 .. code-block:: bash
175
176 pip install furo
177 pip install sphinx-autoapi
178 pip install sphinx-copybutton
179
180 Now you can generate the documentation:
181
182 .. code-block:: bash
183
184 cd /path/to/ifcopenshell/src/bonsai/docs/
185 make html
186 cd _build/html
187 python -m http.server
188
189 .. warning::
190
191 .. warning::
192
193 Depending on your machine and environment, you might need to use ``.\make`` instead of ``make``.
194
195 You will now have a local webserver running hosting the documentation. Your terminal
196 will return something like seen underneath, replace [::] with localhost.
197
198 .. code:: console
199
200 Serving HTTP on :: port 8000 (http://[::]:8000/) ...
201
202 Streamlining your workflow
203 ^^^^^^
204 Now that you have added or changed some content in the documentation, you may want to see it on the webserver.
205 Initially you can:
206
207 - Kill the terminal, eg. the server.
208 - Run the make and build sequence as above again.
209
210 .. tip::
211
212 If you make small incremental changes, you can avoid the cd navigation in many IDE's
213 by right clicking on the docs folder and open a fresh terminal from there.
214
215 This will work, but it is not very efficient. You can streamline your workflow by setting
216 up a run and debug configuration in your IDE. Below is an example for VScode placed in your
217 .vscode folder in the root.
218
219 *task.json*
220
221 .. code:: json
222
223 {
224 "version": "2.0.0",
225 "tasks": [
226 {
227 "label": "Build and Serve Docs",
228 "type": "shell",
229 "command": "powershell",
230 "args": [
231 "-NoProfile",
232 "-ExecutionPolicy",
233 "Bypass",
234 "-Command",
235 "cd D:/ifcopenshell/src/bonsai/docs/; .\\make html; cd _build/html; python -m http.server"
236 ],
237 "group": {
238 "kind": "build",
239 "isDefault": true
240 },
241 "problemMatcher": []
242 }
243 ]
244 }
245
246 *launch.json*
247
248 .. code:: json
249
250 {
251 "version": "0.2.0",
252 "configurations": [
253 {
254 "name": "BonsaiDocsServer",
255 "type": "python",
256 "request": "launch",
257 "program": "D:/ifcopenshell/src/bonsai/docs/_build/html",
258 "args": ["-m", "http.server"],
259 "preLaunchTask": "Build and Serve Docs",
260 "console": "integratedTerminal"
261 }
262 ]
263 }
264
265 Now you can run the debugger, it will build the documentation and start the server.
266 Simply stop debugging to stop the server and rerun the debugger to see your changes.
267
268
269
270
271