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
  • #1 written by Pengos
    about 5 days ago

    This internet site is my aspiration , quite amazing pattern and perfect articles . 840070

  • #2 written by sms pengar
    about 5 days ago

    Reading, watching movies or plays, or comparable activities that may bring inspiration. 508273

  • #3 written by green coffee extract
    about 4 days ago

    I like this post, enjoyed this 1 regards for posting . 366529

  • #4 written by Brooke Capps
    about 4 days ago

    Following I initially commented I clicked the -Notify me when new feedback are added- checkbox and now each time a remark is added I get four emails with the same comment. Is there any method youll be able to take away me from that service? Thanks! 433241

  • #5 written by factory jailbreak iphone 4
    about 3 hours ago

    I really like what you’ve acquired here, really like what you are saying and the way in which you say it. You make it entertaining and you still care for to keep it wise. I can’t wait to read far more from you. ways to jailbreak iphone 4.

1 ... 8 9 10