1

I try to enforce/motivate some fellows to comment their Code so that it becomes more understandable. Therefore, I wanted to use the Template functionality in Eclipse. For now I added the following Template (which is of course not working) using some arbitrary function. I didn't want to do it manually it should be generated AUTOMATICALLY when typing a new method or function.

Template with comment I want and the Prototype of a function it should be placed above when seeing that pattern.

/**
 * @param ${enclosing_method_arguments}
 * @return ${return_type}
 */
${return_type}${enclosing_method}${enclosing_method_arguments}

The desired output is that for each function I get a default Doxygen Command that could be filled out. So its easier to notice that there is something missing. The result should look similar to this:

/**
* @param int a:
* @param int b:
* @return int:
*/

int add(int a, int b){
return a+b

}
  • Isn't it better to state in the coding style guide how documentation has to be? Then all commits that do not follow the coding style guide will be rejected and have to be improved. The problem with auto-generated comments is that doxygen will not complain about missing documentation anymore and therefore finding missing documentation becomes harder. – Benjamin Bihler Oct 21 '19 at 13:20
  • The "Problem" here is that I dont want to do that by hand. I can also use Templates and Press controll + space which is stated here: how-to-automatically-generate-function-header-comments-in-eclipse-cdt. The focus is to improve the workflow and get rid of such things not to generate extra work while programming. The problem of detecting missing Doxygen comments is solved in an extra review tool. – user11344770 Oct 21 '19 at 13:29
  • So is your question whether eclipse can **detect** that a programmer is typing a new function and then **automatically** insert a function comment template? – Benjamin Bihler Oct 21 '19 at 13:36
  • Yes, for each new function – user11344770 Oct 22 '19 at 06:05
  • Perhaps you might want to edit your post to clearly ask that question. I wonder which answers you will get. As far as I know this is not possible in Eclipse. You have to tell eclipse explicitely to insert something while typing. For example you can type the first characters of a template name and then use Ctrl+Space to get a list of possible completions to choose from. If you choose the template, it gets inserted. But the programmer has to trigger that. – Benjamin Bihler Oct 22 '19 at 07:23

0 Answers0