use doxygen to document javascript
There are two mostly used ways to document javascript. One is mentioned in official doxygen help, which uses a perl script to parse javascript code and generate code that doxygen can process. The other is JsDoc, which use rhino to parse javascript code and generate document.
The perl script is not so flexible, and JsDoc can not provide as much commands as doxygen. So I prefer another method that uses pseudo code in java syntax to document javascript.
1. Use a script to get all pseudo code from .js files and generate .java files with the same name, the script is attached bellow named builddoc. This script actually get all lines begin with ‘///’, ‘/**’, ‘/* ‘, ‘ * ‘, ‘ */’ and ‘//*’ into the .java file.
So a javascript file like
//* package ns;
/**
* Foo.
* @param foo foo.
*/
var foo=function(foo){}
//* public void foo(String foo);
will be converted into
package ns;
/**
* Foo.
* @param foo foo.
*/
public void foo(String foo);
And now doxygen can process it in java way.
You should use FILE_PATTERNS = *.java in your doxygen configuration to tell doxygen to parse all .java files.
builddoc:
#!/bin/bash
DIRs="./"
if [ $# -ne 0 ]
then
DIRs=$@
fi
for DIR in $DIRs; do
JSs=`find $DIR -name "*.js"`
for JS in $JSs; do
DOC=`echo $JS|sed 's/\(.*\)\.js/\1.java/g'`;
if [ $JS -nt $DOC ]; then
echo "rebuild $DOC"
grep -e '^\s*\(///\|//\*\|/\*\*\| \* \| \*/\)' $JS | sed 's/^\s*\/\/\*\(.*\)$/\1/g'> $DOC
fi
done
done
about 9 months ago
We enjoy this blog. Might determine create income could maintaining at the moment by making use of it ? Boobs
about 7 months ago
The net will probably be far far more useful than any other time.
about 6 months ago
Wow, amazing blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your website is wonderful, let alone the content!. Thanks For Your article about use doxygen to document javascript .
about 3 weeks ago
Beautiful essay, got the satisfaction of studying