1

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:

  • Adding the line @addtogroup application in the markdown files concatenates them in the module "application".
  • Adding to a group specific functions or the module declaration to a group adds those functions to the same generic module description.

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

Ricard Molins
  • 408
  • 1
  • 6
  • 20
  • Which version of doxygen are you using? Did you have a look at the paragraph "Changing the layout of pages" (https://www.doxygen.nl/manual/customize.html#layout), will probably not help in your case though. Did you have a look at the "Grouping" (https://www.doxygen.nl/manual/grouping.html) especially trying nested groups, looks like you tried something here please show your effort so we can comment and give feedback? – albert Oct 30 '22 at 16:44
  • On a file level the `\addtogroup` doesn't work for `\file` as the `\file` describes the content of the file and this sees doxygen as a higher level than a group and moves the description outside of the group. Did you try `FULL_PATH_NAMES` as well? – albert Oct 31 '22 at 08:31
  • I have tried th `\addtogroup` to function and they are also added to the module page. I have played with `FULL_PATH_NAMES` but turning it on and off does not make any change in the table of content. – Ricard Molins Oct 31 '22 at 17:40
  • Only thing to do is create a small MWE and make this available. – albert Oct 31 '22 at 17:59
  • can you clarify what a MWE is ? – Ricard Molins Nov 02 '22 at 06:39
  • 1
    MWE: Minimal Working Example showing the problem (so small source plus settings different from the default settings (i.e `doxygen -x Doxyfile`)). – albert Nov 02 '22 at 08:45

1 Answers1

1

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:

  • app1
  • app2
  • custom_component
  • custom_timer

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
Kozmotronik
  • 2,080
  • 3
  • 10
  • 25
  • `Unfortunately I cannot add the specific doxygen config file since it is large` but is the result of `doxygen -x Doxyfile` still too large to add? Also mention in your answer which version of doxygen you used (`doxygen -v`). – albert Jan 27 '23 at 14:34
  • I don't execute `doxygen -x Doxyfile` since I use Doxywizard. *Also mention in your answer which version of doxygen you used* - Surely. – Kozmotronik Jan 27 '23 at 14:38
  • In the doxywizard there s in the "run" tab the check box "condensed" and the button "show configuration" together they also do a `doxygen -x` and furthermore you would have a `Doxyfile` on your disk on which you could give `doxygen -x Doxyfile` in a terminal window. – albert Jan 27 '23 at 15:03
  • I see dear @albert but does it really matter doing `doxygen -x` while I have provided the Doxyfile itself? After all, the purpose of this answer was to show a simple implentation for the OP's specific problem wasn't it? I have also provided the version in the answer. – Kozmotronik Jan 27 '23 at 15:14
  • Well I think you meant that you provided the `Doxyfile` somewhere in a google drive, this might not be persistent, so better would be the condensed version of part of your answer. – albert Jan 27 '23 at 15:43
  • I think you are right @albert. Although it is in my personal GDrive that I have been using for a long time, I better leave a condensed version here. Thank you for the reminder. – Kozmotronik Jan 27 '23 at 19:12