2

I know it's not a big deal to write a function header, but I will admit I am being lazy here.

Is there any tool to generate function headers? I think it's easy to add or delete a field within the function header if it's maintained using a tool.

Example:

/**************************************************************************** 
* NAME:        name                                     
* DESCRIPTION: text 
* ARGUMENTS:   args 
* RETURNS:     void
***************************************************************************/ 

If tomorrow, I plan to add two new fields, "date", and "reentrant", the tool should be able to do this:

/**************************************************************************** 
* NAME:        name                                    (date) 
* DESCRIPTION: text 
* ARGUMENTS:   args 
* RETURNS:     void
* RE-ENTRANT :
***************************************************************************/ 

The closest that I could find is following http://www.vim.org/scripts/script.php?script_id=938. However it's VI editor dependent, and I am not VI's greatest fan.

Some simple script should also do.

Cajunluke
  • 3,103
  • 28
  • 28
Kamath
  • 4,461
  • 5
  • 33
  • 60

2 Answers2

1

I'd suggest splitting what you are trying to do into two separate parts.

A comment block with lines re-stating the arguments to a function is of no use. Everyone who reads the code can see what the arguments are. Unless you're going to describe what the argument is used for, don't waste a line of code.

On the other hand, it is useful to pull out functions and their variables into documentation. As mentioned in a comment by bcr, doxygen does a good job of this. It's a similar tool to javadoc, but targeted at C / C++ and I've used it pretty extensively.

You can run the tool on a directory full of code, and it will automatically pull out the functions along with their parameters into documentation. You don't need to have a comment block to get basic documentation of the names of functions and variables. But if you've written a block with a description of the function, it will include that in the documents for you.

Read more here: http://www.doxygen.nl/

albert
  • 8,285
  • 3
  • 19
  • 32
asc99c
  • 3,815
  • 3
  • 31
  • 54
0

What is your ide?

  • On some tools like Visual Studio, eclipse or other big IDE's it's built in or plug-ins (eclipse).

  • On some editors like emacs, in the time that i was coding with it i wrote a small script that made that job. You can easily handle it with some cat, grep and sed calls. Or make some lisp code to do the job.

svick
  • 236,525
  • 50
  • 385
  • 514
GrandMarquis
  • 1,913
  • 1
  • 18
  • 30
  • I dont use ant ide as of now, windows platform + SourceInsight use makefiles to build in CYGWIN platform. – Kamath Aug 18 '11 at 17:21
  • I don't know sourceInsight, and i'm not used to windows environement. But on any platform you could write a script to do it easily: perl, lua or anything else? I hope someone will be able to answer your question better than me; – GrandMarquis Aug 18 '11 at 18:18