8154262: Navigation bar in javadoc generated pages needs to be updated to display module information

Reviewed-by: jjg, ksrini
This commit is contained in:
Bhavesh Patel 2016-05-11 20:28:22 +00:00
parent a00ea0d34f
commit 139c282119
11 changed files with 197 additions and 5 deletions

View File

@ -90,6 +90,19 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
this.next = nextType;
}
/**
* 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.
*

View File

@ -504,6 +504,19 @@ public class ClassUseWriter extends SubWriterHolderWriter {
return bodyTree;
}
/**
* 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.
*

View File

@ -104,6 +104,19 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
this.next = nextClass;
}
/**
* 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.
*

View File

@ -570,6 +570,11 @@ public class HtmlDocletWriter extends HtmlDocWriter {
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()) {
@ -678,6 +683,28 @@ public class HtmlDocletWriter extends HtmlDocWriter {
return li;
}
/**
* 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.
*

View File

@ -267,6 +267,17 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
}
}
/**
* 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.
*

View File

@ -223,6 +223,19 @@ public class PackageTreeWriter extends AbstractTreeWriter {
}
}
/**
* 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.
*

View File

@ -303,6 +303,19 @@ public class PackageUseWriter extends SubWriterHolderWriter {
return bodyTree;
}
/**
* 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.
*

View File

@ -375,6 +375,19 @@ public class PackageWriterImpl extends HtmlDocletWriter
return li;
}
/**
* 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.
*

View File

@ -329,6 +329,7 @@ public abstract class Configuration {
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 @@ public abstract class Configuration {
s.add(p);
}
}
modules = new TreeSet<>(utils.makeModuleComparator());
modules.addAll(modulePackages.keySet());
showModules = (modulePackages.size() > 1);
}

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 8154119
* @bug 8154119 8154262
* @summary Test modules support in javadoc.
* @author bpatel
* @library ../lib
@ -41,46 +41,58 @@ public class TestModules extends JavadocTester {
@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 @@ public class TestModules extends JavadocTester {
+ "<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>");
}
}

View File

@ -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 {
}