cdoxygendoxywizard

How can I organize files in sections according to an architecture with doxygen?


I am trying document my code using Doxygen. I want the resulting HTML to organize the tree view acording to a SW architecture for simple and fast understanding of the project. I have a project organized like this:

│   project_description.md
├───application
│   │   application.md
│   ├───app1
│   │       app1.c
│   │       app1.h
│   │       app1.md
│   └───app2
│           app2.c
│           app2.h
│           app2.md
└───ecu_abstraction
    │   ecu_abstraction.md
    ├───component1
    │       custom_timer.c
    │       custom_timer.h
    │       custom_timer.md
    └───component2
            custom_component2.c
            custom_component2.h
            custom_component2.md

The issue I am having is that the tree view auto-generated by doxygen is flat. All elements have the same level. Current result is:

Autogenerated doxygen flat tree view

My objective is to have something like this:

Target autogenerated tree view

I have made some attempts with grouping and sections but all of them seems to merge the documentation files. Any idea if this can be implemented with Doxygen?

I know I can achieve a similar result by disabling the autogenerated tree view and using @ref but creating a manual table of contex is not very flexible nor future proof.

Attempts with addtogroup functionality:

This means that if I add all my applications to the application layer all of those are concatenated and one single page is created.

Sample markdown file:

@addtogroup application

# App1

bla bla 

Sample C file addition to a group

/**
 * @addtogroup application
 *  @{
 * @file      app2.c
 *
 * @brief Custom simpe timer implementation that allows for simple tick, reste...
 *  @}
 */

enter image description here


Solution

  • It's a little bit late answer, the OP may have solved the matter who knows. Anyway, the implementation according to the OP's requirement should be like the following steps. Assume that we have the source files as *.h and *.c pair:

    First we would implement a application doc file:

    app_doc.dox

    /**
     * \mainpage X Application Project
     * \author Author Name <author_email@example.com>
     * 
     * Description for X Application Project.
     */
    
    /**
     * \defgroup app Application Layer
     * @{
     * Description for the Application group.
     * @}
     */
    
    /**
     * \defgroup ecu ECU Abstraction Layer
     * @{
     * Description for the ECU Abstraction group.
     * @}
     */
    

    Next we would document all indiviual files. But we create new groups using the defgroup command within the related header files only. Right after creating the groups, we make them subgroups using the ingroup command. This will nest the groups and create a hierarchic documentation within the tree view as a result. Note that we also add the *.c file to their related groups. However this may not be necessary unless you have more documentations that belong the same group in the *.c files.

    app1.h

    /**
     * \defgroup app1 App1
     * \ingroup app
     * 
     * \author Author Name (Optional)
     * \date YYYY.MM.DD (Optional)
     * 
     * @{
     * Description for this specific app1 module (Optional).
     */
    
    #ifndef APP1_H
    #define APP1_H
    
    /**
     * app1Func documentation.
     */
    void app1Func(void);
    
    #endif /* APP1_H */
    /// @}
    

    app1.c

    /**
     * \ingroup app1
     * 
     */
    
    void app1Func(void) {
        
    }
    

    app2.h

    /**
     * \defgroup app2 App2
     * \ingroup app
     * 
     * \author Author Name (Optional)
     * \date YYYY.MM.DD (Optional)
     * 
     * @{
     * Description for this specific app2 module (Optional).
     */
    
    #ifndef APP2_H
    #define APP2_H
    
    /**
     * app2Func documentation.
     */
    void app2Func(void);
    
    #endif /* APP2_H */
    /// @}
    

    app2.c

    /**
     * \ingroup app2
     * 
     */
    
    void app2Func(void) {
        
    }
    

    custom_timer.h

    /**
     * \defgroup custom_timer Custom Timer SWC
     * \ingroup ecu
     * 
     * \author Author Name (Optional)
     * \date YYYY.MM.DD (Optional)
     * 
     * @{
     * Description for this specific custom_timer module (Optional).
     */
    
    #ifndef CUSTOM_TIMER_H
    #define CUSTOM_TIMER_H
    
    /**
     * customTimerFunc documentation.
     */
    void customTimerFunc(void);
    
    #endif /* CUSTOM_TIMER_H */
    /// @}
    

    custom_timer.c

    /**
     * \ingroup custom_timer
     * 
     */
    
    void customTimerFunc(void) {
        
    }
    

    custom_component.h

    /**
     * \defgroup custom_component Custom Component SWC
     * \ingroup ecu
     * 
     * \author Author Name (Optional)
     * \date YYYY.MM.DD (Optional)
     * 
     * @{
     * Description for this specific custom_component module (Optional)
     */
    
    #ifndef CUSTOM_COMPONENT_H
    #define CUSTOM_COMPONENT_H
    
    /**
     * customComponentFunc documentation.
     */
    void customComponentFunc(void);
    
    #endif /* CUSTOM_COMPONENT_H */
    /// @}
    

    custom_component.c

    /**
     * \ingroup custom_component
     * 
     */
    
    void customComponentFunc(void) {
        
    }
    

    The Doxygen version I used to generate documentation is 1.9.6. I have generated the documentation using Doxywizard in Linux platform. Finally an image that shows the result.

    enter image description here

    Unfortunately I cannot add the specific doxygen config file since it is large and there is a body character limit in answers. But no worries I uploaded it in a cloud storage so that you can download and view.


    Edit

    Thanks to @albert for the reminder so I also leave the doxygen configuration as condensed view form in case of the original Doxyfile is not available from the cloud drive.

    # Doxyfile 1.9.6
    
    PROJECT_NAME           = "X Application Project"
    PROJECT_NUMBER         = 1.0.0
    PROJECT_BRIEF          = "This is the X Project's synopsis"
    OUTPUT_DIRECTORY       = .
    OPTIMIZE_OUTPUT_FOR_C  = YES
    SHOW_HEADERFILE        = NO
    SHOW_INCLUDE_FILES     = NO
    SHOW_USED_FILES        = NO
    SHOW_FILES             = NO
    INPUT                  = . \
                             ../Xproject
    GENERATE_TREEVIEW      = YES
    FULL_SIDEBAR           = YES
    GENERATE_LATEX         = NO