1

I know I can document a struct member variable inside the struct with doxygen:

struct myStruct {
  int a;   ///< a is an int
}

But how can I put the documentation outside the struct? I've tried various combinations such as:

/// myStruct::a a is an int
/// \var a is an int

But none seem to show up in the generated html. Is this even possible? What would be the correct syntax?

nbubis
  • 2,304
  • 5
  • 31
  • 46
  • Not a duplicate, the previous question asks how to document a header which can't be changed, this asks how to document a struct in a source file we do own. – dave Aug 03 '19 at 04:53
  • @dave How does that make a difference? – L. F. Aug 04 '19 at 03:41
  • @L.F. Ah, I've reread it now and they both end up with about the same answer - but the other one is a more complicated problem. This seemed simpler to understand to me. – dave Aug 04 '19 at 05:17

2 Answers2

1

use \brief , but need to uncomment the first \brief description

struct myStruct {
   int a;   // a is an int
}

then

/// \var int myStruct::a
/// \brief a is an int

I think the "Public Attributes" is for brief information while the "Member Data Documentation" is for the details.

Make sure there is only one \brief then the documentation outside could show in the "Public Attributes"

0

The following seems to work:

/// \var int myStruct::a
/// a is an int

The problem with this method is that it creates multiple line comments that appear under "Member Data Documentation" and not under "Public Attributes" like single line comments, and moreover necessitates duplicating the definition, which is error prone.

I'm still open to other better answers...

nbubis
  • 2,304
  • 5
  • 31
  • 46