Permalink
Browse files

Added OpenJavaDocCheck library (new BSD licensed) and written a custo…

…m JavaDoc checks.

* test if the cdk.module tag has been given in the class JavaDoc.
* test if @cdk.bug is followed by an integer
* test if the @cdk.githash tag is given

Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
  • Loading branch information...
1 parent 21aa28e commit 02c335a778e0a0ff83781eda264135578e90d820 @egonw committed with rajarshi Nov 18, 2009
View
@@ -20,5 +20,7 @@
<classpathentry exported="true" kind="lib" path="develjar/com-sun-tools-doclets-Taglet.jar" sourcepath="org.openscience.cdksrc.zip"/>
<classpathentry exported="true" kind="lib" path="develjar/junit-4.5.jar"/>
<classpathentry kind="lib" path="jar/cmlxom-2.5-b1.jar"/>
+ <classpathentry kind="lib" path="develjar/doccheck.jar"/>
+ <classpathentry kind="lib" path="develjar/ojdcheck.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
Binary file not shown.
View
@@ -174,6 +174,68 @@
</javadoc>
</target>
+ <target name="ojdcheck" depends="compileDocTests">
+ <antcall target="ojdcheck-module"><param name="module" value="interfaces"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="core"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="data"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="datadebug"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="nonotify"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="standard"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="atomtype"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="io"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="ioformats"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="inchi"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="extra"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="fingerprint"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="formula"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="render"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="reaction"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="libiocml"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="libiomd"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="builder3d"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="smiles"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="smarts"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="sdg"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="forcefield"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="pdb"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="qsar"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="qsaratomic"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="qsarbond"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="qsarionpot"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="qsarmolecular"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="qsarprotein"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="pcore"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="structgen"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="valencycheck"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="charges"/></antcall>
+ <antcall target="ojdcheck-module"><param name="module" value="diff"/></antcall>
+ </target>
+
+ <target name="ojdcheck-module">
+ <mkdir dir="reports/ojdcheck/"/>
+ <mkdir dir="${build}/src/${module}"/>
+ <copy todir="${build}/src/${module}">
+ <fileset dir="${src}/main">
+ <includesfile name="${build}/${module}.javafiles"/>
+ </fileset>
+ </copy>
+ <javadoc private="false" public="true">
+ <classpath refid="project.class.path" />
+
+ <doclet name="com.github.ojdcheck.OpenJavaDocCheck"
+ path="develjar/ojdcheck.jar:src/main">
+ <param name="-xhtml"/>
+ <param name="-file"
+ value="reports/ojdcheck/${module}.html"/>
+ <param name="-tests"
+ value="net.sf.cdk.tools.checkdoctest.MissingGithashTagletTest,net.sf.cdk.tools.checkdoctest.MissingModuleTagletTest,net.sf.cdk.tools.checkdoctest.IncorrectBugNumberTagletTest"/>
+ </doclet>
+ <sourcepath>
+ <pathelement path="${build}/src/${module}"/>
+ </sourcepath>
+ </javadoc>
+ </target>
+
<target id="check" name="check">
<condition property="isMacOsX">
<and>
@@ -202,7 +264,7 @@
</classpath>
</javac>
<javac srcdir="src/main" destdir="src/main"
- includes="net/sf/cdk/tools/**/*.java" debug="on" optimize="off">
+ includes="net/sf/cdk/tools/**/*Taglet.java" debug="on" optimize="off">
<classpath>
<fileset dir="jar/">
<include name="xom-1.1.jar" />
@@ -211,6 +273,18 @@
</javac>
</target>
+ <target name="compileDocTests" id="compileDocTests"
+ depends="check">
+ <javac srcdir="src/main" destdir="src/main"
+ includes="net/sf/cdk/tools/checkdoctest/*Test.java"
+ debug="on" optimize="off">
+ <classpath>
+ <fileset dir="develjar/">
+ <include name="ojdcheck.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ </target>
</project>
@@ -0,0 +1,99 @@
+/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package net.sf.cdk.tools.checkdoctest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sf.cdk.tools.doclets.CDKBugTaglet;
+
+import com.github.ojdcheck.test.IClassDocTester;
+import com.github.ojdcheck.test.ITestReport;
+import com.github.ojdcheck.test.TestReport;
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.MethodDoc;
+import com.sun.javadoc.Tag;
+
+/**
+ * OpenJavaDocCheck test that tests if the content of the cdk.bug
+ * tag is a valid integer.
+ *
+ * @see CDKBugTaglet
+ */
+public class IncorrectBugNumberTagletTest implements IClassDocTester {
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDescription() {
+ return "Tests if the @cdk.bug content is a valid number.";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return "CDK Bug Taglet Number Test";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<ITestReport> test(ClassDoc classDoc) {
+ List<ITestReport> reports = new ArrayList<ITestReport>();
+ Tag[] tags = classDoc.tags("cdk.bug");
+ for (Tag tag : tags) {
+ try {
+ Integer.valueOf(tag.text());
+ } catch (NumberFormatException exception) {
+ reports.add(
+ new TestReport(
+ this, classDoc,
+ "Invalid integer given as bug number in @cdk.bug tag.",
+ tag.position().line(), null
+ )
+ );
+ }
+ }
+ MethodDoc[] methodDocs = classDoc.methods();
+ for (MethodDoc methodDoc : methodDocs) {
+ tags = methodDoc.tags("cdk.bug");
+ for (Tag tag : tags) {
+ try {
+ Integer.valueOf(tag.text());
+ } catch (NumberFormatException exception) {
+ reports.add(
+ new TestReport(
+ this, classDoc,
+ "Invalid integer given as bug number in @cdk.bug tag.",
+ tag.position().line(), null
+ )
+ );
+ }
+ }
+ }
+ return reports;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Priority getPriority() {
+ return Priority.ERROR;
+ }
+
+}
@@ -0,0 +1,76 @@
+/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package net.sf.cdk.tools.checkdoctest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sf.cdk.tools.doclets.CDKGitTaglet;
+
+import com.github.ojdcheck.test.IClassDocTester;
+import com.github.ojdcheck.test.ITestReport;
+import com.github.ojdcheck.test.TestReport;
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.Tag;
+
+/**
+ * OpenJavaDocCheck test that warns about missing cdk.githash tags.
+ *
+ * @see CDKGitTaglet
+ */
+public class MissingGithashTagletTest implements IClassDocTester {
+
+ /**
+ * @inheritDoc
+ */
+ public String getDescription() {
+ return "Tests if the @cdk.githash tag is given.";
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public String getName() {
+ return "CDK Githash Taglet Test";
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public List<ITestReport> test(ClassDoc classDoc) {
+ List<ITestReport> reports = new ArrayList<ITestReport>();
+ Tag[] tags = classDoc.tags("cdk.githash");
+ if (tags.length == 0) {
+ reports.add(
+ new TestReport(
+ this, classDoc,
+ "Missing @cdk.githash tag.",
+ classDoc.position().line(), null
+ )
+ );
+ }
+ return reports;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Priority getPriority() {
+ return Priority.MINOR_ERROR;
+ }
+
+}
@@ -0,0 +1,77 @@
+/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package net.sf.cdk.tools.checkdoctest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sf.cdk.tools.doclets.CDKModuleTaglet;
+
+import com.github.ojdcheck.test.IClassDocTester;
+import com.github.ojdcheck.test.ITestReport;
+import com.github.ojdcheck.test.TestReport;
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.Tag;
+
+/**
+ * OpenJavaDocCheck test that warns of a class JavaDoc does not contain
+ * the cdk.module tag needed by the build system.
+ *
+ * @see CDKModuleTaglet
+ */
+public class MissingModuleTagletTest implements IClassDocTester {
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDescription() {
+ return "Tests the content of the module taglet content.";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return "CDK Module Taglet Test";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<ITestReport> test(ClassDoc classDoc) {
+ List<ITestReport> reports = new ArrayList<ITestReport>();
+ Tag[] tags = classDoc.tags("cdk.module");
+ if (tags.length == 0) {
+ reports.add(
+ new TestReport(
+ this, classDoc,
+ "Missing @cdk.module tag.",
+ classDoc.position().line(), null
+ )
+ );
+ }
+ return reports;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Priority getPriority() {
+ return Priority.WARNING;
+ }
+
+}

0 comments on commit 02c335a

Please sign in to comment.