--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/Taglet.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/Taglet.java Thu Jun 09 23:24:05 2016 -0700
@@ -87,6 +87,8 @@
public static enum Location {
/** In an Overview document. */
OVERVIEW,
+ /** In the documentation for a module. */
+ MODULE,
/** In the documentation for a package. */
PACKAGE,
/** In the documentation for a class, interface or enum. */
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Thu Jun 09 23:24:05 2016 -0700
@@ -183,6 +183,19 @@
}
/**
+ * {@inheritDoc}
+ */
+ public void addModuleTags(Content moduleContentTree) {
+ Content tree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION()
+ : moduleContentTree;
+ addTagsInfo(mdle, tree);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ moduleContentTree.addContent(tree);
+ }
+ }
+
+ /**
* Adds list of packages in the package summary table. Generate link to each package.
*
* @param packages Packages to which link is to be generated
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java Thu Jun 09 23:24:05 2016 -0700
@@ -82,6 +82,15 @@
public abstract void addModuleDescription(Content moduleContentTree);
/**
+ * Adds the tag information from the "module-info.java" file to the documentation
+ * tree.
+ *
+ * @param moduleContentTree the content tree to which the module tags will
+ * be added
+ */
+ public abstract void addModuleTags(Content moduleContentTree);
+
+ /**
* Adds the table of packages to the documentation tree.
*
* @param packages the set of packages that should be added.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java Thu Jun 09 23:24:05 2016 -0700
@@ -198,4 +198,16 @@
moduleWriter.addModuleDescription(moduleContentTree);
}
}
+
+ /**
+ * Build the tags of the summary.
+ *
+ * @param node the XML element that specifies which components to document
+ * @param moduleContentTree the tree to which the module tags will be added
+ */
+ public void buildModuleTags(XMLNode node, Content moduleContentTree) {
+ if (!configuration.nocomment) {
+ moduleWriter.addModuleTags(moduleContentTree);
+ }
+ }
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml Thu Jun 09 23:24:05 2016 -0700
@@ -31,6 +31,7 @@
<ModuleDoc>
<Content>
<ModuleDescription/>
+ <ModuleTags/>
<Summary>
<PackageSummary/>
</Summary>
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BaseExecutableMemberTaglet.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BaseExecutableMemberTaglet.java Thu Jun 09 23:24:05 2016 -0700
@@ -62,6 +62,17 @@
/**
* Return true if this <code>Taglet</code>
+ * is used in module documentation.
+ * @return true if this <code>Taglet</code>
+ * is used in module documentation and false
+ * otherwise.
+ */
+ public boolean inModule() {
+ return false;
+ }
+
+ /**
+ * Return true if this <code>Taglet</code>
* is used in package documentation.
* @return true if this <code>Taglet</code>
* is used in package documentation and false
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BasePropertyTaglet.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BasePropertyTaglet.java Thu Jun 09 23:24:05 2016 -0700
@@ -90,6 +90,15 @@
* only appear in Methods.
* @return false since this is not a method.
*/
+ public boolean inModule() {
+ return false;
+ }
+
+ /**
+ * Will return false because this tag may
+ * only appear in Methods.
+ * @return false since this is not a method.
+ */
public boolean inPackage() {
return false;
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BaseTaglet.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BaseTaglet.java Thu Jun 09 23:24:05 2016 -0700
@@ -90,6 +90,17 @@
/**
* Return true if this <code>Taglet</code>
+ * is used in module documentation.
+ * @return true if this <code>Taglet</code>
+ * is used in module documentation and false
+ * otherwise.
+ */
+ public boolean inModule() {
+ return true;
+ }
+
+ /**
+ * Return true if this <code>Taglet</code>
* is used in package documentation.
* @return true if this <code>Taglet</code>
* is used in package documentation and false
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java Thu Jun 09 23:24:05 2016 -0700
@@ -95,6 +95,15 @@
/**
* Will return false because this inline tag may
+ * not appear in Modules.
+ * @return false
+ */
+ public boolean inModule() {
+ return false;
+ }
+
+ /**
+ * Will return false because this inline tag may
* not appear in Packages.
* @return false
*/
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java Thu Jun 09 23:24:05 2016 -0700
@@ -152,6 +152,13 @@
/**
* {@inheritDoc}
*/
+ public boolean inModule() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public boolean inPackage() {
return false;
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/SimpleTaglet.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/SimpleTaglet.java Thu Jun 09 23:24:05 2016 -0700
@@ -56,6 +56,11 @@
public static final String EXCLUDED = "x";
/**
+ * The marker in the location string for modules.
+ */
+ public static final String MODULE = "s";
+
+ /**
* The marker in the location string for packages.
*/
public static final String PACKAGE = "p";
@@ -120,7 +125,7 @@
this.header = header;
locations = Utils.toLowerCase(locations);
if (locations.contains(ALL) && !locations.contains(EXCLUDED)) {
- this.locations = PACKAGE + TYPE + FIELD + METHOD + CONSTRUCTOR + OVERVIEW;
+ this.locations = MODULE + PACKAGE + TYPE + FIELD + METHOD + CONSTRUCTOR + OVERVIEW;
} else {
this.locations = locations;
}
@@ -179,6 +184,17 @@
/**
* Return true if this <code>SimpleTaglet</code>
+ * is used in module documentation.
+ * @return true if this <code>SimpleTaglet</code>
+ * is used in module documentation and false
+ * otherwise.
+ */
+ public boolean inModule() {
+ return locations.contains(MODULE) && !locations.contains(EXCLUDED);
+ }
+
+ /**
+ * Return true if this <code>SimpleTaglet</code>
* is used in package documentation.
* @return true if this <code>SimpleTaglet</code>
* is used in package documentation and false
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/Taglet.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/Taglet.java Thu Jun 09 23:24:05 2016 -0700
@@ -76,6 +76,15 @@
/**
* Return true if this <code>Taglet</code>
+ * is used in module documentation.
+ * @return true if this <code>Taglet</code>
+ * is used in module documentation and false
+ * otherwise.
+ */
+ public abstract boolean inModule();
+
+ /**
+ * Return true if this <code>Taglet</code>
* is used in package documentation.
* @return true if this <code>Taglet</code>
* is used in package documentation and false
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java Thu Jun 09 23:24:05 2016 -0700
@@ -31,6 +31,7 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
@@ -81,6 +82,11 @@
private final LinkedHashMap<String,Taglet> customTags;
/**
+ * The array of custom tags that can appear in modules.
+ */
+ private List<Taglet> moduleTags;
+
+ /**
* The array of custom tags that can appear in packages.
*/
private List<Taglet> packageTags;
@@ -373,6 +379,14 @@
}
new SimpleElementVisitor9<Void, Void>() {
@Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Void visitModule(ModuleElement e, Void p) {
+ if (!taglet.inModule()) {
+ printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "module");
+ }
+ return null;
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
public Void visitPackage(PackageElement e, Void p) {
if (!taglet.inPackage()) {
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "package");
@@ -435,6 +449,9 @@
if (taglet.inOverview()) {
locationsSet.add("overview");
}
+ if (taglet.inModule()) {
+ locationsSet.add("module");
+ }
if (taglet.inPackage()) {
locationsSet.add("package");
}
@@ -471,6 +488,19 @@
/**
* Return the array of <code>Taglet</code>s that can
+ * appear in modules.
+ * @return the array of <code>Taglet</code>s that can
+ * appear in modules.
+ */
+ public List<Taglet> getModuleCustomTaglets() {
+ if (moduleTags == null) {
+ initCustomTaglets();
+ }
+ return moduleTags;
+ }
+
+ /**
+ * Return the array of <code>Taglet</code>s that can
* appear in packages.
* @return the array of <code>Taglet</code>s that can
* appear in packages.
@@ -555,6 +585,8 @@
case CLASS:
case ENUM:
return getTypeCustomTaglets();
+ case MODULE:
+ return getModuleCustomTaglets();
case PACKAGE:
return getPackageCustomTaglets();
case OTHER:
@@ -608,6 +640,7 @@
*/
private void initCustomTaglets() {
+ moduleTags = new ArrayList<>();
packageTags = new ArrayList<>();
typeTags = new ArrayList<>();
fieldTags = new ArrayList<>();
@@ -617,6 +650,9 @@
overviewTags = new ArrayList<>();
for (Taglet current : customTags.values()) {
+ if (current.inModule() && !current.isInlineTag()) {
+ moduleTags.add(current);
+ }
if (current.inPackage() && !current.isInlineTag()) {
packageTags.add(current);
}
@@ -666,9 +702,9 @@
addStandardTaglet(!nosince, new SimpleTaglet(SINCE.tagName, message.getText("doclet.Since"),
SimpleTaglet.ALL));
addStandardTaglet(showversion, new SimpleTaglet(VERSION.tagName, message.getText("doclet.Version"),
- SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
+ SimpleTaglet.MODULE + SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
addStandardTaglet(showauthor, new SimpleTaglet(AUTHOR.tagName, message.getText("doclet.Author"),
- SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
+ SimpleTaglet.MODULE + SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
addStandardTaglet(new SimpleTaglet(SERIAL_DATA.tagName, message.getText("doclet.SerialData"),
SimpleTaglet.EXCLUDED));
addStandardTaglet(new SimpleTaglet(HIDDEN.tagName, message.getText("doclet.Hidden"),
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/UserTaglet.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/UserTaglet.java Thu Jun 09 23:24:05 2016 -0700
@@ -89,6 +89,14 @@
/**
* {@inheritDoc}
*/
+ public boolean inModule() {
+ return userTaglet.isInlineTag()
+ || userTaglet.getAllowedLocations().contains(MODULE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public boolean inPackage() {
return userTaglet.isInlineTag()
|| userTaglet.getAllowedLocations().contains(PACKAGE);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java Thu Jun 09 23:24:05 2016 -0700
@@ -95,6 +95,15 @@
/**
* Will return false because this inline tag may
* only appear in Fields.
+ * @return false since this is not a field.
+ */
+ public boolean inModule() {
+ return false;
+ }
+
+ /**
+ * Will return false because this inline tag may
+ * only appear in Fields.
* @return false since this is not a method.
*/
public boolean inPackage() {
--- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java Thu Jun 09 19:06:36 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java Thu Jun 09 23:24:05 2016 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8154119 8154262
+ * @bug 8154119 8154262 8156077
* @summary Test modules support in javadoc.
* @author bpatel
* @library ../lib
@@ -87,7 +87,7 @@
testModuleLink();
}
- @Test
+ @Test
void test5() {
javadoc("-d", "out-nomodule", "-use",
"-sourcepath", testSrc,
@@ -95,6 +95,18 @@
checkExit(Exit.OK);
}
+ @Test
+ void test6() {
+ javadoc("-d", "out-mdltags", "-author", "-version",
+ "-tag", "regular:a:Regular Tag:",
+ "-tag", "moduletag:s:Module Tag:",
+ "-modulesourcepath", testSrc,
+ "-addmods", "moduletags,module2",
+ "testpkgmdltags", "testpkgmdl2");
+ checkExit(Exit.OK);
+ testModuleTags();
+ }
+
void testDescription(boolean found) {
checkOutput("module1-summary.html", found,
"<!-- ============ MODULE DESCRIPTION =========== -->\n"
@@ -187,4 +199,38 @@
"<ul class=\"navList\" title=\"Navigation\">\n"
+ "<li><a href=\"../../testpkgnomodule/package-summary.html\">Package</a></li>");
}
+
+ void testModuleTags() {
+ checkOutput("moduletags-summary.html", true,
+ "Type Link: <a href=\"testpkgmdltags/TestClassInModuleTags.html\" title=\"class in "
+ + "testpkgmdltags\"><code>TestClassInModuleTags</code></a>.");
+ checkOutput("moduletags-summary.html", true,
+ "Member Link: <a href=\"testpkgmdltags/TestClassInModuleTags.html#"
+ + "testMethod-java.lang.String-\"><code>testMethod(String)</code></a>.");
+ checkOutput("moduletags-summary.html", true,
+ "Package Link: <a href=\"testpkgmdltags/package-summary.html\"><code>testpkgmdltags</code></a>.");
+ checkOutput("moduletags-summary.html", true,
+ "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ + "<dd>JDK 9</dd>");
+ checkOutput("moduletags-summary.html", true,
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+ + "<dd>\"Test see tag\", \n"
+ + "<a href=\"testpkgmdltags/TestClassInModuleTags.html\" title=\"class in testpkgmdltags\"><code>"
+ + "TestClassInModuleTags</code></a></dd>");
+ checkOutput("moduletags-summary.html", true,
+ "<dt><span class=\"simpleTagLabel\">Regular Tag:</span></dt>\n"
+ + "<dd>Just a regular simple tag.</dd>");
+ checkOutput("moduletags-summary.html", true,
+ "<dt><span class=\"simpleTagLabel\">Module Tag:</span></dt>\n"
+ + "<dd>Just a simple module tag.</dd>");
+ checkOutput("moduletags-summary.html", true,
+ "<dt><span class=\"simpleTagLabel\">Version:</span></dt>\n"
+ + "<dd>1.0</dd>");
+ checkOutput("moduletags-summary.html", true,
+ "<dt><span class=\"simpleTagLabel\">Author:</span></dt>\n"
+ + "<dd>Bhavesh Patel</dd>");
+ checkOutput("testpkgmdltags/TestClassInModuleTags.html", false,
+ "<dt><span class=\"simpleTagLabel\">Module Tag:</span></dt>\n"
+ + "<dd>Just a simple module tag.</dd>");
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testModules/moduletags/module-info.java Thu Jun 09 23:24:05 2016 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code 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 General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * This is a test description for the module1 module.<br>
+ * Type Link: {@link testpkgmdltags.TestClassInModuleTags}.<br>
+ * Member Link: {@link testpkgmdltags.TestClassInModuleTags#testMethod(String)}.<br>
+ * Package Link: {@link testpkgmdltags}.<br>
+ *
+ * @author Bhavesh Patel
+ * @since JDK 9
+ * @see "Test see tag"
+ * @see testpkgmdltags.TestClassInModuleTags
+ * @regular Just a regular simple tag.
+ * @moduletag Just a simple module tag.
+ * @version 1.0
+ */
+module moduletags {
+ requires module2;
+
+ exports testpkgmdltags;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testModules/moduletags/testpkgmdltags/TestClassInModuleTags.java Thu Jun 09 23:24:05 2016 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code 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 General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package testpkgmdltags;
+
+/**
+ * Simple tag test
+ * @regular Just a regular simple tag.
+ * @moduletag Just a simple module tag.
+ */
+
+public class TestClassInModuleTags {
+ public void testMethod(String str){}
+}