Comment Standards¶
Qwt source comments follow the rules below for language, placement and completeness.
Language Requirements¶
Warning — 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¶
Comments use Doxygen format and English only. Detailed comments go in cpp files and brief comments in header files. Classes, functions and signals all need a complete documentation comment.
Doxygen Keyword Standards¶
Doxygen keywords must use the @ prefix (e.g., @brief, @param, @return, @details):
1 2 3 4 5 | |
Comment Placement Principles¶
Info — 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¶
Public functions in .cpp files follow this Doxygen template, covering @brief, @param, @return and @details:
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¶
The snippet below shows a complete comment for QwtPlotCurve::setSamples, where @details documents that the data is copied internally:
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¶
In header files, each public function declaration gets only a single-line English comment, as in this example:
1 2 3 4 5 6 7 8 9 10 11 | |
Warning — Note
Do not write detailed Doxygen comment blocks in header files. Detailed content should be placed in the corresponding
.cppfile.
Class Comment Standards¶
Class Doxygen comments should be added in header files.
Class Comment Template¶
The template below documents QwtPlot together with its QWT_DECLARE_PRIVATE declaration:
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¶
Since signals have no cpp definition, their full Doxygen comments are written in the header file. The example below documents a signal inside the Q_SIGNALS block:
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¶
The following example violates the placement rule by putting a detailed Doxygen block on a constructor declaration in the header file:
1 2 3 4 5 6 7 8 9 10 | |
Wrong: Chinese Comments in Source Code¶
The next example violates the English-only rule by leaving a Chinese inline comment in the source file:
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 | |