8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
Reviewed-by: jjg, ksrini
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Wed May 11 17:42:17 2016 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Wed May 11 20:28:22 2016 +0000
@@ -91,6 +91,19 @@
}
/**
+ * Get the module link.
+ *
+ * @return a content tree for the module link
+ */
+ @Override
+ protected Content getNavLinkModule() {
+ Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(annotationType),
+ moduleLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
* Get this package link.
*
* @return a content tree for the package link
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java Wed May 11 17:42:17 2016 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java Wed May 11 20:28:22 2016 +0000
@@ -505,6 +505,19 @@
}
/**
+ * Get the module link.
+ *
+ * @return a content tree for the module link
+ */
+ @Override
+ protected Content getNavLinkModule() {
+ Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
+ moduleLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
* Get this package link.
*
* @return a content tree for the package link
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Wed May 11 17:42:17 2016 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Wed May 11 20:28:22 2016 +0000
@@ -105,6 +105,19 @@
}
/**
+ * Get the module link.
+ *
+ * @return a content tree for the module link
+ */
+ @Override
+ protected Content getNavLinkModule() {
+ Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
+ moduleLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
* Get this package link.
*
* @return a content tree for the package link
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Wed May 11 17:42:17 2016 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Wed May 11 20:28:22 2016 +0000
@@ -570,6 +570,11 @@
if (configuration.createoverview) {
navList.addContent(getNavLinkContents());
}
+ if (configuration.modules.size() == 1) {
+ navList.addContent(getNavLinkModule(configuration.modules.first()));
+ } else if (!configuration.modules.isEmpty()) {
+ navList.addContent(getNavLinkModule());
+ }
if (configuration.packages.size() == 1) {
navList.addContent(getNavLinkPackage(configuration.packages.first()));
} else if (!configuration.packages.isEmpty()) {
@@ -679,6 +684,28 @@
}
/**
+ * Get link to the module summary page for the module passed.
+ *
+ * @param mdle Module to which link will be generated
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkModule(ModuleElement mdle) {
+ Content linkContent = getModuleLink(mdle, moduleLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get the word "Module", to indicate that link is not available here.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkModule() {
+ Content li = HtmlTree.LI(moduleLabel);
+ return li;
+ }
+
+ /**
* Get link to the "package-summary.html" page for the package passed.
*
* @param pkg Package to which link will be generated
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Wed May 11 17:42:17 2016 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Wed May 11 20:28:22 2016 +0000
@@ -268,6 +268,17 @@
}
/**
+ * Get this module link.
+ *
+ * @return a content tree for the module link
+ */
+ @Override
+ protected Content getNavLinkModule() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, moduleLabel);
+ return li;
+ }
+
+ /**
* Get "PREV MODULE" link in the navigation bar.
*
* @return a content tree for the previous link
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java Wed May 11 17:42:17 2016 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java Wed May 11 20:28:22 2016 +0000
@@ -224,6 +224,19 @@
}
/**
+ * Get the module link.
+ *
+ * @return a content tree for the module link
+ */
+ @Override
+ protected Content getNavLinkModule() {
+ Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
+ moduleLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
* Get link to the package summary page for the package of this tree.
*
* @return a content tree for the package link
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java Wed May 11 17:42:17 2016 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java Wed May 11 20:28:22 2016 +0000
@@ -304,6 +304,19 @@
}
/**
+ * Get the module link.
+ *
+ * @return a content tree for the module link
+ */
+ @Override
+ protected Content getNavLinkModule() {
+ Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
+ moduleLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
* Get this package link.
*
* @return a content tree for the package link
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java Wed May 11 17:42:17 2016 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java Wed May 11 20:28:22 2016 +0000
@@ -376,6 +376,19 @@
}
/**
+ * Get the module link.
+ *
+ * @return a content tree for the module link
+ */
+ @Override
+ protected Content getNavLinkModule() {
+ Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
+ moduleLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
* Highlight "Package" in the navigation bar, as this is the package page.
*
* @return a content tree for the package link
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java Wed May 11 17:42:17 2016 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java Wed May 11 20:28:22 2016 +0000
@@ -329,6 +329,7 @@
public abstract MessageRetriever getDocletSpecificMsg();
public CommentUtils cmtUtils;
+ public SortedSet<ModuleElement> modules;
/**
* A sorted set of packages specified on the command-line merged with a
@@ -395,6 +396,8 @@
s.add(p);
}
}
+ modules = new TreeSet<>(utils.makeModuleComparator());
+ modules.addAll(modulePackages.keySet());
showModules = (modulePackages.size() > 1);
}
--- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java Wed May 11 17:42:17 2016 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java Wed May 11 20:28:22 2016 +0000
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8154119
+ * @bug 8154119 8154262
* @summary Test modules support in javadoc.
* @author bpatel
* @library ../lib
@@ -41,46 +41,58 @@
@Test
void test1() {
- javadoc("-d", "out",
+ javadoc("-d", "out", "-use",
"-modulesourcepath", testSrc,
"-addmods", "module1,module2",
"testpkgmdl1", "testpkgmdl2");
checkExit(Exit.OK);
testDescription(true);
testNoDescription(false);
+ testModuleLink();
}
@Test
void test2() {
- javadoc("-d", "out-html5", "-html5",
+ javadoc("-d", "out-html5", "-html5", "-use",
"-modulesourcepath", testSrc,
"-addmods", "module1,module2",
"testpkgmdl1", "testpkgmdl2");
checkExit(Exit.OK);
testHtml5Description(true);
testHtml5NoDescription(false);
+ testModuleLink();
}
@Test
void test3() {
- javadoc("-d", "out-nocomment", "-nocomment",
+ javadoc("-d", "out-nocomment", "-nocomment", "-use",
"-modulesourcepath", testSrc,
"-addmods", "module1,module2",
"testpkgmdl1", "testpkgmdl2");
checkExit(Exit.OK);
testDescription(false);
testNoDescription(true);
+ testModuleLink();
}
@Test
void test4() {
- javadoc("-d", "out-html5-nocomment", "-nocomment", "-html5",
+ javadoc("-d", "out-html5-nocomment", "-nocomment", "-html5", "-use",
"-modulesourcepath", testSrc,
"-addmods", "module1,module2",
"testpkgmdl1", "testpkgmdl2");
checkExit(Exit.OK);
testHtml5Description(false);
testHtml5NoDescription(true);
+ testModuleLink();
+ }
+
+ @Test
+ void test5() {
+ javadoc("-d", "out-nomodule", "-use",
+ "-sourcepath", testSrc,
+ "testpkgnomodule");
+ checkExit(Exit.OK);
}
void testDescription(boolean found) {
@@ -142,4 +154,37 @@
+ "<li class=\"blockList\">\n"
+ "<table class=\"overviewSummary\">");
}
+
+ void testModuleLink() {
+ checkOutput("overview-summary.html", true,
+ "<li>Module</li>");
+ checkOutput("module1-summary.html", true,
+ "<li class=\"navBarCell1Rev\">Module</li>");
+ checkOutput("module2-summary.html", true,
+ "<li class=\"navBarCell1Rev\">Module</li>");
+ checkOutput("testpkgmdl1/package-summary.html", true,
+ "<li><a href=\"../module1-summary.html\">Module</a></li>");
+ checkOutput("testpkgmdl1/TestClassInModule1.html", true,
+ "<li><a href=\"../module1-summary.html\">Module</a></li>");
+ checkOutput("testpkgmdl1/class-use/TestClassInModule1.html", true,
+ "<li><a href=\"../../module1-summary.html\">Module</a></li>");
+ checkOutput("testpkgmdl2/package-summary.html", true,
+ "<li><a href=\"../module2-summary.html\">Module</a></li>");
+ checkOutput("testpkgmdl2/TestClassInModule2.html", true,
+ "<li><a href=\"../module2-summary.html\">Module</a></li>");
+ checkOutput("testpkgmdl2/class-use/TestClassInModule2.html", true,
+ "<li><a href=\"../../module2-summary.html\">Module</a></li>");
+ }
+
+ void testNoModuleLink() {
+ checkOutput("testpkgnomodule/package-summary.html", true,
+ "<ul class=\"navList\" title=\"Navigation\">\n"
+ + "<li><a href=\"../testpkgnomodule/package-summary.html\">Package</a></li>");
+ checkOutput("testpkgnomodule/TestClassNoModule.html", true,
+ "<ul class=\"navList\" title=\"Navigation\">\n"
+ + "<li><a href=\"../testpkgnomodule/package-summary.html\">Package</a></li>");
+ checkOutput("testpkgnomodule/class-use/TestClassNoModule.html", true,
+ "<ul class=\"navList\" title=\"Navigation\">\n"
+ + "<li><a href=\"../../testpkgnomodule/package-summary.html\">Package</a></li>");
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testModules/testpkgnomodule/TestClassNoModule.java Wed May 11 20:28:22 2016 +0000
@@ -0,0 +1,28 @@
+/*
+ * 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 testpkgnomodule;
+
+public class TestClassNoModule {
+}