| 1 |
We use PasDoc https://github.com/pasdoc/pasdoc for API documentation. |
| 2 |
Michalis, an author of this engine, is also a PasDoc developer, |
| 3 |
so suggestions about PasDoc improvements are also welcome :) |
| 4 |
|
| 5 |
We use PasDoc with --auto-abstract option. This is very handy, |
| 6 |
and it forces us (in a good way) to write really good 1st sentence |
| 7 |
of every documentation comment. Guidelines below can be summarized as |
| 8 |
"make the 1st sentence of every documentation really meaningful". |
| 9 |
Do's and dont's: |
| 10 |
|
| 11 |
- Do not start a sentence with "This..", like "This function does |
| 12 |
the job of calculating the sensor." or "This returns the calculated sensor |
| 13 |
value." or "This causes sensor value to be calculated." |
| 14 |
or things like that. Usually, the clumsy "This..." part of the sentence |
| 15 |
can be simply removed. Your sentence should simply describe what the |
| 16 |
function / class etc. does, as shortly as possible. |
| 17 |
|
| 18 |
This problem comes usually from a need to use a verb in the 1st documentation |
| 19 |
sentence. Well, there's no need for it. If you have a function |
| 20 |
named "SensorValue" (although "Sensor" seems even better), then user |
| 21 |
already knows that the "sensor value" is calculated by this function. |
| 22 |
The documentation string can be just "Calculate the sensor value.", |
| 23 |
"The sensor value.", or simply nothing, as the function name already |
| 24 |
says everything. |
| 25 |
|
| 26 |
- Write the documentations like orders, not like description. |
| 27 |
E.g. "Do calculation.", not "Does calculation.". |
| 28 |
|
| 29 |
- Do not start the 1st (or, preferably, any other) sentence with |
| 30 |
the name of the item you're just documenting. If you document |
| 31 |
method FooBar, do not write "FooBar does something cool." |
| 32 |
or "FooBar is the collision tag.". |
| 33 |
User reading the description already knows the name of item, |
| 34 |
so just write "Do something cool." or "The collision tag.". |
| 35 |
|
| 36 |
- Using "I.e.", especially at the beginning of the sentence, looks |
| 37 |
clumsy and often should be removed, this forces the sentence to be simpler. |
| 38 |
If you *really* have to, start the sentence with "That is". |
| 39 |
|
| 40 |
- Do not write "Will be called...". Just "Called..." is OK. |
| 41 |
|
| 42 |
- *Always* make a unit description, for every unit. They are handy |
| 43 |
at PasDoc's unit list. |
| 44 |
|
| 45 |
- Often, we have a unit with only a single / a few classes. |
| 46 |
In such cases it's best to place most of the documentation at the class, |
| 47 |
not at the unit description --- since the class is the actual item being |
| 48 |
described. |
| 49 |
|
| 50 |
Unit's description should then contain a very short description of the class |
| 51 |
and a link to the class. Like |
| 52 |
{ Viewport (TCastleViewport). } |
| 53 |
|
| 54 |
- Do not start documentation string with "Simple..." or "Trivial...", |
| 55 |
like "Simple function to calculate cosinus". |
| 56 |
If it was worth including in the engine, then there's some value to it, |
| 57 |
even if the implementation is trivial :) |
| 58 |
Whether it has trivial or not trivial implementation, |
| 59 |
is not of primary interest to the documentation reader. |
| 60 |
The primary concern is "what it does". |
| 61 |
|
| 62 |
We use @groupBegin / @groupEnd tags in our documentation, |
| 63 |
although they are not yet implemented in PasDoc. |
| 64 |
See https://github.com/pasdoc/pasdoc/wiki/MichalisKamburelis -- they are planned. |