I am documenting some code which uses meta-programming heavily, for example:
template<rysq::type A, rysq::type B, rysq::type C, rysq::type D, class Transform>
struct Kernel<meta::braket<A,B,C,D>, Transform,
typename boost::enable_if<
quadrature<meta::braket<A,B,C,D>, Transform> >::type>
: Eri <Transform> {
what is a good way to document such construct using doxygen?
Use preprocessor macros. Here’s an example from the not-yet-official Boost.XInt library (presently queued for review for inclusion in Boost):
Use the
#defined macro names instead of the template parameters, everywhere you need them, like so:And put lines like these in the Doxyfile:
The result is that Doxygen sees either “…” or “other” for the template parameters, and the compiler sees the real ones. If you describe the template parameters in the documentation for the class itself, then the user of the library will only need to see them in the one place that he’s likely to look for them; they’ll be hidden everywhere else.
As an additional advantage to this design, if you ever need to make changes to the template parameter lists, you only need to change them in the macro definitions and the functions that actually use the changed parameters. Everything else will adapt automatically.