8135291: [javadoc] broken link in Package com.sun.tools.jconsole

Reviewed-by: jjg, ksrini
This commit is contained in:
Bhavesh Patel 2016-08-15 22:14:25 -07:00
parent c7f35c53af
commit f6fc6ee2b8
4 changed files with 129 additions and 72 deletions

View file

@ -209,7 +209,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
HtmlTree div = new HtmlTree(HtmlTag.DIV); HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.header); div.addStyle(HtmlStyle.header);
ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(typeElement); ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(typeElement);
if (mdle != null && !mdle.isUnnamed()) { if (configuration.showModules) {
Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, contents.moduleLabel); Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, contents.moduleLabel);
Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classModuleLabel); Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classModuleLabel);
moduleNameDiv.addContent(Contents.SPACE); moduleNameDiv.addContent(Contents.SPACE);

View file

@ -580,11 +580,13 @@ public class HtmlDocletWriter extends HtmlDocWriter {
if (configuration.createoverview) { if (configuration.createoverview) {
navList.addContent(getNavLinkContents()); navList.addContent(getNavLinkContents());
} }
if (configuration.showModules) {
if (configuration.modules.size() == 1) { if (configuration.modules.size() == 1) {
navList.addContent(getNavLinkModule(configuration.modules.first())); navList.addContent(getNavLinkModule(configuration.modules.first()));
} else if (!configuration.modules.isEmpty()) { } else if (!configuration.modules.isEmpty()) {
navList.addContent(getNavLinkModule()); navList.addContent(getNavLinkModule());
} }
}
if (configuration.packages.size() == 1) { if (configuration.packages.size() == 1) {
navList.addContent(getNavLinkPackage(configuration.packages.first())); navList.addContent(getNavLinkPackage(configuration.packages.first()));
} else if (!configuration.packages.isEmpty()) { } else if (!configuration.packages.isEmpty()) {

View file

@ -125,7 +125,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
HtmlTree div = new HtmlTree(HtmlTag.DIV); HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.header); div.addStyle(HtmlStyle.header);
ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(packageElement); ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(packageElement);
if (mdle != null && !mdle.isUnnamed()) { if (configuration.showModules) {
Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, contents.moduleLabel); Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, contents.moduleLabel);
Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classModuleLabel); Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classModuleLabel);
moduleNameDiv.addContent(Contents.SPACE); moduleNameDiv.addContent(Contents.SPACE);

