Home > Back-end >  Doxygen: Documenting struct as a member of a struct
Doxygen: Documenting struct as a member of a struct

Time:09-30

I would like to document a struct as a member of a struct, in a style, that there will be clickable link to structure precalculated same as on calibrator_calibration_t and after click it will show me all members of precalculated.

Generated HTML:

Generated HTML

I've tried many different approaches but none of them worked as I needed. Any tip?

/**
 *  @struct filter_t
 *  @brief Filter structure 
 */
typedef struct 
{
    calibrator_calibration_t calibration;             ///< Copied calibration
    blackbox_weight_id_e weight_id;

    struct                                       
    {
        float slope;
        float above_mixed;
        float under_mixed;
        float above_male;
        float under_male;
        float above_female;
        float under_female;
        uint32_t stable_counter_minimum;
    } precalculated;          ///< Precalculated values (for faster calculation) based on settings                              
} filter_t;

CodePudding user response:

If you want the type of structure member precalculated to be documented with a name and a link to separate documentation of that type, then you must give that type a name or tag. You have not done that. C does not allow you to name it (via typedef) when its definition is inside a struct definition, however, and it is poor style to tag it in that context.

If you can get over your apparent aversion to structure tags and are also unconcerned with the stylistic problems involved, then I anticipate that adding a tag would induce Doxygen to do what you want:

typedef struct 
{
    calibrator_calibration_t calibration;             ///< Copied calibration
    blackbox_weight_id_e weight_id;

    struct precalc         // Note the structure tag here
    {
        float slope;
        float above_mixed;
        float under_mixed;
        float above_male;
        float under_male;
        float above_female;
        float under_female;
        uint32_t stable_counter_minimum;
    } precalculated;          ///< Precalculated values (for faster calculation) based on settings                              
} filter_t;

But if you are going to tag the structure type then it would be better form to move it out of the host structure definition, and if you're going to do that, then it appears that your standard convention would be to name it instead of tagging it:

typedef struct {
    float slope;
    float above_mixed;
    float under_mixed;
    float above_male;
    float under_male;
    float above_female;
    float under_female;
    uint32_t stable_counter_minimum;
} precalculated_t;

typedef struct 
{
    calibrator_calibration_t calibration;             ///< Copied calibration
    blackbox_weight_id_e weight_id;
    precalculated_t precalculated;                    ///< Precalculated values (for faster calculation) based on settings
} filter_t;
  • Related