Skip to content

Commit 58f38f3

Browse files
committed
docs: split and include languages style guides
1 parent 1b988a1 commit 58f38f3

File tree

5 files changed

+675
-620
lines changed

5 files changed

+675
-620
lines changed

docs/src/code/style-asciidoc.adoc

Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
:lang: en
2+
:toc:
3+
4+
= AsciiDoc Coding Standards
5+
6+
This is a very recent (09/2022) part of this document. Please help shaping
7+
it if you are familiar with asciidoc.
8+
9+
// After looking at the website, and maybe watching the one or other YouTube Video, the
10+
// LinuxCNC documentation is likely the first point of contact for any new
11+
// user. The talent to get the documentation right is mostly disjunct from
12+
// computationally orchestrating all the moving parts of a mill or lathe,
13+
// though. Still, we need this to shine if we want LinuxCNC to shine and
14+
// for a transfer of our knowledge for the next generation - this seems
15+
// fair to say for a project that was started in the last millennium and few
16+
// individuals buying their own mills/lathes before their hair turns gray.
17+
18+
// not really related to the style guide IMHO
19+
// == Overall structure of documentation
20+
21+
// There are two basic documents, i.e. the
22+
// * Users' Guide and the
23+
// * Developers' Guide
24+
25+
// All documents created belong to either of these "parental documents"
26+
// and are included from the respective document, either directly or that
27+
// included file includes it.
28+
29+
30+
== Preamble, TOC, Anchors etc.
31+
32+
Every file should start with a header. This is typically
33+
34+
----
35+
:lang: en
36+
----
37+
38+
and longer documents may also chose to set
39+
40+
----
41+
:toc:
42+
----
43+
44+
This should be followed by an anchor for that section or chapter that is
45+
represented in that file like
46+
47+
----
48+
[[cha:<file-title>]]
49+
----
50+
51+
// For a better consistency, and maintainability, the anchors need to be the same for all langages.
52+
// If the page needs extras, e.g. for the syntax-highlighting, then such lines may then follow.
53+
54+
//.Anchors for titles and other blocks
55+
56+
If a chapter/section header shall be granted the option to be
57+
referenced from another part of the documentation then it needs an anchor.
58+
The anchor shall be a combination of an indicator of the kind
59+
of block that is referenced (cha, sec, fig ,tab, ...) together with a
60+
short name identifying the object.
61+
62+
63+
// * index entries for titles and other blocks
64+
65+
// ?
66+
67+
== Heading/Title Capitalization
68+
69+
The documentation prefers the "Title Case Capitalization". It is defined by several associations. Here the definition by the APA:
70+
71+
.Title Case Capitalization
72+
[quote, APA, 'link:https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case[]']
73+
____
74+
75+
In title case, major words are capitalized, and most minor words are lowercase. [...]
76+
77+
- *major words*: Nouns, verbs (including linking verbs), adjectives, adverbs, pronouns, and all words of four letters or more are considered major words.
78+
- *minor words*: Short (i.e., three letters or fewer) conjunctions, short prepositions, and all articles are considered minor words.
79+
80+
____
81+
82+
// === Lists
83+
84+
// I think we should not define whether we should have a dot at the end of list items or not
85+
86+
== Sections and Subsections
87+
88+
The depth of sections shall not exceed 3 levels. If more structure is needed,
89+
subheadings can be inserted like this:
90+
----
91+
= Chapter
92+
== Section
93+
=== Subsection
94+
.Subheading
95+
----
96+
While "Chapter" corresponds to the document's title.
97+
98+
99+
100+
== Usage of Italic and Monospace Font
101+
102+
Highlighting of special elements like component names, pin names etc. shall be italic.
103+
Short code snippets shall be in monospaecd font.
104+
Headings shall not be formatted either itlaic nor monospaced.
105+
106+
.Example
107+
====
108+
----
109+
If you are using _component_a_ you have to set the use `parameter_x = 500.0`.
110+
----
111+
112+
If you are using _component_a_ you have to set the use `parameter_x = 500.0`.
113+
114+
If you have direction control of your spindle, then the HAL pins _spindle.N.forward_ and _spindle.N.reverse_ are controlled by the G-codes _M3_ and _M4_.
115+
====
116+
117+
118+
== Values and Units
119+
120+
Between a value and its unit shall be always a space, preferably a thin space (U+2009). +
121+
To enter Unicode characters in most graphical editors,
122+
123+
1. press and hold the Left Ctrl and Shift keys and hit the u key and then
124+
2. type the Unicode code with Ctrl + Shift still pressed.
125+
126+
In VIM, press Ctrl + v and then enter the Unicode code with prefixed "u".
127+
128+
129+
== Code Blocks
130+
131+
Asciidoc supports syntax highlighting for several languages.
132+
The most common used in LinuxCNC are: _c, python, sh, tcl, xml_. +
133+
They are used like this:
134+
----
135+
[source,c]
136+
----
137+
// some code
138+
----
139+
----
140+
It also exists some LinuxCNC-specific syntax highlighting
141+
for _hal, ini, ngc_. +
142+
To use those, following lines need to be inserted:
143+
----
144+
// these attributes must come after the document title, to work around a bug in asciidoc 8.6.6
145+
:ini: {basebackend@docbook:'':ini}
146+
:hal: {basebackend@docbook:'':hal}
147+
:ngc: {basebackend@docbook:'':ngc}
148+
----
149+
150+
The keywords for those need to be surrounded by curly braces:
151+
----
152+
[source,{ini}]
153+
----
154+
// some code
155+
----
156+
----
157+
158+
159+
== Pin Listings
160+
161+
.Compact Form
162+
163+
----
164+
* **comp.group.**_N_**.pin** '(type, direction)' - Functional description
165+
----
166+
167+
Example:
168+
====
169+
* **halui.joint.**_N_**.select** '(bit, in)' - Pin for selecting joint N
170+
* **halui.joint.**_N_**.is-selected** '(bit, out)' - Status pin that joint N is selected
171+
* **halui.joint.**_N_**.has-fault** '(bit, out)' - Status pin telling that joint N has a fault
172+
====
173+
Where _N_ is the instance number of the component. If it's a component/module that can only be loaded once, a zero could/should replace _N_.
174+
175+
.Indented Form with Line Break
176+
----
177+
* **comp.group.**_N_**.pin** '(type, direction)':: Functional description
178+
----
179+
180+
Example:
181+
====
182+
**pid.**_N_**.Pgain** '(float, in)':: Proportional gain. Results in a contribution to the output that is the error multiplied by Pgain.
183+
184+
**pid.**_N_**.Igain** '(float, in)':: Integral gain. Results in a contribution to the output that is the integral of the error multiplied by Igain. For example an error of 0.02 that lasted 10 seconds would result in an integrated error (`errorI`) of 0.2, and if Igain is 20, the integral term would add 4.0 to the output.
185+
186+
**pid.**_N_**.Dgain** '(float, in)':: Derivative gain. Results in a contribution to the output that is the rate of change (derivative) of the error multiplied by Dgain. For example an error that changed from 0.02 to 0.03 over 0.2 seconds would result in an error derivative (errorD) of of 0.05, and if Dgain is 5, the derivative term would add 0.25 to the output.
187+
====
188+
189+
== Listings of Commands/Messages
190+
191+
.Panelui
192+
====
193+
.*home_selected*
194+
* required argument: axis number (int)
195+
196+
.*unhome_selected*
197+
* required argument: axis number (int)
198+
199+
.*override_limits*
200+
201+
.*spindle_forward_adjust*
202+
* optional argument: starting RPM (int) - default 100
203+
* Description: If the spindle is stopped it will start in the forward direction.
204+
If it is already running it will increase or decrease the rpm depending on
205+
what direction the spindle is running in.
206+
207+
.*spindle_forward*
208+
* optional argument: starting RPM (int) - default 100
209+
210+
====
211+
212+
213+
.GStat
214+
====
215+
*motion-mode-changed* :: '(returns integer)' -
216+
Sent when motion's mode has changed
217+
218+
*spindle-control-changed* :: '(returns integer, bool, integer, bool)' -
219+
(spindle num, spindle on state, requested spindle direction & rate, at-speed state) +
220+
Sent when spindle direction or running status changes or at-speed changes.
221+
222+
*current-feed-rate* :: '(returns float)' -
223+
Sent when the current feed rate changes.
224+
225+
*current-x-rel-position* :: '(returns float)' -
226+
Sent every 100ms.
227+
228+
*current-position* :: '(returns pyobject, pyobject, pyobject, pyobject)' -
229+
Sent every 100ms. +
230+
returns tuples of position, relative position, distance-to-go and +
231+
the joint actual position. Before homing, on multi-joint axes, only joint +
232+
position is valid.
233+
====
234+
235+
// === ??
236+
// * usage of lists vs titles +
237+
// ?
238+
239+
// * use of bold and italic
240+
// * structure/page splitting guidance
241+
// - avoid 2k+ char long lines
242+
243+
244+
== Images
245+
246+
- Shall be centered
247+
- Shall have a caption if not embedded in the text
248+
----
249+
.Caption
250+
image::image.png["Description",align="center"]
251+
----
252+
253+
254+
== Table Formatting (to be filled by smoe 😉)
255+
Tables can be presented with a series of options.
256+
257+
- header +
258+
With the header-option set, the fist line will be interpreted accordingly.
259+
260+
- column width +
261+
in ideal column, the column is constituted only by its data. No
262+
vertical separators should be required. The horizontal alignment will
263+
also not be required since the writing itself is horizontal enough.
264+
+
265+
If individual fields have too much text then a line-break within that
266+
field should be provoked.
267+
268+
- what lines are visible +
269+
As motivated above, there should be no grid lines.
270+
The top and bottom lines should separate the table from the surrounding text.
271+
Another line could be motivated between the header and the main body.
272+
273+
- captions +
274+
Asciidoc makes it difficult to nicely prepare captions. At the same time,
275+
captions are the only bit of the whole document that even with the first flick
276+
through the document will not escape the reader's attention.
277+
278+
- spaces between ? for po4a
279+
280+
----
281+
Instruction needs to be added
282+
----
283+
284+
285+
== ?
286+
- reference
287+
* figure formatting (captions)
288+
- reference
289+
- caption
290+
----
291+
Instruction needs to be added
292+
----
293+
* footnotes
294+
* comments
295+
* interaction with other media like videos
296+
297+
// vim: set syntax=asciidoc:

0 commit comments

Comments
 (0)