Refactored doxygen tests
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13261 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
501bb822e6
commit
93a02cc728
9 changed files with 131 additions and 403 deletions
|
|
@ -3,7 +3,9 @@
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Brief description.
|
* \brief
|
||||||
|
* Brief description.
|
||||||
|
*
|
||||||
* The comment text
|
* The comment text
|
||||||
* \author Some author
|
* \author Some author
|
||||||
* \return Some number
|
* \return Some number
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ enum E_TEST
|
||||||
/** the first item */
|
/** the first item */
|
||||||
E_TEST_ONE,
|
E_TEST_ONE,
|
||||||
E_TEST_TWO = 2, /**< the second */
|
E_TEST_TWO = 2, /**< the second */
|
||||||
E_TEST_THREE = 2+1
|
E_TEST_THREE = 2+1 /**< the last item */
|
||||||
};
|
};
|
||||||
|
|
||||||
%}
|
%}
|
||||||
71
Examples/test-suite/java/commentParser.java
Normal file
71
Examples/test-suite/java/commentParser.java
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
|
||||||
|
import com.sun.javadoc.*;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class commentParser {
|
||||||
|
static HashMap<String, String> parsedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
|
public static boolean start(RootDoc root) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This method is called by 'javadoc' and gets the whole parsed java
|
||||||
|
* file, we get comments and store them
|
||||||
|
*/
|
||||||
|
|
||||||
|
ClassDoc[] classes = root.classes();
|
||||||
|
|
||||||
|
for (int i = 0; i < classes.length; i++) {
|
||||||
|
|
||||||
|
if (classes[i].getRawCommentText().length() > 0)
|
||||||
|
parsedComments.put(classes[i].name(),
|
||||||
|
classes[i].getRawCommentText());
|
||||||
|
|
||||||
|
MethodDoc[] methods = classes[i].methods();
|
||||||
|
FieldDoc[] fields = classes[i].fields();
|
||||||
|
FieldDoc[] constants = classes[i].enumConstants();
|
||||||
|
|
||||||
|
for (int j = 0; j < constants.length; j++) {
|
||||||
|
FieldDoc f = constants[j];
|
||||||
|
if (f.getRawCommentText().length() > 0)
|
||||||
|
parsedComments.put(f.name(), f.getRawCommentText());
|
||||||
|
}
|
||||||
|
for (int j = 0; j < fields.length; j++) {
|
||||||
|
FieldDoc f = fields[j];
|
||||||
|
if (f.getRawCommentText().length() > 0)
|
||||||
|
parsedComments.put(f.name(), f.getRawCommentText());
|
||||||
|
}
|
||||||
|
for (int j = 0; j < methods.length; j++) {
|
||||||
|
MethodDoc m = methods[j];
|
||||||
|
if (m.getRawCommentText().length() > 0)
|
||||||
|
parsedComments.put(m.name(), m.getRawCommentText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int check(HashMap<String, String> wantedComments) {
|
||||||
|
int errorCount=0;
|
||||||
|
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
|
||||||
|
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
Entry<String, String> e = (Entry<String, String>) it.next();
|
||||||
|
|
||||||
|
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
|
||||||
|
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
|
||||||
|
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
|
||||||
|
System.out.println("\tgot:\t"+e.getValue());
|
||||||
|
errorCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parsedComments.size() < wantedComments.size()) {
|
||||||
|
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
|
||||||
|
errorCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return errorCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
import doxygen_basic_translate.*;
|
import doxygen_basic_translate.*;
|
||||||
import com.sun.javadoc.*;
|
import com.sun.javadoc.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class doxygen_basic_translate_runme {
|
public class doxygen_basic_translate_runme {
|
||||||
static {
|
static {
|
||||||
|
|
@ -15,80 +13,24 @@ public class doxygen_basic_translate_runme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static HashMap<String, String> parsedComments = new HashMap<String, String>();
|
|
||||||
static HashMap<String, String> wantedComments = new HashMap<String, String>();
|
|
||||||
|
|
||||||
public static boolean start(RootDoc root) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
This method is called by 'javadoc' and gets the whole parsed
|
|
||||||
java file, we get comments and store them
|
|
||||||
*/
|
|
||||||
|
|
||||||
ClassDoc[] classes = root.classes();
|
|
||||||
|
|
||||||
for (int i = 0; i < classes.length; i++) {
|
|
||||||
|
|
||||||
if (classes[i].getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
|
|
||||||
|
|
||||||
MethodDoc[] methods = classes[i].methods();
|
|
||||||
FieldDoc[] fields = classes[i].fields();
|
|
||||||
FieldDoc[] constants = classes[i].enumConstants();
|
|
||||||
|
|
||||||
for (int j = 0; j < constants.length; j++) {
|
|
||||||
FieldDoc f = constants[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < fields.length; j++) {
|
|
||||||
FieldDoc f = fields[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < methods.length; j++) {
|
|
||||||
MethodDoc m = methods[j];
|
|
||||||
if (m.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(m.name(), m.getRawCommentText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String argv[])
|
public static void main(String argv[])
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
|
commentParser parser = new commentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_basic_translate runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_basic_translate runtime test",
|
||||||
"doxygen_basic_translate_runme", new String[]{"-quiet", "doxygen_basic_translate"});
|
"commentParser", new String[]{"-quiet", "doxygen_basic_translate"});
|
||||||
|
|
||||||
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
wantedComments.put("function", " Brief description. \n The comment text \n" +
|
wantedComments.put("function", " Brief description. \n The comment text \n" +
|
||||||
" @author\tSome author \n" +
|
" @author\tSome author \n" +
|
||||||
" @return\tSome number \n" +
|
" @return\tSome number \n" +
|
||||||
" @see\tfunction2 \n");
|
" @see\tfunction2 \n");
|
||||||
|
|
||||||
int errorCount=0;
|
// and ask the parser to check comments for us
|
||||||
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
|
System.exit(parser.check(wantedComments));
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<String, String> e = (Entry<String, String>) it.next();
|
|
||||||
|
|
||||||
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
|
|
||||||
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
|
|
||||||
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
|
|
||||||
System.out.println("\tgot:\t"+e.getValue());
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parsedComments.size() != wantedComments.size()) {
|
|
||||||
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
System.exit(errorCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
import doxygen_parsing_enums_proper.*;
|
import doxygen_parsing_enums_proper.*;
|
||||||
import com.sun.javadoc.*;
|
import com.sun.javadoc.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class doxygen_parsing_enums_proper_runme {
|
public class doxygen_parsing_enums_proper_runme {
|
||||||
static {
|
static {
|
||||||
|
|
@ -15,79 +13,24 @@ public class doxygen_parsing_enums_proper_runme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static HashMap<String, String> parsedComments = new HashMap<String, String>();
|
|
||||||
static HashMap<String, String> wantedComments = new HashMap<String, String>();
|
|
||||||
|
|
||||||
public static boolean start(RootDoc root) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
This method is called by 'javadoc' and gets the whole parsed
|
|
||||||
java file, we get comments and store them
|
|
||||||
*/
|
|
||||||
|
|
||||||
ClassDoc[] classes = root.classes();
|
|
||||||
|
|
||||||
for (int i = 0; i < classes.length; i++) {
|
|
||||||
|
|
||||||
if (classes[i].getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
|
|
||||||
|
|
||||||
MethodDoc[] methods = classes[i].methods();
|
|
||||||
FieldDoc[] fields = classes[i].fields();
|
|
||||||
FieldDoc[] constants = classes[i].enumConstants();
|
|
||||||
|
|
||||||
for (int j = 0; j < constants.length; j++) {
|
|
||||||
FieldDoc f = constants[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < fields.length; j++) {
|
|
||||||
FieldDoc f = fields[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < methods.length; j++) {
|
|
||||||
MethodDoc m = methods[j];
|
|
||||||
if (m.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(m.name(), m.getRawCommentText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String argv[])
|
public static void main(String argv[])
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
|
commentParser parser = new commentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_proper runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_proper runtime test",
|
||||||
"doxygen_parsing_enums_proper_runme", new String[]{"-quiet", "doxygen_parsing_enums_proper"});
|
"commentParser", new String[]{"-quiet", "doxygen_parsing_enums_proper"});
|
||||||
|
|
||||||
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
wantedComments.put("E_TEST", " Test enumeration \n");
|
wantedComments.put("E_TEST", " Test enumeration \n");
|
||||||
wantedComments.put("E_TEST_ONE", " the first item \n");
|
wantedComments.put("E_TEST_ONE", " the first item \n");
|
||||||
wantedComments.put("E_TEST_TWO", " the second \n");
|
wantedComments.put("E_TEST_TWO", " the second \n");
|
||||||
|
wantedComments.put("E_TEST_THREE", " the last item \n");
|
||||||
|
|
||||||
int errorCount=0;
|
// and ask the parser to check comments for us
|
||||||
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
|
System.exit(parser.check(wantedComments));
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<String, String> e = (Entry<String, String>) it.next();
|
|
||||||
|
|
||||||
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
|
|
||||||
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
|
|
||||||
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
|
|
||||||
System.out.println("\tgot:\t"+e.getValue());
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parsedComments.size() != wantedComments.size()) {
|
|
||||||
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
System.exit(errorCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
import doxygen_parsing_enums_simple.*;
|
import doxygen_parsing_enums_simple.*;
|
||||||
import com.sun.javadoc.*;
|
import com.sun.javadoc.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class doxygen_parsing_enums_simple_runme {
|
public class doxygen_parsing_enums_simple_runme {
|
||||||
static {
|
static {
|
||||||
|
|
@ -15,78 +13,23 @@ public class doxygen_parsing_enums_simple_runme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static HashMap<String, String> parsedComments = new HashMap<String, String>();
|
|
||||||
static HashMap<String, String> wantedComments = new HashMap<String, String>();
|
|
||||||
|
|
||||||
public static boolean start(RootDoc root) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
This method is called by 'javadoc' and gets the whole parsed
|
|
||||||
java file, we get comments and store them
|
|
||||||
*/
|
|
||||||
|
|
||||||
ClassDoc[] classes = root.classes();
|
|
||||||
|
|
||||||
for (int i = 0; i < classes.length; i++) {
|
|
||||||
|
|
||||||
if (classes[i].getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
|
|
||||||
|
|
||||||
MethodDoc[] methods = classes[i].methods();
|
|
||||||
FieldDoc[] fields = classes[i].fields();
|
|
||||||
FieldDoc[] constants = classes[i].enumConstants();
|
|
||||||
|
|
||||||
for (int j = 0; j < constants.length; j++) {
|
|
||||||
FieldDoc f = constants[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < fields.length; j++) {
|
|
||||||
FieldDoc f = fields[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < methods.length; j++) {
|
|
||||||
MethodDoc m = methods[j];
|
|
||||||
if (m.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(m.name(), m.getRawCommentText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String argv[])
|
public static void main(String argv[])
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
|
commentParser parser = new commentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_simple runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_simple runtime test",
|
||||||
"doxygen_parsing_enums_simple_runme", new String[]{"-quiet", "doxygen_parsing_enums_simple"});
|
"commentParser", new String[]{"-quiet", "doxygen_parsing_enums_simple"});
|
||||||
|
|
||||||
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
wantedComments.put("E_TEST_ONE", " the first item \n");
|
wantedComments.put("E_TEST_ONE", " the first item \n");
|
||||||
wantedComments.put("E_TEST_TWO", " the second \n");
|
wantedComments.put("E_TEST_TWO", " the second \n");
|
||||||
|
wantedComments.put("E_TEST_THREE", " the last item \n");
|
||||||
|
|
||||||
int errorCount=0;
|
// and ask the parser to check comments for us
|
||||||
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
|
System.exit(parser.check(wantedComments));
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<String, String> e = (Entry<String, String>) it.next();
|
|
||||||
|
|
||||||
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
|
|
||||||
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
|
|
||||||
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
|
|
||||||
System.out.println("\tgot:\t"+e.getValue());
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parsedComments.size() != wantedComments.size()) {
|
|
||||||
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
System.exit(errorCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
import doxygen_parsing_enums_typesafe.*;
|
import doxygen_parsing_enums_typesafe.*;
|
||||||
import com.sun.javadoc.*;
|
import com.sun.javadoc.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class doxygen_parsing_enums_typesafe_runme {
|
public class doxygen_parsing_enums_typesafe_runme {
|
||||||
static {
|
static {
|
||||||
|
|
@ -15,79 +13,24 @@ public class doxygen_parsing_enums_typesafe_runme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static HashMap<String, String> parsedComments = new HashMap<String, String>();
|
|
||||||
static HashMap<String, String> wantedComments = new HashMap<String, String>();
|
|
||||||
|
|
||||||
public static boolean start(RootDoc root) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
This method is called by 'javadoc' and gets the whole parsed
|
|
||||||
java file, we get comments and store them
|
|
||||||
*/
|
|
||||||
|
|
||||||
ClassDoc[] classes = root.classes();
|
|
||||||
|
|
||||||
for (int i = 0; i < classes.length; i++) {
|
|
||||||
|
|
||||||
if (classes[i].getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
|
|
||||||
|
|
||||||
MethodDoc[] methods = classes[i].methods();
|
|
||||||
FieldDoc[] fields = classes[i].fields();
|
|
||||||
FieldDoc[] constants = classes[i].enumConstants();
|
|
||||||
|
|
||||||
for (int j = 0; j < constants.length; j++) {
|
|
||||||
FieldDoc f = constants[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < fields.length; j++) {
|
|
||||||
FieldDoc f = fields[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < methods.length; j++) {
|
|
||||||
MethodDoc m = methods[j];
|
|
||||||
if (m.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(m.name(), m.getRawCommentText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String argv[])
|
public static void main(String argv[])
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
|
commentParser parser = new commentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typesafe runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typesafe runtime test",
|
||||||
"doxygen_parsing_enums_typesafe_runme", new String[]{"-quiet", "doxygen_parsing_enums_typesafe"});
|
"commentParser", new String[]{"-quiet", "doxygen_parsing_enums_typesafe"});
|
||||||
|
|
||||||
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
wantedComments.put("E_TEST", " Test enumeration \n");
|
wantedComments.put("E_TEST", " Test enumeration \n");
|
||||||
wantedComments.put("E_TEST_ONE", " the first item \n");
|
wantedComments.put("E_TEST_ONE", " the first item \n");
|
||||||
wantedComments.put("E_TEST_TWO", " the second \n");
|
wantedComments.put("E_TEST_TWO", " the second \n");
|
||||||
|
wantedComments.put("E_TEST_THREE", " the last item \n");
|
||||||
|
|
||||||
int errorCount=0;
|
// and ask the parser to check comments for us
|
||||||
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
|
System.exit(parser.check(wantedComments));
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<String, String> e = (Entry<String, String>) it.next();
|
|
||||||
|
|
||||||
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
|
|
||||||
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
|
|
||||||
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
|
|
||||||
System.out.println("\tgot:\t"+e.getValue());
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parsedComments.size() != wantedComments.size()) {
|
|
||||||
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
System.exit(errorCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
import doxygen_parsing_enums_typeunsafe.*;
|
import doxygen_parsing_enums_typeunsafe.*;
|
||||||
import com.sun.javadoc.*;
|
import com.sun.javadoc.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class doxygen_parsing_enums_typeunsafe_runme {
|
public class doxygen_parsing_enums_typeunsafe_runme {
|
||||||
static {
|
static {
|
||||||
|
|
@ -15,79 +13,24 @@ public class doxygen_parsing_enums_typeunsafe_runme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static HashMap<String, String> parsedComments = new HashMap<String, String>();
|
|
||||||
static HashMap<String, String> wantedComments = new HashMap<String, String>();
|
|
||||||
|
|
||||||
public static boolean start(RootDoc root) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
This method is called by 'javadoc' and gets the whole parsed
|
|
||||||
java file, we get comments and store them
|
|
||||||
*/
|
|
||||||
|
|
||||||
ClassDoc[] classes = root.classes();
|
|
||||||
|
|
||||||
for (int i = 0; i < classes.length; i++) {
|
|
||||||
|
|
||||||
if (classes[i].getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
|
|
||||||
|
|
||||||
MethodDoc[] methods = classes[i].methods();
|
|
||||||
FieldDoc[] fields = classes[i].fields();
|
|
||||||
FieldDoc[] constants = classes[i].enumConstants();
|
|
||||||
|
|
||||||
for (int j = 0; j < constants.length; j++) {
|
|
||||||
FieldDoc f = constants[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < fields.length; j++) {
|
|
||||||
FieldDoc f = fields[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < methods.length; j++) {
|
|
||||||
MethodDoc m = methods[j];
|
|
||||||
if (m.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(m.name(), m.getRawCommentText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String argv[])
|
public static void main(String argv[])
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
|
commentParser parser = new commentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typeunsafe runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typeunsafe runtime test",
|
||||||
"doxygen_parsing_enums_typeunsafe_runme", new String[]{"-quiet", "doxygen_parsing_enums_typeunsafe"});
|
"commentParser", new String[]{"-quiet", "doxygen_parsing_enums_typeunsafe"});
|
||||||
|
|
||||||
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
wantedComments.put("E_TEST", " Test enumeration \n");
|
wantedComments.put("E_TEST", " Test enumeration \n");
|
||||||
wantedComments.put("E_TEST_ONE", " the first item \n");
|
wantedComments.put("E_TEST_ONE", " the first item \n");
|
||||||
wantedComments.put("E_TEST_TWO", " the second \n");
|
wantedComments.put("E_TEST_TWO", " the second \n");
|
||||||
|
wantedComments.put("E_TEST_THREE", " the last item \n");
|
||||||
|
|
||||||
int errorCount=0;
|
// and ask the parser to check comments for us
|
||||||
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
|
System.exit(parser.check(wantedComments));
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<String, String> e = (Entry<String, String>) it.next();
|
|
||||||
|
|
||||||
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
|
|
||||||
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
|
|
||||||
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
|
|
||||||
System.out.println("\tgot:\t"+e.getValue());
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parsedComments.size() != wantedComments.size()) {
|
|
||||||
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
System.exit(errorCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
import doxygen_parsing.*;
|
import doxygen_parsing.*;
|
||||||
import com.sun.javadoc.*;
|
import com.sun.javadoc.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class doxygen_parsing_runme {
|
public class doxygen_parsing_runme {
|
||||||
static {
|
static {
|
||||||
|
|
@ -15,54 +13,17 @@ public class doxygen_parsing_runme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static HashMap<String, String> parsedComments = new HashMap<String, String>();
|
|
||||||
static HashMap<String, String> wantedComments = new HashMap<String, String>();
|
|
||||||
|
|
||||||
public static boolean start(RootDoc root) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
This method is called by 'javadoc' and gets the whole parsed
|
|
||||||
java file, we get comments and store them
|
|
||||||
*/
|
|
||||||
|
|
||||||
ClassDoc[] classes = root.classes();
|
|
||||||
|
|
||||||
for (int i = 0; i < classes.length; i++) {
|
|
||||||
|
|
||||||
if (classes[i].getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
|
|
||||||
|
|
||||||
MethodDoc[] methods = classes[i].methods();
|
|
||||||
FieldDoc[] fields = classes[i].fields();
|
|
||||||
FieldDoc[] constants = classes[i].enumConstants();
|
|
||||||
|
|
||||||
for (int j = 0; j < constants.length; j++) {
|
|
||||||
FieldDoc f = constants[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < fields.length; j++) {
|
|
||||||
FieldDoc f = fields[j];
|
|
||||||
if (f.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(f.name(), f.getRawCommentText());
|
|
||||||
}
|
|
||||||
for (int j = 0; j < methods.length; j++) {
|
|
||||||
MethodDoc m = methods[j];
|
|
||||||
if (m.getRawCommentText().length() > 0)
|
|
||||||
parsedComments.put(m.name(), m.getRawCommentText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String argv[])
|
public static void main(String argv[])
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
|
commentParser parser = new commentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_parsing runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_parsing runtime test",
|
||||||
"doxygen_parsing_runme", new String[]{"-quiet", "doxygen_parsing"});
|
"commentParser", new String[]{"-quiet", "doxygen_parsing"});
|
||||||
|
|
||||||
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
wantedComments.put("simpleFunction", " This is simple comment for a function \n");
|
wantedComments.put("simpleFunction", " This is simple comment for a function \n");
|
||||||
|
|
||||||
|
|
@ -85,27 +46,7 @@ public class doxygen_parsing_runme {
|
||||||
wantedComments.put("setSimpleVarFive", " This is a post comment \n");
|
wantedComments.put("setSimpleVarFive", " This is a post comment \n");
|
||||||
wantedComments.put("getSimpleVarFive", " This is a post comment \n");
|
wantedComments.put("getSimpleVarFive", " This is a post comment \n");
|
||||||
|
|
||||||
|
// and ask the parser to check comments for us
|
||||||
int errorCount=0;
|
System.exit(parser.check(wantedComments));
|
||||||
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
|
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<String, String> e = (Entry<String, String>) it.next();
|
|
||||||
|
|
||||||
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
|
|
||||||
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
|
|
||||||
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
|
|
||||||
System.out.println("\tgot:\t"+e.getValue());
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parsedComments.size() != wantedComments.size()) {
|
|
||||||
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
System.exit(errorCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue