Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8256208: Javadoc's generated overview does not show classes of unnamed package

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -296,12 +296,6 @@ protected void setTopFile() {
} else {
if (showModules) {
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()) {
topFile = docPaths.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
}
@@ -105,13 +105,11 @@ protected void addIndex(Content main) {
}

for (PackageElement pkg : configuration.packages) {
if (!pkg.isUnnamed()) {
if (!(options.noDeprecated() && utils.isDeprecated(pkg))) {
Content packageLinkContent = getPackageLink(pkg, getLocalizedPackageName(pkg));
Content summaryContent = new ContentBuilder();
addSummaryComment(pkg, summaryContent);
table.addRow(pkg, packageLinkContent, summaryContent);
}
if (!(options.noDeprecated() && utils.isDeprecated(pkg))) {
Content packageLinkContent = getPackageLink(pkg, getLocalizedPackageName(pkg));
Content summaryContent = new ContentBuilder();
addSummaryComment(pkg, summaryContent);
table.addRow(pkg, packageLinkContent, summaryContent);
}
}

@@ -24,6 +24,7 @@
/*
* @test
* @bug 4904075 4774450 5015144 8043698 8196201 8203791 8184205 8260223
* 8256208
* @summary Reference unnamed package as "Unnamed", not empty string.
* Generate a package summary for the unnamed package.
* @library ../../lib
@@ -48,6 +49,12 @@ public void test() {
testSrc("src1/C.java"));
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,
"""
<h1 title="Unnamed Package" class="title">Unnamed Package</h1>""",
@@ -156,4 +163,25 @@ public void testUse() {
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>
Copy link
Contributor

@jonathan-gibbons jonathan-gibbons Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old-style? How quaint!

Copy link
Member Author

@hns hns Nov 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One adapts to the environment... Also, not much missing for valid html5 except <!doctype html>