Skip to content

Commit de89939

Browse files
authored
docs: Doxygen usage & guidelines (#7)
* Doxygen: started the guidelines I started writing the guidelines for the Doxygen section. Focusing on where to use them, how to write them, core structure and grammar, and giving example templates for comments to be used in File header and above each method. To-do: clean up * Improved grammar + small addition I improved the grammar for my section. Also added another 1-2 rules in the "Writing style guidelines". Added more tables with the good and bad examples. * Improved comment examples The examples in the Doxygen comment guidelines have been updated and improved. I placed a link to the official C# XML example page. * Fixing linting issues These are the following changes made to suit the Linter's standards: - Replaced tab-indents with spacebar-indents. - Removed trailing whitespaces - Table: kept a line free/empty above and below each table. - Added arrow tags <>, to every bare URL used. * More smaller linting fixes This SHOULD be the remaining fixes for the linting issues. I was using 2 spaces for indentation (because md007 tells us to use 2 in the example_) but am now using 4 spaces.
1 parent d0d2a68 commit de89939

1 file changed

Lines changed: 134 additions & 0 deletions

File tree

docs/style/comments.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,140 @@ Example:
4141
| **DEPRECATED** | as-of-date(dd/mm/yyyy) | Mark an API or function as deprecated. | `// DEPRECATED(19/06/2025): Replaced this function with Foo()` |
4242
| **WTF** | - | Identify confusing or unexpected behavior requiring investigation. *(Use sparingly.)* | `// WTF: Behavior differs between debug and release builds` |
4343

44+
---
45+
46+
## Doxygen Guidelines
47+
48+
### 📍 Where to use?
49+
50+
- At the **header** of every file, explaining:
51+
- Filename
52+
- Brief description of file's purpose and contents.
53+
- Author(s)
54+
- Date of Creation
55+
- **Above** every **Method**, describing:
56+
- The purpose briefly, in one line
57+
- The method in more detail. (What algorithms were used, unique decisions made.)
58+
- The parameter(s) and result.
59+
- **Class/Struct** documenation:
60+
- Brief class description
61+
- Detailed usage information.
62+
- Template parameters.
63+
- Important Member relationships
64+
65+
### :writing_hand: Writing Style guidelines
66+
67+
**Grammar & Tone:**
68+
69+
- Present tense
70+
71+
| | |
72+
|--|--|
73+
| ❌ Bad | `The function will sort the array.`|
74+
| ✅ Good| `Sorts the array using quicksort.`|
75+
76+
- Active voice: *Subject + Verb + Object*
77+
78+
| | |
79+
|--|--|
80+
| ❌ Bad | `The integer is modified by the method.`|
81+
| ✅ Good| `The function modifies the integer.`|
82+
83+
- Write in Third Person instead of First Person:
84+
85+
| | |
86+
|--|--|
87+
| ❌ No usage of: <em>I, me, we</em>. | `# I calculate the average here.` <br> `# We initialize the module`|
88+
| ✅ Use Third person| `Calculates the average of the values.`<br>`Initializes the communication module.`|
89+
90+
- Be direct and concise,
91+
92+
- Start summaries with a verb:
93+
94+
| | |
95+
|--|--|
96+
| ❌ Bad | `This function is responsible for performing the task of data validation.` |
97+
| ✅ Good| `Validates input data format.`|
98+
99+
### TEMPLATES
100+
101+
**File headers [C++ only]:**
102+
103+
/**
104+
* @file filename.cpp
105+
* @brief Brief description of file purpose
106+
* @author John Doe (optional)
107+
* @date 2024-01-15
108+
*
109+
* Detailed description of file contents, context, and usage...
110+
* Can span multiple lines...
111+
*
112+
* @NOTE: ... Important notes about this file
113+
* @WARNING: ... Any warnings for developers
114+
*/
115+
116+
**Method Documentation:**
117+
118+
- C++:
119+
120+
/**
121+
* @brief One-line description of function purpose
122+
*
123+
* Detailed description including algorithm, edge cases,
124+
* performance characteristics, etc.
125+
*
126+
* @param param1 Description of first parameter
127+
* @param param2 Description of second parameter
128+
* @return Description of return value
129+
* /
130+
131+
- C#:
132+
133+
/// <summary>
134+
/// Calculates the sum of two integers.
135+
/// </summary>
136+
/// <param name="left">The first integer operand.</param>
137+
/// <param name="right">The second integer operand.</param>
138+
/// <returns>The sum of the two integers.</returns>
139+
public static int Add(int left, int right)
140+
{
141+
return left + right;
142+
}
143+
144+
**Class Documentation:**
145+
146+
- C++
147+
148+
/**
149+
* @class ClassName
150+
* @brief Brief description of class purpose
151+
*
152+
* Detailed explanation of class responsibilities, usage patterns,
153+
* and important design decisions.
154+
*
155+
* @param Description of template parameter requirements
156+
*/
157+
public class ClassName<T>
158+
{
159+
// Class implementation
160+
}
161+
162+
- C#:
163+
164+
/// <summary>
165+
/// A summary about this class.
166+
/// </summary>
167+
/// <remarks>
168+
/// These remarks would explain more about this class.
169+
/// In this example, these comments also explain the
170+
/// general information about the derived class.
171+
/// </remarks>
172+
public class MainClass
173+
{
174+
}
175+
176+
- For more examples, look here: <https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/examples>
177+
44178
---
45179

46180
## Discouraged Comment Styles

0 commit comments

Comments
 (0)