Skip to content

Commit 1f3e43e

Browse files
add Commenting Style section
1 parent 6089da1 commit 1f3e43e

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

doc/src/dev/coding_style.rst

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Examples where `auto` is appropriate:
1515
1616
// Lambdas have unreadable and compiler-generated types — use auto for them
1717
auto add = [](int x, int y) { return x + y; };
18-
18+
1919
2020
Avoid `auto` when the type is simple and clear:
2121

@@ -44,3 +44,53 @@ Avoid:
4444
}
4545
4646
Rationale: clear, explicit types help with readability and understanding. Avoid hiding simple types behind `auto`.
47+
48+
49+
Commenting Style
50+
================
51+
Comment types and rules:
52+
53+
- Use `/* ... */` **only** for Doxygen documentation comments.
54+
Do **not** use block comments (`/* */`) to describe code logic or individual lines in function bodies.
55+
56+
- Use `//` for all regular comments within function bodies or implementation code.
57+
58+
Formatting rules for `//` comments:
59+
60+
- Always include a space between `//` and the comment text.
61+
- Use full sentences when appropriate.
62+
- For multi-line comments, prefix each line with `// `.
63+
64+
Examples (correct usage):
65+
66+
.. code-block:: cpp
67+
68+
// Check if the node has already been visited
69+
if (visited[node_id]) {
70+
return;
71+
}
72+
73+
// Enable debug output for route estimation
74+
bool debug_enabled = true;
75+
76+
/**
77+
* @brief Estimates the wirelength of a net using bounding box.
78+
*
79+
* @param net_id ID of the net to analyze.
80+
* @return Estimated wirelength in units.
81+
*/
82+
float estimate_wirelength(ClusterNetId net_id);
83+
84+
Incorrect usage:
85+
86+
.. code-block:: cpp
87+
88+
/* Check if visited */ // Block comments are not allowed here
89+
if (visited[node_id]) {
90+
return;
91+
}
92+
93+
//Missing space
94+
//inconsistent formatting
95+
96+
/* Non-Doxygen block comment */ // Not permitted

0 commit comments

Comments
 (0)