Doxygen: Difference between revisions
Lou Montana (talk | contribs) (Add Class documentation info + Examples) |
Lou Montana (talk | contribs) m (Some additional details) |
||
(10 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
{{Feature|informative| | {{Feature|informative| | ||
* The official Doxygen documentation can be found here: https://www.doxygen.nl/manual/ | * The official Doxygen format documentation can be found here: https://www.doxygen.nl/manual/ | ||
* See also {{Link/ | * See also {{Link|enfusion://ScriptEditor/scripts/Game/Examples/SCR_ExampleDoxygen.c;52|SCR_ExampleDoxygen}} for "live" examples. | ||
}} | }} | ||
{{Feature|important|What is not documented does not exist!}} | {{Feature|important|2= <div style="font-size: 1.25em; text-align: center">What is not documented does not exist!</div>}} | ||
== Project Documentation == | == Project<!-- s --> Documentation == | ||
{ | {| class="wikitable" | ||
! Game | |||
{{ | ! File Location | ||
! Download | |||
|- | |||
| {{armaR}} | |||
| {{Link|https://store.steampowered.com/app/1874910/Arma_Reforger_Tools/|{{armaR}} Tools}} \ {{hl|Workbench\docs}} | |||
| {{GameCategory|armaR|Modding|Guidelines|Scripting|text= {{armaR}} Scripting Guidelines Hub}} | |||
|- | |||
|} | |||
Line 28: | Line 35: | ||
{{Name|bi}} recommendations: | {{Name|bi}} recommendations: | ||
* use {{hl|/*! */}} | * use {{hl|//!}} and {{hl|//!<}} | ||
* do not go too much into details (e.g | ** {{hl|/*! */}}, {{hl|///}} and {{hl|/** */}} are to be avoided (inline comment is preferred in order to remain able to comment big chunks of code with {{hl|/* */}} without conflict) | ||
* do not over-document code ( | * do not go too much into details (e.g {{hl|//! This method does xxx if provided Y but will not do it if Z is set to true at line 246 and ...}}) | ||
* do not over-document code (e.g {{hl|//! Get the name}} on {{hl|string GetName()}} is of absolutely no value); again, code should be self-explanatory and a comment should explain a design decision (if needed) | |||
See {{Link|#Examples}} below. | |||
{{Feature|important| | {{Feature|important| | ||
Line 44: | Line 54: | ||
Grouping is usually done in a different comment block than class comment. | Grouping is usually done in a different comment block than class comment. | ||
<enforce> | <enforce> | ||
/ | //! This class is a databag used by the TAG_WholeSystemClass's WholeSystem feature. | ||
This class is a databag used by the TAG_WholeSystemClass's WholeSystem feature. | //! Member variables are public for that purpose. It holds info X and Y related to Z. | ||
Member variables are public for that purpose. It holds info X and Y related to Z. | |||
class TAG_MyDataClass | class TAG_MyDataClass | ||
{ | { | ||
Line 60: | Line 68: | ||
A method documentation goes below the {{hl|//---}} separator and must ideally document the method's purpose, its '''parameters''', and its '''return value'''. | A method documentation goes below the {{hl|//---}} separator and must ideally document the method's purpose, its '''parameters''', and its '''return value'''. | ||
{{Feature|warning|'''Always''' amend the documentation when changing a method's signature!}} | {{Feature|warning|'''Always''' amend the documentation when changing a method's signature/behaviour!}} | ||
<enforce> | <enforce> | ||
Line 66: | Line 74: | ||
{ | { | ||
//------------------------------------------------------------------------------------------------ | //------------------------------------------------------------------------------------------------ | ||
/ | //! Documentation goes here with the same indent | ||
int GetIntMethod1(bool returnPositive) | int GetIntMethod1(bool returnPositive) | ||
{ | { | ||
Line 75: | Line 81: | ||
//------------------------------------------------------------------------------------------------ | //------------------------------------------------------------------------------------------------ | ||
/ | /*! | ||
Alternative syntax - not recommended in {{armaR}} | |||
Note that indentation is on the same level as the comment start | |||
*/ | |||
int GetIntMethod2(bool returnPositive) | int GetIntMethod2(bool returnPositive) | ||
{ | { | ||
Line 85: | Line 94: | ||
Various parameter formats: | Various parameter formats: | ||
<enforce> | <enforce> | ||
//! \param myParam parameter description | //! \param[in] myParam parameter description | ||
//! \param[out] myParam parameter description | //! \param[out] myParam parameter description | ||
//! \param[ | //! \param[in,out] myParam parameter description | ||
</enforce> | </enforce> | ||
Line 114: | Line 123: | ||
//------------------------------------------------------------------------------------------------ | //------------------------------------------------------------------------------------------------ | ||
//! Detects obstacles based on current settings - a SCR_ObstacleDetector.RefreshObstaclesBy*() method must have been called earlier | //! Detects obstacles based on current settings - a SCR_ObstacleDetector.RefreshObstaclesBy*() method must have been called earlier | ||
//! \param worldPos the location to check - only the 2D position will be checked | //! \param[in] worldPos the location to check - only the 2D position will be checked | ||
//! \param exclusionList list of entities that should not be considered as obstacles | //! \param[in] exclusionList list of entities that should not be considered as obstacles | ||
//! \return true if an obstacle has been detected or on error, false otherwise | //! \return true if an obstacle has been detected or on error, false otherwise | ||
bool HasObstacle(vector worldPos, array<IEntity> exclusionList = null) | bool HasObstacle(vector worldPos, array<IEntity> exclusionList = null) | ||
Line 145: | Line 154: | ||
//------------------------------------------------------------------------------------------------ | //------------------------------------------------------------------------------------------------ | ||
//! Returns true if has obstacle | //! Returns true if has obstacle | ||
//! \param worldPos the world position | //! \param[in] worldPos the world position | ||
//! \param exclusionList the exclusion list | //! \param[in] exclusionList the exclusion list | ||
//! \return true or false | //! \return true or false | ||
bool HasObstacle(vector worldPos, array<IEntity> exclusionList = null) | bool HasObstacle(vector worldPos, array<IEntity> exclusionList = null) | ||
Line 162: | Line 171: | ||
| | | | ||
This one is one of the worst possible cases: '''no comment is better than a wrong comment'''.<br> | This one is one of the worst possible cases: '''no comment is better than a wrong comment'''.<br> | ||
Prefer leaving it undocumented (ideally with a TODO) if you do not have the time to document your code at the moment. | Prefer leaving it undocumented (ideally with a {{hl|// TODO}}) if you do not have the time to document your code at the moment. | ||
|} | |} | ||
Line 168: | Line 177: | ||
== See Also == | == See Also == | ||
* https://www.doxygen.nl/ - the official Doxygen website | * {{Link|https://www.doxygen.nl/}} - the official Doxygen website | ||
* https://www.doxygen.nl/manual/ - the official documentation | * {{Link|https://www.doxygen.nl/manual/}} - the official documentation | ||
* {{Link|https://www.doxygen.nl/manual/commands.html}} - \commands list | |||
{{GameCategory|armaR|Modding|Guidelines|Scripting}} | {{GameCategory|armaR|Modding|Guidelines|Scripting}} | ||
{{GameCategory|arma4|Modding|Guidelines|Scripting}} | {{GameCategory|arma4|Modding|Guidelines|Scripting}} |
Latest revision as of 18:58, 24 July 2024
Doxygen is a tool that generates documentation from code comment respecting a certain format. This code documentation is used across Enfusion projects, starting with Arma Reforger.
Project Documentation
Game | File Location | Download |
---|---|---|
Arma Reforger | Arma Reforger Tools \ Workbench |
Arma Reforger Scripting Guidelines Hub |
Bohemia Interactive Guidelines
Documentation is important:
- Document what is public (protected methods go second - people should use public methods anyway)
- Document what is important (features, concepts, specifics like variables or constants, etc)
- Document what is dangerous (performance-wise, crash-wise)
Bohemia Interactive recommendations:
- use
/ /! and / /!< /*! * /, / / / and /** * / are to be avoided (inline comment is preferred in order to remain able to comment big chunks of code with /* * / without conflict)
- do not go too much into details (e.g
/ /! This method does xxx if provided Y but will not do it if Z is set to true at line 246 and ...) - do not over-document code (e.g
/ /! Get the name on string GetName() is of absolutely no value); again, code should be self-explanatory and a comment should explain a design decision (if needed)
See Examples below.
Class
A class documentation explains what the class does. It can add said class to groups (see Doxygen's grouping documentation). Grouping is usually done in a different comment block than class comment.
Method
A method documentation goes below the
Various parameter formats:
Only one return format:
To be used when a void signature is not used.
Variable
Examples
Do
This example is taken from SCR_ObstacleDetector:
This comment is fine for multiple reasons:
- the main description states the method's goal and usage condition
- parameters are documented and specifics (when present) are explained
- the return value is described accurately
- error cases are covered
Don't
Example | Explanation |
---|---|
| |
//------------------------------------------------------------------------------------------------
//! Returns true if has obstacle
//! \param[in] worldPos the world position
//! \param[in] exclusionList the exclusion list
//! \return true or false
bool HasObstacle(vector worldPos, array<IEntity> exclusionList = null) |
|
This one is one of the worst possible cases: no comment is better than a wrong comment. |
See Also
- https://www.doxygen.nl/ - the official Doxygen website
- https://www.doxygen.nl/manual/ - the official documentation
- https://www.doxygen.nl/manual/commands.html - \commands list