31

Does anyone know how to edit the style used for Doxygen comments in Eclipse CDT?

In other words type /** and pressing enter on a line before a function currently gives me something like:

/**
 * 
 * @param one
 * @param two
 * @return
 */
Foo(int one, int two);

and I want it to give me something like:

/**********************************************************************/
///
/// \param one
/// \param two
/// \return
/***********************************************************************/
Foo(int one, int two);

Also, plus one if anyone knows how to bind this to a keyboard shortcut (like alt-shift-j for Eclipse JDT).

Also, FYI, the fact that Eclipse CDT supports Doxygen now seems to be a little known fact based on Google. See here for details. Doxygen can be enabled under the project properties by selecting "Enable project specific settings" in the "C/C++ General" tab and selecting "Doxygen". My CDT version is 7.0.1, but I think this became available in 5.0.

Lastly, the comments section under code templates in preferences doesn't accomplish this based on my testing.

EDIT: See here. It seems like the comment style is hard coded. If anyone finds otherwise, I'd love to know about it. I guess templates will be the best thing for now unless the Javadoc style is okay for you.

jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
deuberger
  • 3,578
  • 6
  • 31
  • 33

5 Answers5

5

Yes, this seems to be a bug in Eclipse CDT.

As a workaround I suggest you create a custom template which can be accessed with the Ctrl+Space key combination.

In Eclipse Helios: Window -> Preferences -> C/C++ -> Editor -> Templates

Click on New... to create a new template and in the Name field use some descriptive name e.g. "comment-function", and add your doxygen comment in the Pattern field. Confirm and apply this change.

In your code you can then go to the line above your function declaration, type the first few letters of your custom template name followed by the Ctrl+Space key combination.

In this example:

com<Ctrl+space>

will bring up the Content Assist dialog filtered with "com*" from which you can select the "comment-function" template.

Note:

com<Ctrl+space+space>

will filter even further by only showing Template Proposals in the Content Assist pop-up window.

rolve
  • 10,083
  • 4
  • 55
  • 75
Theuns Alberts
  • 330
  • 4
  • 7
1

This is a configuration I found in my java comment

Javadoc comment modification

and when i edited as shown my java doc comment changed to

image in java editor

Try to look for similar configuration under your php configuration.

Naveen Babu
  • 1,584
  • 1
  • 14
  • 35
  • I have this in my `C/C++` code style settings too however for some reason I get `@...` instead of `\...` (as the style has specified). It seems that there is a more central place to change these things and it overrides the styles for the specific language. Sounds like a bug to me... – rbaleksandar Apr 18 '17 at 13:45
0

I can get some of the way to what you want by going to: Preferences - PHP - Code Style - Code Templates - Comments.

I'm not sure that this will enable you to use backslashes instead of @s for your keywords, but I think it should achieve most of what you want.

xgretsch
  • 1,294
  • 13
  • 15
  • Thanks for the idea, but I've already looked into that (see the link in my edit from a few months ago above) and it doesn't accomplish what I want. – deuberger Apr 12 '11 at 15:34
0

Starting from eclipse 2020-03 you can use a combination of options: code template to create your header and footer using /*****/ and then in the middle just use /// customizing the style in C/C++->Editor options.

greywolf82
  • 21,813
  • 18
  • 54
  • 108
-2

A Doxygen tag uses this basic format.

/**
Your tags and such. It MUST have the /** and the */.
*/

It absolutely must have the /** */ around the whole Doxygen comment. If you modify the Code Templates it will do what you want.

The proposed comment style is wrong though.

/***************/ <-- These are terminated Doxygen blocks.
/// <-- These are used in xml style Doxygen blocks.
///
/// This isn't actually a Doxygen block and shouldn't work
/// if you run Doxygen on it.
///
/***************/ <-- These are terminated Doxygen blocks.

This below is standard for most companies who code in JAVA and eclipse. Since Doxygen is valid for multiple languages this is valid for C/C++ too.

/**
 * Brief description.
 *
 * @param[in|out] <value> <description>
 */

If you want to use the xml style tags...

/// <summary>
/// This is a summary of the class, blah, blah.
/// </summary>

You're also going to want to make sure eclipse isn't inserting other comment styles too, otherwise you can end up with comments inserted inside other comments. Also generally it is a bad rule to mix comment styles like /** */ and ///.

Finally if you select auto-generate comments when you create classes and such those comments will automatically be put in. And you can have eclipse auto-generate method headers as you type (though I forget how I did this).

GlazedHam
  • 205
  • 1
  • 2
  • 10
  • 6
    Doxygen supports a number of formats. See http://www.stack.nl/~dimitri/doxygen/docblocks.html. The format you referenced is the Javadoc format and is just one of many supported formats. The format I gave as example is unconventional, but not wrong, just different. Also, you did not answer the question. As I already mentioned in one of my edits, this is an eclipse bug which is now addressed here https://bugs.eclipse.org/bugs/show_bug.cgi?id=333134. Thanks for trying to help though. – deuberger Mar 07 '12 at 16:46