Comment Standards¶
This document defines the standards for writing code comments in the Qwt project, ensuring consistency and completeness between documentation and code.
Language Requirements¶
Important: English Only
Qwt is an international project. All comments in source code (including Doxygen documentation comments) must be written in English; Chinese is not permitted.
Chinese documentation is only allowed in the docs/ directory.
Key Requirements¶
Features
- ✅ Doxygen Format: Use Doxygen standard format for comments
- ✅ English-Only Comments: All comments must be written in English
- ✅ Placement Rules: Detailed comments go in cpp files; brief comments go in header files
- ✅ Completeness: Classes, functions, and signals all require complete documentation comments
Doxygen Keyword Standards¶
Doxygen keywords must use the @ prefix (e.g., @brief, @param, @return, @details):
1 2 3 4 5 | |
Comment Placement Principles¶
Core Principles
- Detailed comments go in
.cppfiles - Brief comments go in
.hfiles - Keep header files clean and avoid excessive comment content
Source File Comment Standards¶
All new code must use the Doxygen English format for comments.
Function Comment Template¶
1 2 3 4 5 6 7 8 9 10 | |
Parameter Descriptions¶
Parameter direction annotations are recommended but not mandatory. For value and const ref parameters, the direction is obvious and [in] can be omitted.
However, direction must be annotated in the following cases:
@param[out]— Non-const reference/pointer used for output results@param[in,out]— Non-const reference/pointer that is both read and written
1 2 3 4 5 6 7 8 9 10 | |
Detailed Description Example¶
1 2 3 4 5 6 7 8 9 10 11 12 | |
Header File Comment Standards¶
public function declarations in header files should only have single-line English brief comments.
Brief Comment Example¶
1 2 3 4 5 6 7 8 9 10 11 | |
Note
Do not write detailed Doxygen comment blocks in header files. Detailed content should be placed in the corresponding .cpp file.
Class Comment Standards¶
Class Doxygen comments should be added in header files.
Class Comment Template¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Class Comments with Examples¶
For classes with rich functionality, usage examples should be included:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Signal Comment Standards¶
Qt signals are declared in header files and have no corresponding cpp definition, so signal comments must be fully added in the header file.
Signal Comment Example¶
1 2 3 4 5 6 7 8 9 | |
Comment Style Checklist¶
When writing comments, please verify the following items:
| Check Item | Location | Requirement |
|---|---|---|
| Class comments | Header file .h |
English Doxygen, including usage examples |
| Public function detailed comments | Source file .cpp |
English Doxygen |
| Public function brief comments | Header file .h |
Single-line English |
| Signal comments | Header file .h |
English Doxygen |
| Private/protected functions | Source file .cpp |
Optional, English recommended |
| Inline comments | Anywhere | English |
Common Mistakes¶
❌ Wrong: Detailed Comments in Header Files¶
1 2 3 4 5 6 7 8 9 10 | |
❌ Wrong: Chinese Comments in Source Code¶
1 2 3 4 5 6 | |
✅ Correct: Brief Header Comments + Detailed cpp Comments¶
Header file MyClass.h:
1 2 3 4 5 | |
Source file MyClass.cpp:
1 2 3 4 5 6 7 8 9 10 | |