8256208: Javadoc's generated overview does not show classes of unnamed package
Reviewed-by: jjg
This commit is contained in:
parent
f65db88b74
commit
e35abe3235
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html
test/langtools/jdk/javadoc/doclet/testUnnamedPackage
@ -296,12 +296,6 @@ public class HtmlConfiguration extends BaseConfiguration {
|
|||||||
} else {
|
} else {
|
||||||
if (showModules) {
|
if (showModules) {
|
||||||
topFile = DocPath.empty.resolve(docPaths.moduleSummary(modules.first()));
|
topFile = DocPath.empty.resolve(docPaths.moduleSummary(modules.first()));
|
||||||
} else if (packages.size() == 1 && packages.first().isUnnamed()) {
|
|
||||||
List<TypeElement> classes = new ArrayList<>(getIncludedTypeElements());
|
|
||||||
if (!classes.isEmpty()) {
|
|
||||||
TypeElement te = getValidClass(classes);
|
|
||||||
topFile = docPaths.forClass(te);
|
|
||||||
}
|
|
||||||
} else if (!packages.isEmpty()) {
|
} else if (!packages.isEmpty()) {
|
||||||
topFile = docPaths.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
|
topFile = docPaths.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
|
||||||
}
|
}
|
||||||
|
@ -105,13 +105,11 @@ public class PackageIndexWriter extends AbstractOverviewIndexWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (PackageElement pkg : configuration.packages) {
|
for (PackageElement pkg : configuration.packages) {
|
||||||
if (!pkg.isUnnamed()) {
|
if (!(options.noDeprecated() && utils.isDeprecated(pkg))) {
|
||||||
if (!(options.noDeprecated() && utils.isDeprecated(pkg))) {
|
Content packageLinkContent = getPackageLink(pkg, getLocalizedPackageName(pkg));
|
||||||
Content packageLinkContent = getPackageLink(pkg, getLocalizedPackageName(pkg));
|
Content summaryContent = new ContentBuilder();
|
||||||
Content summaryContent = new ContentBuilder();
|
addSummaryComment(pkg, summaryContent);
|
||||||
addSummaryComment(pkg, summaryContent);
|
table.addRow(pkg, packageLinkContent, summaryContent);
|
||||||
table.addRow(pkg, packageLinkContent, summaryContent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4904075 4774450 5015144 8043698 8196201 8203791 8184205 8260223
|
* @bug 4904075 4774450 5015144 8043698 8196201 8203791 8184205 8260223
|
||||||
|
* 8256208
|
||||||
* @summary Reference unnamed package as "Unnamed", not empty string.
|
* @summary Reference unnamed package as "Unnamed", not empty string.
|
||||||
* Generate a package summary for the unnamed package.
|
* Generate a package summary for the unnamed package.
|
||||||
* @library ../../lib
|
* @library ../../lib
|
||||||
@ -48,6 +49,12 @@ public class TestUnnamedPackage extends JavadocTester {
|
|||||||
testSrc("src1/C.java"));
|
testSrc("src1/C.java"));
|
||||||
checkExit(Exit.OK);
|
checkExit(Exit.OK);
|
||||||
|
|
||||||
|
checkOutput("index.html", true,
|
||||||
|
"""
|
||||||
|
<script type="text/javascript">window.location.replace('package-summary.html')</script>
|
||||||
|
<noscript>
|
||||||
|
<meta http-equiv="Refresh" content="0;package-summary.html">
|
||||||
|
</noscript>""");
|
||||||
checkOutput("package-summary.html", true,
|
checkOutput("package-summary.html", true,
|
||||||
"""
|
"""
|
||||||
<h1 title="Unnamed Package" class="title">Unnamed Package</h1>""",
|
<h1 title="Unnamed Package" class="title">Unnamed Package</h1>""",
|
||||||
@ -156,4 +163,25 @@ public class TestUnnamedPackage extends JavadocTester {
|
|||||||
eters of type <a href="../A.html" title="class in Unnamed Package">A</a>""");
|
eters of type <a href="../A.html" title="class in Unnamed Package">A</a>""");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMixed() {
|
||||||
|
javadoc("-d", "out-mixed",
|
||||||
|
"-sourcepath", testSrc("src1"),
|
||||||
|
testSrc("src1/C.java"),
|
||||||
|
"pkg");
|
||||||
|
checkExit(Exit.OK);
|
||||||
|
|
||||||
|
checkOutput("index.html", true,
|
||||||
|
"""
|
||||||
|
<div class="col-first even-row-color all-packages-table all-packages-table-tab1"\
|
||||||
|
><a href="package-summary.html">Unnamed Package</a></div>
|
||||||
|
<div class="col-last even-row-color all-packages-table all-packages-table-tab1">
|
||||||
|
<div class="block">This is a package comment for the unnamed package.</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-first odd-row-color all-packages-table all-packages-table-tab1">\
|
||||||
|
<a href="pkg/package-summary.html">pkg</a></div>
|
||||||
|
<div class="col-last odd-row-color all-packages-table all-packages-table-tab1">
|
||||||
|
<div class="block">This is a package comment for package pkg.</div>""");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021, 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.
|
||||||
|
*
|
||||||
|
* 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 pkg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is class D in the package pkg.
|
||||||
|
*/
|
||||||
|
public class D {}
|
@ -0,0 +1,5 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
This is a package comment for package pkg.
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user