生成非常少的 Doxygen 文档

问题描述 投票:0回答:1

我第一次尝试在一个简单的 C 项目中生成 Doxygen 文档。不幸的是,我只取得了有限的成功。我尝试阅读 Doxygen 提供的文档 (https://www.doxygen.nl/manual/starting.html) 开始使用。不过我不是很清楚。

我可以从我的小型 C 项目中生成一些 Doxygen 文档。我生成的 Doxygen 文档仅限于我在

Michaels_Criterion_tests.c
中创建的名为
structOfSignals
的结构。对于
structOfSignals
,我在“类列表/类索引”中看到了我的简短声明,并且没有参数或返回(我基本上是从我的函数文档中复制的)。

对于我的头文件中的所有其他文档或 .c 文件中的函数,我没有看到我的简短注释(尽管 Doxygen 明确承认我的头文件,因为它已将它们放在“文件列表”下)。

我相信我的问题源于三种可能性之一:

  1. 我的
    Doxyfile
    中的一个或多个配置选项不正确。
  2. 我的
    CmakeLists.txt
    不正确(很有可能)。
  3. 1. 和 2.

我保留了

Doxyfile
大部分默认值。少数例外是:

  • 将字符串值分配给
    PROJECT_NAME
    PROJECT_NUMBER
    PROJECT_BRIEF
  • 我分配了
    OUTPUT_DIRECTORY = "output"
    (正在我的
    output
    目录中创建输出文件)。
  • JAVADOC_BANNER
    NO
    更改为
    YES
    。我知道如果我不更改此值,这将是我的评论风格的问题。

以下是我的几个文件的内容:

Doxyfile
文件太大,无法发布,但希望上面的更改列表可以清楚地表明它主要是默认值。我正在使用 Doxygen 1.9.1 版本。

CmakeLists.txt: 注意:我注释掉了

Michaels_Criterion_tests
fibonacci
的 c 和头文件,因为那是我在单元测试时唯一关心的代码。未来的目标是有一个条件语句,它将根据我是否尝试进行单元测试来切换以包含或排除这些文件。但现在,我只想让事情能够处理较小的文件。

#Minimum version of CMake required
cmake_minimum_required(VERSION 3.20)
project(mainProject) #name this to whatever you'd like 

# Set C standard
set(CMAKE_C_STANDARD 11)

# Locate Doxygen
find_package(Doxygen REQUIRED)

# Locate Criterion
#find_package(criterion REQUIRED)

# Set input directory
set(DOXYGEN_INPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
#set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/docs)

# Set source and header files
set(SOURCES
    ${DOXYGEN_INPUT_DIR}/main.c
    ${DOXYGEN_INPUT_DIR}/timer.c
    #${DOXYGEN_INPUT_DIR}/Michaels_Criterion_tests.c
    ${DOXYGEN_INPUT_DIR}/signalHandler.c
    #${DOXYGEN_INPUT_DIR}/fibonacci.c
)

set(HEADERS
    ${DOXYGEN_INPUT_DIR}/timer.h
    #${DOXYGEN_INPUT_DIR}/Michaels_Criterion_tests.h
    ${DOXYGEN_INPUT_DIR}/signalHandler.h
    #${DOXYGEN_INPUT_DIR}/fibonacci.h
)

# Configure Doxygen
set(DOXYGEN_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/output/Doxyfile)
configure_file(${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${DOXYGEN_CONFIG} @ONLY)

# Add executable target
add_executable(mainProject ${SOURCES} ${HEADERS})

# Link with Criterion
#target_link_libraries(mainProject criterion)

# Add a target to generate API documentation with Doxygen
add_custom_target(
    doc ALL DEPENDS mainProject
    COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_CONFIG}
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    COMMENT "Generating API documentation with Doxygen"
    VERBATIM
)

main.c

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>               //for clock() and CLOCKS_PER_SEC
#include "signalHandler.h"
#include "timer.h"

//@file main.c


int main(int argc, char *argv[]) {
    int raiseResult;
    void (*prev_handler)(int);
    sig_atomic_t signaled = 0;      //Debug testing only. Remove later.

    printf("Hello, World!\n");

    //Register the signal handler
    prev_handler = signal(TEST_SIGNAL_51, sigHandler);

    //call the timey function
    raiseResult = timey(1, TEST_SIGNAL_51);

    //debug
    printf("raiseResult =%d.\n",raiseResult );

    return 0;

}

sigHandler.c

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include "signalHandler.h"

//sig_atomic_t signaled = 0;      //Debug testing only. Remove later.

/************************************************************************************************************
The function is a signal handler.
Parameters:
    int sig - The signal's number
Returns:
    N/A
************************************************************************************************************/
void sigHandler(int sig)
{
    //signaled = 1;

    //Switch statement to handle all signals
    switch(sig) {
        case TEST_SIGNAL_50:
            printf("Case 50 has been matched.\n");
            //LOG AND DO STUFF...
            break;
        case TEST_SIGNAL_51:
            printf("Case 51 has been matched.\n");
            //LOG AND DO STUFF...
            break;
        case TEST_SIGNAL_52:
            printf("Case 52 has been matched.\n");
            //LOG AND DO STUFF...
            break;
        case SIGINT:
            printf("SIGINT Case has been matched.\n");
            //LOG AND DO STUFF...
            break;
        default:    //Raised signal is not a match
            printf("Raised signal %d is not a match.\n", sig);
            //Probably just log an error and hope we can ignore without blowing up??
            break;
    }
}

sigHandler.h

#ifndef SIGNAL_HANDLER_H
#define SIGNAL_HANDLER_H

#define TEST_SIGNAL_50 50       //PLACEHOLDER
#define TEST_SIGNAL_51 51       //PLACEHOLDER
#define TEST_SIGNAL_52 52       //PLACEHOLDER


//Function declarations
void sigHandler(int sig);

#endif /* SIGNAL_HANDLER_H */

定时器.c

#include <stdio.h>
#include <stdlib.h>
#include <time.h>               //for clock() and CLOCKS_PER_SEC
#include <signal.h>
#include "timer.h"
#include "signalHandler.h"

//@file timer.c

int timer(int trigger){
    clock_t start = clock(), difference;
    int msec = 0;
    int raiseResult;       //Holds return value of raise(). raise() returns zero if successful and a nonzero value if unsuccessful.

    do{
        //printf("This is a message\n");                    //Debug only                
        difference = clock() - start;                       //The difference between the start of the clock and "now".
        msec = difference * 1000 / CLOCKS_PER_SEC;          //CLOCKS_PER_SEC is defined in time.h. Clock ticks per second (system dependent)
    } while(msec < trigger);

    printf("Time taken %d seconds %d milliseconds\n", msec/1000, msec%1000);

    //raiseResult = raise(SIGINT);
    //raiseResult = raise(SIGUSR1);
    raiseResult = raise(TEST_SIGNAL_51);

    return raiseResult;
}



/***********************************************************************************************************
* This function is a timer which raises the signal after trigger milliseconds have elapsed
* Parameters:
*     @param int trigger - The time, in milliseconds, in which this timer should trigger an alarm.
*     @param int signalToRaise - The signal that will be raised once this timer raises its alarm.
* Returns:
*     @return int - This is the return result of raise(); zero if successful and a nonzero value if unsuccessful.
************************************************************************************************************/
int timey(int trigger, int signalToRaise){
    clock_t start = clock(), difference;
    int msec = 0;
    int raiseResult;       //Holds return value of raise(). raise() returns zero if successful and a nonzero value if unsuccessful.

    do{
        //printf("This is a message\n");                    //Debug only  
        difference = clock() - start;                       //The difference between the start of the clock and "now".
        msec = difference * 1000 / CLOCKS_PER_SEC;          //CLOCKS_PER_SEC is defined in time.h. Clock ticks per second (system dependent)
    } while(msec < trigger);

    printf("Time taken %d seconds %d milliseconds\n", msec/1000, msec%1000);
    printf("About to raise signal %d\n", signalToRaise);

    raiseResult = raise(signalToRaise);

    return raiseResult;
}

定时器.h

#ifndef TIMER_H
#define TIMER_H

//@file CASCTimer.c

//Function declarations
int timer(int trigger);

/***********************************************************************************************************
* @brief This function is a timer which raises the signal after trigger milliseconds have elapsed
* Parameters:
*     @param int trigger - The time, in milliseconds, in which this timer should trigger an alarm.
*     @param int signalToRaise - The signal that will be raised once this timer raises its alarm.
* Returns:
*     @return int - This is the return result of raise(); zero if successful and a nonzero value if unsuccessful.
************************************************************************************************************/
int timey(int trigger, int signalToRaise);

#endif /* TIMER_H */

有人看到我做错了什么吗?

c cmake doxygen
1个回答
0
投票

值得注意的 Doxyfile 配置:

  • OPTIMIZE_OUTPUT_FOR_C
  • “构建相关配置选项”
    部分中以
    EXTRACT开头的配置。如果您将相关选项设置为YES
    ,doxygen 将为头文件和源文件中的每个语句/声明生成文档,即使它们没有文档记录。
© www.soinside.com 2019 - 2024. All rights reserved.