View file

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8154119 8154262 8156077 8157987 8154261 8154817 * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291
* @summary Test modules support in javadoc. * @summary Test modules support in javadoc.
* @author bpatel * @author bpatel
* @library ../lib * @library ../lib
@ -31,7 +31,6 @@
* @build JavadocTester * @build JavadocTester
* @run main TestModules * @run main TestModules
*/ */
public class TestModules extends JavadocTester { public class TestModules extends JavadocTester {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
@ -39,72 +38,108 @@ public class TestModules extends JavadocTester {
tester.runTests(); tester.runTests();
} }
/**
* Test generated module pages for HTML 4.
*/
@Test @Test
void test1() { void testHtml4() {
javadoc("-d", "out", "-use", javadoc("-d", "out", "-use",
"--module-source-path", testSrc, "--module-source-path", testSrc,
"--add-modules", "module1,module2", "--add-modules", "module1,module2",
"testpkgmdl1", "testpkgmdl2"); "testpkgmdl1", "testpkgmdl2");
checkExit(Exit.OK); checkExit(Exit.OK);
testDescription(true); checkDescription(true);
testNoDescription(false); checkNoDescription(false);
testOverviewSummaryModules(); checkOverviewSummaryModules();
testModuleLink(); checkModuleLink();
testModuleClickThroughLinks(); checkModuleClickThroughLinks();
testModuleClickThrough(true); checkModuleClickThrough(true);
checkModuleFilesAndLinks(true);
} }
/**
* Test generated module pages for HTML 5.
*/
@Test @Test
void test2() { void testHtml5() {
javadoc("-d", "out-html5", "-html5", "-use", javadoc("-d", "out-html5", "-html5", "-use",
"--module-source-path", testSrc, "--module-source-path", testSrc,
"--add-modules", "module1,module2", "--add-modules", "module1,module2",
"testpkgmdl1", "testpkgmdl2"); "testpkgmdl1", "testpkgmdl2");
checkExit(Exit.OK); checkExit(Exit.OK);
testHtml5Description(true); checkHtml5Description(true);
testHtml5NoDescription(false); checkHtml5NoDescription(false);
testHtml5OverviewSummaryModules(); checkHtml5OverviewSummaryModules();
testModuleLink(); checkModuleLink();
testModuleClickThroughLinks(); checkModuleClickThroughLinks();
testModuleClickThrough(true); checkModuleClickThrough(true);
checkModuleFilesAndLinks(true);
} }
/**
* Test generated module pages for HTML 4 with -nocomment option.
*/
@Test @Test
void test3() { void testHtml4NoComment() {
javadoc("-d", "out-nocomment", "-nocomment", "-use", javadoc("-d", "out-nocomment", "-nocomment", "-use",
"--module-source-path", testSrc, "--module-source-path", testSrc,
"--add-modules", "module1,module2", "--add-modules", "module1,module2",
"testpkgmdl1", "testpkgmdl2"); "testpkgmdl1", "testpkgmdl2");
checkExit(Exit.OK); checkExit(Exit.OK);
testDescription(false); checkDescription(false);
testNoDescription(true); checkNoDescription(true);
testModuleLink(); checkModuleLink();
checkModuleFilesAndLinks(true);
} }
/**
* Test generated module pages for HTML 5 with -nocomment option.
*/
@Test @Test
void test4() { void testHtml5NoComment() {
javadoc("-d", "out-html5-nocomment", "-nocomment", "-html5", "-use", javadoc("-d", "out-html5-nocomment", "-nocomment", "-html5", "-use",
"--module-source-path", testSrc, "--module-source-path", testSrc,
"--add-modules", "module1,module2", "--add-modules", "module1,module2",
"testpkgmdl1", "testpkgmdl2"); "testpkgmdl1", "testpkgmdl2");
checkExit(Exit.OK); checkExit(Exit.OK);
testHtml5Description(false); checkHtml5Description(false);
testHtml5NoDescription(true); checkHtml5NoDescription(true);
testModuleLink(); checkModuleLink();
checkModuleFilesAndLinks(true);
} }
/**
* Test generated pages, in an unnamed module, for HTML 4.
*/
@Test @Test
void test5() { void testHtml4UnnamedModule() {
javadoc("-d", "out-nomodule", "-use", javadoc("-d", "out-nomodule", "-use",
"-sourcepath", testSrc, "-sourcepath", testSrc,
"testpkgnomodule", "testpkgnomodule1"); "testpkgnomodule", "testpkgnomodule1");
checkExit(Exit.OK); checkExit(Exit.OK);
testOverviewSummaryPackages(); checkOverviewSummaryPackages();
testModuleClickThrough(false); checkModuleClickThrough(false);
checkModuleFilesAndLinks(false);
} }
/**
* Test generated pages, in an unnamed module, for HTML 5.
*/
@Test @Test
void test6() { void testHtml5UnnamedModule() {
javadoc("-d", "out-html5-nomodule", "-html5", "-use",
"-sourcepath", testSrc,
"testpkgnomodule", "testpkgnomodule1");
checkExit(Exit.OK);
checkHtml5OverviewSummaryPackages();
checkModuleFilesAndLinks(false);
}
/**
* Test generated module pages with javadoc tags.
*/
@Test
void testJDTagsInModules() {
javadoc("-d", "out-mdltags", "-author", "-version", javadoc("-d", "out-mdltags", "-author", "-version",
"-tag", "regular:a:Regular Tag:", "-tag", "regular:a:Regular Tag:",
"-tag", "moduletag:s:Module Tag:", "-tag", "moduletag:s:Module Tag:",
@ -112,30 +147,37 @@ public class TestModules extends JavadocTester {
"--add-modules", "moduletags,module2", "--add-modules", "moduletags,module2",
"testpkgmdltags", "testpkgmdl2"); "testpkgmdltags", "testpkgmdl2");
checkExit(Exit.OK); checkExit(Exit.OK);
testModuleTags(); checkModuleTags();
} }
/**
* Test generated module summary page.
*/
@Test @Test
void test7() { void testModuleSummary() {
javadoc("-d", "out-moduleSummary", "-use", javadoc("-d", "out-moduleSummary", "-use",
"-modulesourcepath", testSrc, "-modulesourcepath", testSrc,
"-addmods", "module1,module2", "-addmods", "module1,module2",
"testpkgmdl1", "testpkgmdl2", "testpkg2mdl2"); "testpkgmdl1", "testpkgmdl2", "testpkg2mdl2");
checkExit(Exit.OK); checkExit(Exit.OK);
testModuleSummary(); checkModuleSummary();
testNegatedModuleSummary(); checkNegatedModuleSummary();
} }
/**
* Test generated module pages and pages with link to modules.
*/
@Test @Test
void test8() { void testModuleFilesAndLinks() {
javadoc("-d", "out-html5-nomodule", "-html5", "-use", javadoc("-d", "out-modulelinks",
"-sourcepath", testSrc, "-modulesourcepath", testSrc,
"testpkgnomodule", "testpkgnomodule1"); "-addmods", "module1",
"testpkgmdl1");
checkExit(Exit.OK); checkExit(Exit.OK);
testHtml5OverviewSummaryPackages(); checkModuleFilesAndLinks(false);
} }
void testDescription(boolean found) { void checkDescription(boolean found) {
checkOutput("module1-summary.html", found, checkOutput("module1-summary.html", found,
"<!-- ============ MODULE DESCRIPTION =========== -->\n" "<!-- ============ MODULE DESCRIPTION =========== -->\n"
+ "<a name=\"module.description\">\n" + "<a name=\"module.description\">\n"
@ -150,7 +192,7 @@ public class TestModules extends JavadocTester {
+ "<div class=\"block\">This is a test description for the module2 module.</div>"); + "<div class=\"block\">This is a test description for the module2 module.</div>");
} }
void testNoDescription(boolean found) { void checkNoDescription(boolean found) {
checkOutput("module1-summary.html", found, checkOutput("module1-summary.html", found,
"<div class=\"contentContainer\">\n" "<div class=\"contentContainer\">\n"
+ "<ul class=\"blockList\">\n" + "<ul class=\"blockList\">\n"
@ -167,7 +209,7 @@ public class TestModules extends JavadocTester {
+ "<!-- ============ MODULES SUMMARY =========== -->"); + "<!-- ============ MODULES SUMMARY =========== -->");
} }
void testHtml5Description(boolean found) { void checkHtml5Description(boolean found) {
checkOutput("module1-summary.html", found, checkOutput("module1-summary.html", found,
"<section role=\"region\">\n" "<section role=\"region\">\n"
+ "<!-- ============ MODULE DESCRIPTION =========== -->\n" + "<!-- ============ MODULE DESCRIPTION =========== -->\n"
@ -186,7 +228,7 @@ public class TestModules extends JavadocTester {
+ "</section>"); + "</section>");
} }
void testHtml5NoDescription(boolean found) { void checkHtml5NoDescription(boolean found) {
checkOutput("module1-summary.html", found, checkOutput("module1-summary.html", found,
"<div class=\"contentContainer\">\n" "<div class=\"contentContainer\">\n"
+ "<ul class=\"blockList\">\n" + "<ul class=\"blockList\">\n"
@ -203,17 +245,13 @@ public class TestModules extends JavadocTester {
+ "<!-- ============ MODULES SUMMARY =========== -->"); + "<!-- ============ MODULES SUMMARY =========== -->");
} }
void testModuleLink() { void checkModuleLink() {
checkOutput("overview-summary.html", true, checkOutput("overview-summary.html", true,
"<li>Module</li>"); "<li>Module</li>");
checkOutput("module1-summary.html", true, checkOutput("module1-summary.html", true,
"<li class=\"navBarCell1Rev\">Module</li>"); "<li class=\"navBarCell1Rev\">Module</li>");
checkOutput("module2-summary.html", true, checkOutput("module2-summary.html", true,
"<li class=\"navBarCell1Rev\">Module</li>"); "<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, checkOutput("testpkgmdl1/class-use/TestClassInModule1.html", true,
"<li><a href=\"../../module1-summary.html\">Module</a></li>"); "<li><a href=\"../../module1-summary.html\">Module</a></li>");
checkOutput("testpkgmdl2/package-summary.html", true, checkOutput("testpkgmdl2/package-summary.html", true,
@ -224,7 +262,7 @@ public class TestModules extends JavadocTester {
"<li><a href=\"../../module2-summary.html\">Module</a></li>"); "<li><a href=\"../../module2-summary.html\">Module</a></li>");
} }
void testNoModuleLink() { void checkNoModuleLink() {
checkOutput("testpkgnomodule/package-summary.html", true, checkOutput("testpkgnomodule/package-summary.html", true,
"<ul class=\"navList\" title=\"Navigation\">\n" "<ul class=\"navList\" title=\"Navigation\">\n"
+ "<li><a href=\"../testpkgnomodule/package-summary.html\">Package</a></li>"); + "<li><a href=\"../testpkgnomodule/package-summary.html\">Package</a></li>");
@ -236,7 +274,7 @@ public class TestModules extends JavadocTester {
+ "<li><a href=\"../../testpkgnomodule/package-summary.html\">Package</a></li>"); + "<li><a href=\"../../testpkgnomodule/package-summary.html\">Package</a></li>");
} }
void testModuleTags() { void checkModuleTags() {
checkOutput("moduletags-summary.html", true, checkOutput("moduletags-summary.html", true,
"Type Link: <a href=\"testpkgmdltags/TestClassInModuleTags.html\" title=\"class in " "Type Link: <a href=\"testpkgmdltags/TestClassInModuleTags.html\" title=\"class in "
+ "testpkgmdltags\"><code>TestClassInModuleTags</code></a>."); + "testpkgmdltags\"><code>TestClassInModuleTags</code></a>.");
@ -270,7 +308,7 @@ public class TestModules extends JavadocTester {
+ "<dd>Just a simple module tag.</dd>"); + "<dd>Just a simple module tag.</dd>");
} }
void testOverviewSummaryModules() { void checkOverviewSummaryModules() {
checkOutput("overview-summary.html", true, checkOutput("overview-summary.html", true,
"<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n" "<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n"
+ "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
@ -287,7 +325,7 @@ public class TestModules extends JavadocTester {
+ "</tr>"); + "</tr>");
} }
void testOverviewSummaryPackages() { void checkOverviewSummaryPackages() {
checkOutput("overview-summary.html", false, checkOutput("overview-summary.html", false,
"<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n" "<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n"
+ "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
@ -304,7 +342,7 @@ public class TestModules extends JavadocTester {
+ "</tr>"); + "</tr>");
} }
void testHtml5OverviewSummaryModules() { void checkHtml5OverviewSummaryModules() {
checkOutput("overview-summary.html", true, checkOutput("overview-summary.html", true,
"<table class=\"overviewSummary\">\n" "<table class=\"overviewSummary\">\n"
+ "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
@ -321,7 +359,7 @@ public class TestModules extends JavadocTester {
+ "</tr>"); + "</tr>");
} }
void testHtml5OverviewSummaryPackages() { void checkHtml5OverviewSummaryPackages() {
checkOutput("overview-summary.html", false, checkOutput("overview-summary.html", false,
"<table class=\"overviewSummary\">\n" "<table class=\"overviewSummary\">\n"
+ "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
@ -338,7 +376,7 @@ public class TestModules extends JavadocTester {
+ "</tr>"); + "</tr>");
} }
void testModuleSummary() { void checkModuleSummary() {
checkOutput("module1-summary.html", true, checkOutput("module1-summary.html", true,
"<ul class=\"subNavList\">\n" "<ul class=\"subNavList\">\n"
+ "<li>Module:&nbsp;</li>\n" + "<li>Module:&nbsp;</li>\n"
@ -440,7 +478,7 @@ public class TestModules extends JavadocTester {
+ "</tr>"); + "</tr>");
} }
void testNegatedModuleSummary() { void checkNegatedModuleSummary() {
checkOutput("module1-summary.html", false, checkOutput("module1-summary.html", false,
"<!-- ============ SERVICES SUMMARY =========== -->\n" "<!-- ============ SERVICES SUMMARY =========== -->\n"
+ "<a name=\"services.summary\">\n" + "<a name=\"services.summary\">\n"
@ -448,7 +486,7 @@ public class TestModules extends JavadocTester {
+ "</a>"); + "</a>");
} }
void testModuleClickThroughLinks() { void checkModuleClickThroughLinks() {
checkOutput("module-overview-frame.html", true, checkOutput("module-overview-frame.html", true,
"<li><a href=\"module1-frame.html\" target=\"packageListFrame\" " "<li><a href=\"module1-frame.html\" target=\"packageListFrame\" "
+ "onclick=\"updateModuleFrame('module1-type-frame.html','module1-summary.html');" + "onclick=\"updateModuleFrame('module1-type-frame.html','module1-summary.html');"
@ -463,11 +501,28 @@ public class TestModules extends JavadocTester {
+ " top.packageFrame.location = pFrame;\n" + " top.packageFrame.location = pFrame;\n"
+ " top.classFrame.location = cFrame;\n" + " top.classFrame.location = cFrame;\n"
+ "}"); + "}");
} }
void testModuleClickThrough(boolean found) { void checkModuleClickThrough(boolean found) {
checkFiles(found, checkFiles(found,
"module1-type-frame.html", "module1-type-frame.html",
"module2-type-frame.html"); "module2-type-frame.html");
} }
void checkModuleFilesAndLinks(boolean found) {
checkOutput("testpkgmdl1/package-summary.html", found,
"<li><a href=\"../module1-summary.html\">Module</a></li>");
checkOutput("testpkgmdl1/package-summary.html", found,
"<div class=\"subTitle\"><span class=\"moduleLabelInClass\">Module</span>&nbsp;"
+ "<a href=\"../module1-summary.html\">module1</a></div>");
checkOutput("testpkgmdl1/TestClassInModule1.html", found,
"<li><a href=\"../module1-summary.html\">Module</a></li>");
checkOutput("testpkgmdl1/TestClassInModule1.html", found,
"<div class=\"subTitle\"><span class=\"moduleLabelInClass\">Module</span>&nbsp;"
+ "<a href=\"../module1-summary.html\">module1</a></div>");
checkFiles(found,
"module1-frame.html",
"module1-summary.html",
"module-overview-frame.html");
}
} }