Files
rt-thread/documentation/0.doxygen/example/src/function.c
T
Chen Wang 3c8b23576f
AutoTestCI / components/cpp11 (push) Waiting to run
AutoTestCI / kernel/atomic (push) Waiting to run
AutoTestCI / kernel/atomic/riscv64 (push) Waiting to run
AutoTestCI / kernel/atomic_c11 (push) Waiting to run
AutoTestCI / kernel/atomic_c11/riscv64 (push) Waiting to run
AutoTestCI / kernel/device (push) Waiting to run
AutoTestCI / kernel/ipc (push) Waiting to run
AutoTestCI / kernel/irq (push) Waiting to run
AutoTestCI / kernel/mem (push) Waiting to run
AutoTestCI / kernel/mem/riscv64 (push) Waiting to run
AutoTestCI / kernel/thread (push) Waiting to run
AutoTestCI / kernel/timer (push) Waiting to run
AutoTestCI / rtsmart/aarch64 (push) Waiting to run
AutoTestCI / rtsmart/arm (push) Waiting to run
AutoTestCI / rtsmart/riscv64 (push) Waiting to run
AutoTestCI / components/utest (push) Waiting to run
RT-Thread BSP Static Build Check / ESP32C3 (push) Waiting to run
RT-Thread BSP Static Build Check / Infineon_TI_microchip (push) Waiting to run
RT-Thread BSP Static Build Check / RT-Thread Online Packages (STM32F407 RT-Spark) (push) Waiting to run
RT-Thread BSP Static Build Check / RTduino/Arduino Libraries (Raspberry Pico) (push) Waiting to run
RT-Thread BSP Static Build Check / RTduino/Arduino Libraries (STM32F412 Nucleo) (push) Waiting to run
RT-Thread BSP Static Build Check / aarch64 (push) Waiting to run
RT-Thread BSP Static Build Check / gd32_n32_apm32 (push) Waiting to run
RT-Thread BSP Static Build Check / hpmicro (push) Waiting to run
RT-Thread BSP Static Build Check / i386-unknown (push) Waiting to run
RT-Thread BSP Static Build Check / llvm-arm (push) Waiting to run
RT-Thread BSP Static Build Check / mips (push) Waiting to run
RT-Thread BSP Static Build Check / nordic(yml) (push) Waiting to run
RT-Thread BSP Static Build Check / nuvoton (push) Waiting to run
RT-Thread BSP Static Build Check / nxp_renesas (push) Waiting to run
RT-Thread BSP Static Build Check / others_at32_hc32_ht32 (push) Waiting to run
RT-Thread BSP Static Build Check / riscv-none (push) Waiting to run
RT-Thread BSP Static Build Check / riscv64-unknown (push) Waiting to run
RT-Thread BSP Static Build Check / simulator (push) Waiting to run
RT-Thread BSP Static Build Check / stm32_f2_f4 (push) Waiting to run
RT-Thread BSP Static Build Check / stm32_f7_g0_h7_mp15_u5_h5_wb5 (push) Waiting to run
RT-Thread BSP Static Build Check / stm32f0_f1 (push) Waiting to run
RT-Thread BSP Static Build Check / stm32l4 (push) Waiting to run
BSP compilation with more drivers / BSP Compilation with More Drivers (push) Waiting to run
pkgs_test / change (push) Has been skipped
doc_doxygen / doxygen_doc generate (push) Has been cancelled
doc_doxygen / deploy (push) Has been cancelled
doxygen: group examples in subpages
Doxygen examples are grouped on different pages so that you can
easily link to pages of related types in the documentation.
For example, macro examples have their own page, and function
examples have their own page, which correspond to their own code
examples, such as "macro.h" or "function.h".

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
2025-03-06 11:46:21 +08:00

106 lines
3.8 KiB
C

/**
* @page page_howto_function How to write doxygen documentation for function.
*
* Function comments can be placed in the header file (before the
* function declaration) OR in the source file (before the function
* definition).
*
* The advantage of placing it in the header file is that we generally
* think that the header file is the place to declare the API, but the
* problem is that when a module has many API extern functions, if the
* comments are placed in the header file, the header file will be very
* long. You can imagine that for a module with many APIs and many
* comments, the header file will be full of large green comments, and
* the function declaration part is mixed in the middle and difficult
* to distinguish. And if you want to fully understand which extern
* functions this module exports, you need to scroll a long file for a
* long time to get a general idea. Especially for RTT, see `include/rtthread.h`
* as an example.
*
* Putting the comment in the source file can avoid the above problems.
* For developers, it is also convenient to read the comments together with
* the code implementation. The disadvantage is that it would be different
* from the function side, from other types, such as structures, i.e. the API
* comments of functions need to be read in the source file instead of directly
* in the header file.
*
* Comprehensive consideration can be combined with the actual situation.
* For example, if there are too many API functions in a header file, it is
* recommended to put the function comments in the source file.
*
* So, it is **strongly recommended** to put comments in the source file when
* writing new functions or annotating functions.
*
* To documenting for functions, a comment block before the function
* declaraion/definition is recommended to describe the general information
* of the function. In the comment block, a `@brief` is required, a `@return`
* is also required no matter if the function return values or not. `@param` is
* required if any, and if it is provided, direction [in]/[out]/[in,out] should
* be provide together. Other commands (such as `@note`) are optional.
*
* If you feel that the description of `@brief` is not enough, you
* can add a detailed description part, which is also optional.
*
* See
* <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/src/function.c">documentation/0.doxygen/example/src/function.c</a>
* for code example.
*
* See
* <a href="./group__group__doxygen__example__function.html">Doxygen Example of Function</a>
* for html output.
*
* @note <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/src/function.h">documentation/0.doxygen/example/src/function.h</a>
* is just an example of the header file where we declare the API without
* doxygen documentation.
*/
/**
* @defgroup group_doxygen_example_function Doxygen Example of Function
*
* @ingroup group_doxygen_example
*
* @brief Doxygen Example of Function.
*
* @{
*/
/**
* @brief Brief description for the function
*
* Detailed description starts here, one line or multiple lines.
* Blah blah blah...
*
* @param[in] a Description of param a
*
* @param[in] b Description of param b
*
* @return void
*
* @note This is a note for this structure, blah blah blah...
*/
void doxygen_example_func_foo(int a, int b)
{
return;
}
/**
* @brief Brief description for the function
*
* Detailed description starts here, one line or multiple lines.
* Blah blah blah...
*
* @param[in] a Description of param a
*
* @param[out] b Description of param b
*
* @return the return value, 0 for success, -1 for failure
*
* @note This is a note for this structure, blah blah blah...
*/
int doxygen_example_func_bar(int a, int* b)
{
return 0;
}
/** @} */