Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ domain limited template support #1729

Closed
andreacassioli opened this issue Feb 16, 2015 · 3 comments
Closed

C++ domain limited template support #1729

andreacassioli opened this issue Feb 16, 2015 · 3 comments
Labels
domains:cpp type:enhancement enhance or introduce a new feature

Comments

@andreacassioli
Copy link

Hi,
I would like to write docs for a c++ function with this signature

.. cpp::function:: template<typename T, int N> namespace::function_name< T , N >(shape_t<N> shape, std::function<T(ptrdiff_t)> f)

but it is not recognized by the C++ domain. I got an error as

WARNING: Invalid definition: "," or ">" in template expected

Investigating it seems that the int params in template are not supported. Is there any plan for that?

@jakobandersen
Copy link
Contributor

Currently the C++ domain does not support template declarations (see also issue #1314), but only template instantiations. As a temporary "solution" you can write
.. cpp:function:: namespace::funcction_name<T, N>(arg1, arg2)
and then change it back when template support is implemented.

@shimizukawa shimizukawa added type:enhancement enhance or introduce a new feature domains:cpp labels Feb 18, 2015
@cbiffle
Copy link

cbiffle commented Jul 14, 2015

FYI, the temporary "solution" does not work for operators.

@cbiffle
Copy link

cbiffle commented Jul 14, 2015

Here are a few other cases I've encountered, for your consideration.

I'm writing my docs by hand, not using Breathe, in case you're curious. (Doxygen chokes harder on my templates than Sphinx does; as noted below, I can kind of make the current Sphinx implementation do what I want.)

Default template parameters

This works:

.. cpp:class:: Maybe<T, CheckPolicy>

This doesn't:

.. cpp:class:: Maybe<T, CheckPolicy = LaxCheckPolicy>

Which probably makes sense, since you're parsing the expression grammar and what I just wrote isn't legal. But currently there's no obvious way to specify default template parameters, except for this:

a template class with a note explaining its missing default

Template operators and template constructors

It isn't legal to pass template parameters to an operator, so currently there's no way of discussing a template operator, except to mention the types in passing without any explanation of where they came from (the S type in the screenshot):
template operator docs with mysterious type S

Template constructors are in a similar boat -- you can't explicitly pass template arguments to a constructor -- but they get a pass in the current C++ domain implementation because it doesn't distinguish them from template functions:

template constructor pretending to be a template function

Non-type template parameters

In an invocation there's no way to tell which parameters are types vs. non-types, and no way to indicate the type of non-type parameters. The convention I'm currently using is to lowercase the non-types and hope the reader gets it, but this doesn't give me a good way of indicating their type:

template alias with non-type template parameter using lowercase name convention

Partial specializations

I haven't even figured out how to express this one.

jakobandersen added a commit to jakobandersen/sphinx that referenced this issue Sep 2, 2015
Create symbol tables to represent all declarations, including templated
declarations (sphinx-doc#1729).
Fixes sphinx-doc#1314.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
domains:cpp type:enhancement enhance or introduce a new feature
Projects
None yet
Development

No branches or pull requests

4 participants