簡體   English   中英

在 Doxygen 中記錄命令

[英]Documenting command in Doxygen

我在 C++ 中創建了一個簡單的庫,並且在 Doxygen 中以相當好的紀律記錄了 API。 在 package 中有幾個示例程序可以使用該庫。在同一個 Doxygen 進程中記錄這些(作為命令行程序)是否有技巧?

我決定在我的評論中添加更多詳細信息的答案。

正如我在評論中提到的,我通常使用 Doxygen 的“MainPage”功能。

對於我的公共存儲庫,我使用 README.md 頁面並按如下方式配置 Doxygen:

OUTPUT_DIRECTORY       = docs/
EXTRACT_ALL            = YES
EXTRACT_PRIVATE        = YES
EXTRACT_PRIV_VIRTUAL   = YES
EXTRACT_PACKAGE        = YES
EXTRACT_STATIC         = YES
EXTRACT_LOCAL_CLASSES  = YES

INPUT                  = README.md <any other files or directories>
USE_MDFILE_AS_MAINPAGE = README.md

然后這會生成 Doxygen HTML 文件,例如可以在此處看到(請原諒無恥的插件)

它有助於提供您的庫、用例的總體概述,尤其是在您提到的案例、應用程序 arguments、開關等中。


編輯 2023-01-10:

正如這個答案下的評論中提到的,這當然不是實現 OP 目標的唯一方法。 如果要記錄單獨的文件(即可執行文件),可以很容易地將它們添加到 Doxyfile 中:

# individual files
INPUT = lib/include/myheader.hpp lib/src/myimpl.cpp examples/dosomethingcool.cpp

# Directories
INPUT = lib/include/ lib/src/ examples/
FILE_PATTERNS = *.cpp *.hpp

在您的示例實現中,您可以添加一個簡單的 JavaDoc 樣式 header:

/**
 * @file myimpl.cpp
 * @author Your Name <you@you.net>
 * @date 2023-01-01
 *
 * @brief Contains an example of implementing/using my awesome library.
 *
 * Enter a detailed description of your reference implementation here.
 * You may also include Markdown, so you can create simple tables,
 * or format your text in a way that you like.
 *
 * Alternatively, you could also add an example using code.
 * @code{.sh}
 * # call my implementation like this:
 * ./myimpl -LgTz100
 * @endcode
 *
 * # A complete list of arguments:
 * | Long opt | short opt | Description     |
 * |----------|-----------|-----------------|
 * | -foo     | -f        | Foos something  |
 * | -bar     | -B        | Bars the baz    |
 */

#include <iostream>

/**
 * @brief Program entry point.
 * You can continue with normal documentation here.
 *
 * @param argc The total amount of args passed
 * @param argv The string arguments passed to the application
 */
int main(int32_t argc, char** argv) {
    // implement whatever here
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM