I have a stack of JavaScript files from which I want to extract the function definition lines and the following comment block for documentation purposes,
e.g. in the source files functions are defined thusly;
function thisIsAfunction (firstArg, secondArg, thirdArg) { /* ************************************************************** * a description of the purpose of the function, what * argument values are expected and some examples * of use. * */ [then the body of the code for the function, which may contain further comment blocks that I want to ignore] }
Question is can I do this with the ubiquitous egrep? or will I need to use something like perl or awk?
Any ideas or suggestions? Anyone know of something that already does this?
And before someone asks, yes I have tried google and found one possibility, an awk script that will extract _all_ the comments but not the function definitions [eXtract Source Code Comment http://members.tripod.com/vgoenka/unixscripts/xscc.html]. Most hits were from people who wanted to remove comments to either just compress the source or count lines of code.
Regards,
Keith ____________ Never annoy Dragons. For thou art crunchy and taste good with ketchup. - D&D saying