11

Is there some way to document template parameters like this:

template<
    int N, ///< description
    typename T ///< description
>

rather than listing each parameter with tparam?

please note that function arguments can be documented like this in current doxygen:

void function(int a /**< description */);

if there is not one, how hard would be to implement it? if you are familiar with doxygen internals, can you point me in the direction where to implement it.

thank you

1 Answer 1

5

There is no way to document your template parameters like you described.

I would say it is not a good idea, because then you would document your template parameters differently from your usual parameters, and why would you want that?

Usually it looks like this:

/*! \p transpose : transpose a matrix
 *
 * \param A input matrix
 * \param At output matrix (transpose of A)
 *
 * \tparam MatrixType1 matrix
 * \tparam MatrixType2 matrix
 */

template <typename MatrixType1, typename MatrixType2>
void transpose(const MatrixType1& A, MatrixType2& At);

and you want it to look like this?!

/*! \p transpose : transpose a matrix
 *
 * \param A input matrix
 * \param At output matrix (transpose of A)
 *
 */

template <
  typename MatrixType1, ///< matrix
  typename MatrixType2  ///< matrix
>
void transpose(const MatrixType1& A, MatrixType2& At);

Why?

Sign up to request clarification or add additional context in comments.

3 Comments

He could place each usual parameter on a new line as well.
yes, I also wanted to place parameters like that. I just find it somewhat easier to read (in source), since parameter is documented right after the declaration
By documenting the parameters where they are defined in the code, the risk of forgetting to document a new parameter when it is added, or forgetting to remove the documentation of a parameter when it is removed, decreases significantly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.