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

Formatting "template <typename T>" part of C++ declarations #1314

Closed
shimizukawa opened this issue Jan 3, 2015 · 4 comments
Closed

Formatting "template <typename T>" part of C++ declarations #1314

shimizukawa opened this issue Jan 3, 2015 · 4 comments
Labels
type:enhancement enhance or introduce a new feature type:proposal a feature suggestion

Comments

@shimizukawa
Copy link
Member

Hi,

I understand this is a pretty subjective request, but I would like to be able to specify a C++ function with template parameters like:

#!rst

.. cpp:function:: template <typename T>
                  SymmetricAerodynamics::set_kind()

And have it render as:

template <typename T>
SymmetricAerodynamics::set_kind()

Currently it will render as two separate functions in the final output or if you put it on one line then it comes out as one line:

template <typename T> SymmetricAerodynamics::set_kind()

In other documentation tools (eg. doxygen) and generally in C++ code layout the template< typename T> part goes on the line above. I would also be happy to specify it on one line and have Sphinx automatically insert the line break.

If this seems like a reasonable thing to support then I would be happy to try to look into implementing it. My interest is in part driven by my work on the Breathe Sphinx extension which generally deals with C++ and would benefit from this multi-line support in the rendering of desc_signature node.

I realise the impact of this change my be considered to be breaking/changing current behaviour and so cannot be done.

Cheers,
Michael


@shimizukawa shimizukawa added type:enhancement enhance or introduce a new feature type:proposal a feature suggestion prio:low labels Jan 3, 2015
@christophercrouzet
Copy link

I'm intending to use sphinx to manually document C++ projects that heavily rely on templates but this is issue doesn't help with the readability factor—too bad it's marked as a low priority.

@Oberon00
Copy link

Oberon00 commented Feb 5, 2015

Same here! Since doxygen is basically unusable for template heavy C++-code, Sphinx is a nice alternative. But until this is implemented, I will have to use rst sections for my functions.

@jakobandersen
Copy link
Contributor

I would like to implement it when I find time, but there are 3 separate issues of which I need a bit of help with the last two:

  • Template declaration support in the domain. I will try to start on this soon.
  • Rendering multi-line declarations. I guess it's easy to render a line break, but I have not found out how.
  • Support for multi-line declarations. The declarations are split somewhere before they reach the domain, and I don't know if it's possible for a domain to disable the splitting.

@jakobandersen
Copy link
Contributor

A declaration can be split over multiple lines by escaping the line break. For example:

.. cpp:class:: template<typename T> \
               MyClass

Each line of template parameter lists should be rendered on their own line.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:enhancement enhance or introduce a new feature type:proposal a feature suggestion
Projects
None yet
Development

No branches or pull requests

4 participants