cppalliance / mrdocs

MrDocs: A Clang/LLVM tool for building reference documentation from C++ code and javadoc comments.
https://mrdocs.com
Other
75 stars 16 forks source link

tparams are missing from asciidoc templates #674

Open akrzemi1 opened 6 days ago

akrzemi1 commented 6 days ago

Is it possible to extend the grammar of this "javadoc" format to allow describing the template parameters? This could look like this:

/** The main class template for instantiating markable types

    @tparam MP mark policy that defines how the marked value is represented in the `representation_type`
    @tparam OP policy for relational operations
 */
template <typename MP, typename OP>
class markable
{
  /* ... */
};
vinniefalco commented 6 days ago

This should already work

akrzemi1 commented 6 days ago

It does not, at least not for my header.

This is my header before the annotations. https://github.com/akrzemi1/markable/blob/master/include/ak_toolkit/markable.hpp

I first forward-declare my class template, and then later provide a definition. I will later try to upload a version with the annotations

alandefreitas commented 6 days ago

Yes. If it doesn't find your @tparam, then that's just a bug we haven't seen yet. Probably related to these forward declarations because we have already used @tparam a lot.

alandefreitas commented 6 days ago

Or maybe the @tparam asciidoc templates are missing for classes.

akrzemi1 commented 6 days ago

The three special things about my template is that:

  1. I use a forward declaration
  2. I use default parameter values
  3. I use a macro rather than just typename
/** The main class template for instantiating markable types

    @tparam MP mark policy that defines how the marked value is represented in the `representation_type`
 */
template <AK_TOOLKIT_MARK_POLICY MP, typename OP = order_none>
class markable;
alandefreitas commented 6 days ago

MrDocs understands tparam, forward declarations, and macros.

https://github.com/cppalliance/mrdocs/blob/8537d3dbc71878a3ea6e176b0d25af8d0d51e799/test-files/golden-tests/duplicate-jdoc.cpp#L25-L37 https://github.com/cppalliance/mrdocs/blob/8537d3dbc71878a3ea6e176b0d25af8d0d51e799/test-files/golden-tests/duplicate-jdoc.xml#L90-L106

I believe the problem is much simpler. @tparams are just missing from the asciidoc templates:

https://github.com/cppalliance/mrdocs/blob/develop/share/mrdocs/addons/generator/asciidoc/partials/symbols/record.adoc.hbs https://github.com/cppalliance/mrdocs/blob/develop/share/mrdocs/addons/generator/asciidoc/partials/symbols/function.adoc.hbs

I believe the reason is that we have this pattern of not documenting @tparams when they're deduced from the @param, so we didn't notice that the @tparams were not in the templates at all.

vinniefalco commented 6 days ago

Please edit the issue title and description to reflect the defect. Or open a new one.