Loading...
Loading...
Adds Doxygen-compatible documentation comments to C++ header files. Use this skill exclusively for adding or improving API documentation in existing header files (*.hpp, *.h). Do NOT create new resource files such as Doxyfile, scripts, or README files.
npx skill4agent add sentenz/skills cpp-api-documentation[!NOTE] This skill is for documenting header files only. Do NOT create new resource files (e.g., Doxyfile, scripts, README).
Well-documented APIs enable developers to quickly understand and use components without reading implementation details.
Documentation embedded in source code stays synchronized with implementation, reducing drift between code and documentation.
Documentation comments serve as living specifications, keeping API contracts synchronized with implementation.
Document all public APIs including classes, functions, parameters, return values, and exceptions. Private implementation details may be omitted.
Documentation provides context about usage patterns, performance characteristics, and thread safety guarantees.
Use a uniform style, format, terminology and structure throughout the API documentation using the patterns defined in this skill.
Use clear, brief descriptions. Avoid redundant information that restates what is obvious from the signature.
Provide specific details about behavior, edge cases, and error conditions rather than vague statements.
Documentation should be easy to access and navigate, integrated with development tools and workflows.
Documentation must match the actual behavior. Update documentation whenever the implementation changes.
Include usage examples, preconditions, postconditions, and error handling to help developers use the API correctly.
Describes the file's role in the project architecture.
Identifies the original author(s) of the file.
Specifies the licensing terms (typically SPDX identifier).
A one-line summary of what the namespace contains.
Extended description of the namespace's role and contents.
A one-line summary of what the class represents.
Extended description of responsibilities, invariants, and usage patterns.
For template classes, document each template parameter's purpose and constraints.
A one-line summary of what the function does.
Document each parameter withincluding direction (@param,[in],[out]).[in,out]
Document the return value withor@returnfor specific values.@retval
Document thrown exceptions withor@throws.@exception
Usefor critical warnings about misuse.@warning
Usefor important information.@note
Document preconditions with.@pre
Document postconditions with.@post
Useand@codeblocks for usage examples.@endcode
Useto reference related functions, classes, or external resources.@see
Usefor trailing inline documentation.///< description
Usefor preceding documentation./// description
Document each enumerator with a brief Inline Comments description.
Useto create named documentation modules.@defgroup
Useto add elements to existing groups.@ingroup
Usefor explicit class membership.@memberof
Document inherited classes withor@copydocto reuse base class documentation.@copybrief
Usefor formulas that appear within running text (opens LaTeX math mode).\f$..\f$
Usefor LaTeX elements that don't require explicit math mode (e.g., logos like\f(...\f)).\LaTeX
Usefor centered, unnumbered equations on separate lines.\f[...\f]
Usefor specific LaTeX environments (e.g.,\f{environment}{...\f},eqnarray*).align
Enablein Doxyfile for client-side formula rendering without requiring LaTeX installation.USE_MATHJAX
Useconfiguration to define reusable LaTeX commands withFORMULA_MACROFILE.\newcommand
[!IMPORTANT] Do NOT create Doxyfile, scripts, or other resource files. Only modify header files.
src/<module>/<header>.hppWrite documentation in clear, concise English. Use present tense for descriptions ("Returns the sum" not "Will return the sum").
Keep documentation lines under 100 characters for readability.
Usefor multi-line documentation blocks. Each line within the block should start with/** ... */.*
Preferfor single-line documentation and///for multi-line documentation blocks. Use Javadoc-style commands (/** */,@param) rather than Qt-style (@return,\param).\return
Usefor explicit brief descriptions.@brief
Add detailed descriptions after the brief, separated by a blank line or using.@details
Always specify parameter direction using,[in], or[out]for clarity.[in,out]
Useand@codeblocks for usage examples within documentation.@endcode
Useto reference related functions, classes, or external resources.@see
Usefor important information and@notefor critical warnings.@warning
Mark deprecated APIs withincluding migration guidance.@deprecated
Usefor planned improvements visible in generated documentation.@todo
Follow this order for function documentation:
@brief (if needed)@details (for templates)@tparam@param@return@throws@pre@post@note@warning@see@deprecated
[!NOTE] Place theblock after the include guard (@fileor#pragma once/#ifndef). This ensures the documentation is parsed once along with the declarations it describes and keeps preprocessor directives separate from API documentation.#define
#pragma once
/**
* @file <filename>.hpp
* @brief One-line description of the file's purpose.
*
* Detailed description of the file's contents and design decisions.
*
* @author <author_name>
* @copyright Copyright (c) <year> <organization>
* @license SPDX-License-Identifier: <license_identifier>
*//**
* @brief One-line description of namespace contents.
*
* Detailed description of the namespace's role, the types of
* components it contains, and how they relate to each other.
*/
namespace namespace_name {
// Namespace contents
} // namespace namespace_name/**
* @brief One-line description of the class.
*
* Detailed description of the class responsibility, key invariants,
* and usage patterns.
*
* @tparam T Description of template parameter and constraints.
*
* @note Thread safety: Describe thread safety guarantees.
*
* @see RelatedClass
*
* @code
* ClassName<int> obj;
* obj.method(param);
* @endcode
*/
template <typename T>
class ClassName
{
// ...
};/**
* @brief One-line description of what the function does.
*
* Detailed description including algorithm details and edge cases.
*
* @param[in] param1 Description of the input parameter.
* @param[out] param2 Description of the output parameter.
* @param[in,out] param3 Description of bidirectional parameter.
*
* @return Description of the return value.
* @retval specific_value Meaning of this specific return value.
*
* @throws std::invalid_argument If param1 is invalid.
* @throws std::runtime_error If operation fails.
*
* @pre Preconditions that must be met before calling.
* @post Postconditions guaranteed after successful execution.
*
* @note Important information for users.
* @warning Critical warnings about potential misuse.
*
* @see relatedFunction()
*
* @code
* auto result = functionName(input, output);
* @endcode
*/
ReturnType functionName(const InputType& param1, OutputType& param2);class ClassName
{
private:
int count_; ///< Number of items currently stored.
bool is_valid_; ///< Whether the object is in a valid state.
/// Description for simple members.
int simple_member_;
/**
* @brief Buffer for temporary storage.
*
* Detailed explanation of the member's purpose and
* synchronization requirements.
*/
std::vector<char> buffer_;
};/**
* @brief Description of what this enumeration represents.
*
* Detailed description of the enum's purpose and usage context.
*/
enum class EnumName
{
Success, ///< Operation completed successfully.
Error, ///< Operation failed with an error.
Pending, ///< Operation is still in progress.
NotFound ///< Requested item was not found.
};/**
* @defgroup module_name Module Display Name
* @brief One-line description of the module.
*
* Detailed description of the module purpose and components.
*
* @{
*/
// Classes and functions belonging to this group
/** @} */ // End of module_name/**
* @brief Calculates the Euclidean distance between two points.
*
* The distance between \f$(x_1,y_1)\f$ and \f$(x_2,y_2)\f$ is
* \f$\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\f$.
*
* For complex equations, use displayed formulas:
* \f[
* d = \sqrt{\sum_{i=1}^{n}(p_i - q_i)^2}
* \f]
*
* Multi-line equations using eqnarray environment:
* \f{eqnarray*}{
* E &=& mc^2 \\
* F &=& ma
* \f}
*
* @param[in] x1 X-coordinate of the first point.
* @param[in] y1 Y-coordinate of the first point.
* @param[in] x2 X-coordinate of the second point.
* @param[in] y2 Y-coordinate of the second point.
*
* @return The Euclidean distance \f$d \geq 0\f$.
*/
double distance(double x1, double y1, double x2, double y2);