Skip to content

Instantly share code, notes, and snippets.

@fdmysterious
Last active December 12, 2023 16:54
Show Gist options
  • Save fdmysterious/f0e9a4deb995b2267085bd8e9348d39f to your computer and use it in GitHub Desktop.
Save fdmysterious/f0e9a4deb995b2267085bd8e9348d39f to your computer and use it in GitHub Desktop.
Doxygen header/source template

Header file

/**
 * @author Name <[email protected]>
 * @date July 2023
 * @brief Blahblah
 */

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \defgroup group-name Group Display Name
 * \ingroup parent-group
 * @{
 */

/* ------------------- Includes */



/** @} */ // group-name

#ifdef __cplusplus
} // extern C
#endif

Source file

/**
 * @author Name <[email protected]>
 * @date July 2023
 * @brief Blahblah
 */

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \addtogroup group-name
 * @{
 */



/** @} */ // group-name

#ifdef __cplusplus
} // extern C
#endif

Overall group define

An index.dox file can be used at the root of a module folder to define the overall doxygen group:

/* This file is intended for doxygen */
/*!
 * \defgroup sub-group Sub group name
 * @{
 * \ingroup Root-group
 * @}
*/

This sub-group can be then referenced in the \addtogroup call in the header template file.

VSCode snippet file

{
	"Header template": {
		"prefix": "templateHeader",
		"scope": "c,cpp",
		"body": [
			"/**",
			" * @author ${1:Name} <${2:[email protected]}>",
			" * @date $CURRENT_MONTH_NAME $CURRENT_YEAR",
			" * @brief ${3:Blahblah}",
			" */",
			"",
			"#pragma once",
			"",
			"#ifdef __cplusplus",
			"extern \"C\" {",
			"#endif",
			"",
			"/**",
			" * \\defgroup ${5:group-name} ${6:Group Display Name}",
			" * \\ingroup ${7:parent-group}",
			" * @{",
			" */",
			"",
			"/* ------------------- Includes */",
			"",
			"$0",
			"",
			"/** @} */ // $5",
			"",
			"#ifdef __cplusplus",
			"} // extern C",
			"#endif",
		]
	},

	"Source template": {
		"prefix": "templateSource",
		"scope": "c,cpp",
		"body": [
			"/**",
			" * @author ${1:Name} <${2:[email protected]}>",
			" * @date $CURRENT_MONTH_NAME $CURRENT_YEAR",
			" * @brief ${4:Blahblah}",
			" */",
			"",
			"#ifdef __cplusplus",
			"extern \"C\" {",
			"#endif",
			"",
			"/**",
			" * \\addtogroup ${5:group-name}",
			" * @{",
			" */",
			"",
			"$0",
			"",
			"/** @} */ // $5",
			"",
			"#ifdef __cplusplus",
			"} // extern C",
			"#endif",
		]
	},

	"Test template": {
		"prefix": "templateTest",
		"scope": "c,cpp",
		"body": [
			"/**",
			" * @author ${1:Name} <${2:[email protected]}>",
			" * @date $CURRENT_MONTH_NAME $CURRENT_YEAR",
			" * @brief ${4:Blahblah}",
			" */",
			"",
			"/**",
			" * \\defgroup ${5:group-name} ${6:Group name}",
			" * \\addtogroup ${7:parent-group}",
			" * @{",
			" */",
			"",
			"/* ------------------- Includes */",
			"",
			"#include <string>",
			"#include <iostream>",
			"#include <gtest/gtest.h>",
			"",
			"$0",
			"",
			"/** @} */ // $5"
		]
	},

	"Section": {
		"prefix": "section",

		"body": [
			"/* ------------------- ${1:Name} */",
			"",
			"$0"
		]
	},

	"Doxygen comment": {
		"prefix": "dlc",
		"body": "/** ${1} */$0"
	},

	"Long Doxygen comment": {
		"prefix": "dllc",
		"body": "/** $0 */"
	},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment