Wed, 11 Sep 2013 14:50:11 -0700
8015496: Information that package is deprecated is missing in profiles view
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java Wed Sep 11 08:30:58 2013 -0400 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java Wed Sep 11 14:50:11 2013 -0700 1.3 @@ -157,7 +157,7 @@ 1.4 addAllProfilesLink(div); 1.5 } 1.6 body.addContent(div); 1.7 - if (configuration.showProfiles) { 1.8 + if (configuration.showProfiles && configuration.profilePackages.size() > 0) { 1.9 Content profileSummary = configuration.getResource("doclet.Profiles"); 1.10 addProfilesList(profileSummary, body); 1.11 }
2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java Wed Sep 11 08:30:58 2013 -0400 2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java Wed Sep 11 14:50:11 2013 -0700 2.3 @@ -205,13 +205,20 @@ 2.4 * {@inheritDoc} 2.5 */ 2.6 protected void generateProfileFiles() throws Exception { 2.7 - if (configuration.showProfiles) { 2.8 + if (configuration.showProfiles && configuration.profilePackages.size() > 0) { 2.9 ProfileIndexFrameWriter.generate(configuration); 2.10 Profile prevProfile = null, nextProfile; 2.11 + String profileName; 2.12 for (int i = 1; i < configuration.profiles.getProfileCount(); i++) { 2.13 - ProfilePackageIndexFrameWriter.generate(configuration, Profile.lookup(i).name); 2.14 + profileName = Profile.lookup(i).name; 2.15 + // Generate profile package pages only if there are any packages 2.16 + // in a profile to be documented. The profilePackages map will not 2.17 + // contain an entry for the profile if there are no packages to be documented. 2.18 + if (!configuration.shouldDocumentProfile(profileName)) 2.19 + continue; 2.20 + ProfilePackageIndexFrameWriter.generate(configuration, profileName); 2.21 PackageDoc[] packages = configuration.profilePackages.get( 2.22 - Profile.lookup(i).name); 2.23 + profileName); 2.24 PackageDoc prev = null, next; 2.25 for (int j = 0; j < packages.length; j++) { 2.26 // if -nodeprecated option is set and the package is marked as
3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java Wed Sep 11 08:30:58 2013 -0400 3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java Wed Sep 11 14:50:11 2013 -0700 3.3 @@ -130,10 +130,14 @@ 3.4 String profileName; 3.5 for (int i = 1; i < configuration.profiles.getProfileCount(); i++) { 3.6 profileName = Profile.lookup(i).name; 3.7 - Content profileLinkContent = getTargetProfileLink("classFrame", 3.8 - new StringContent(profileName), profileName); 3.9 - Content li = HtmlTree.LI(profileLinkContent); 3.10 - ul.addContent(li); 3.11 + // If the profile has valid packages to be documented, add it to the 3.12 + // profiles list on overview-summary.html page. 3.13 + if (configuration.shouldDocumentProfile(profileName)) { 3.14 + Content profileLinkContent = getTargetProfileLink("classFrame", 3.15 + new StringContent(profileName), profileName); 3.16 + Content li = HtmlTree.LI(profileLinkContent); 3.17 + ul.addContent(li); 3.18 + } 3.19 } 3.20 profilesDiv.addContent(ul); 3.21 Content div = HtmlTree.DIV(HtmlStyle.contentContainer, profilesDiv);
4.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java Wed Sep 11 08:30:58 2013 -0400 4.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java Wed Sep 11 14:50:11 2013 -0700 4.3 @@ -88,8 +88,13 @@ 4.4 Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading); 4.5 HtmlTree ul = new HtmlTree(HtmlTag.UL); 4.6 ul.setTitle(profilesLabel); 4.7 + String profileName; 4.8 for (int i = 1; i < profiles.getProfileCount(); i++) { 4.9 - ul.addContent(getProfile(i)); 4.10 + profileName = (Profile.lookup(i)).name; 4.11 + // If the profile has valid packages to be documented, add it to the 4.12 + // left-frame generated for profile index. 4.13 + if (configuration.shouldDocumentProfile(profileName)) 4.14 + ul.addContent(getProfile(profileName)); 4.15 } 4.16 div.addContent(ul); 4.17 body.addContent(div); 4.18 @@ -98,13 +103,12 @@ 4.19 /** 4.20 * Gets each profile name as a separate link. 4.21 * 4.22 - * @param profile the profile being documented 4.23 + * @param profileName the profile being documented 4.24 * @return content for the profile link 4.25 */ 4.26 - protected Content getProfile(int profile) { 4.27 + protected Content getProfile(String profileName) { 4.28 Content profileLinkContent; 4.29 Content profileLabel; 4.30 - String profileName = (Profile.lookup(profile)).name; 4.31 profileLabel = new StringContent(profileName); 4.32 profileLinkContent = getHyperLink(DocPaths.profileFrame(profileName), profileLabel, "", 4.33 "packageListFrame");
5.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java Wed Sep 11 08:30:58 2013 -0400 5.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java Wed Sep 11 14:50:11 2013 -0700 5.3 @@ -138,6 +138,7 @@ 5.4 "classFrame", new StringContent(pkg.name()), profile.name); 5.5 Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName); 5.6 HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading); 5.7 + addPackageDeprecationInfo(li, pkg); 5.8 return li; 5.9 } 5.10 5.11 @@ -175,6 +176,30 @@ 5.12 } 5.13 5.14 /** 5.15 + * Add the profile package deprecation information to the documentation tree. 5.16 + * 5.17 + * @param li the content tree to which the deprecation information will be added 5.18 + * @param pkg the PackageDoc that is added 5.19 + */ 5.20 + public void addPackageDeprecationInfo(Content li, PackageDoc pkg) { 5.21 + Tag[] deprs; 5.22 + if (Util.isDeprecated(pkg)) { 5.23 + deprs = pkg.tags("deprecated"); 5.24 + HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); 5.25 + deprDiv.addStyle(HtmlStyle.deprecatedContent); 5.26 + Content deprPhrase = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase); 5.27 + deprDiv.addContent(deprPhrase); 5.28 + if (deprs.length > 0) { 5.29 + Tag[] commentTags = deprs[0].inlineTags(); 5.30 + if (commentTags.length > 0) { 5.31 + addInlineDeprecatedComment(pkg, deprs[0], deprDiv); 5.32 + } 5.33 + } 5.34 + li.addContent(deprDiv); 5.35 + } 5.36 + } 5.37 + 5.38 + /** 5.39 * Get "PREV PROFILE" link in the navigation bar. 5.40 * 5.41 * @return a content tree for the previous link
6.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Wed Sep 11 08:30:58 2013 -0400 6.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Wed Sep 11 14:50:11 2013 -0700 6.3 @@ -396,6 +396,9 @@ 6.4 interimResults.put(p, new ArrayList<PackageDoc>()); 6.5 6.6 for (PackageDoc pkg: packages) { 6.7 + if (nodeprecated && Util.isDeprecated(pkg)) { 6.8 + continue; 6.9 + } 6.10 // the getProfile method takes a type name, not a package name, 6.11 // but isn't particularly fussy about the simple name -- so just use * 6.12 int i = profiles.getProfile(pkg.name().replace(".", "/") + "/*"); 6.13 @@ -409,12 +412,17 @@ 6.14 // Build the profilePackages structure used by the doclet 6.15 profilePackages = new HashMap<String,PackageDoc[]>(); 6.16 List<PackageDoc> prev = Collections.<PackageDoc>emptyList(); 6.17 + int size; 6.18 for (Map.Entry<Profile,List<PackageDoc>> e: interimResults.entrySet()) { 6.19 Profile p = e.getKey(); 6.20 List<PackageDoc> pkgs = e.getValue(); 6.21 pkgs.addAll(prev); // each profile contains all lower profiles 6.22 Collections.sort(pkgs); 6.23 - profilePackages.put(p.name, pkgs.toArray(new PackageDoc[pkgs.size()])); 6.24 + size = pkgs.size(); 6.25 + // For a profile, if there are no packages to be documented, do not add 6.26 + // it to profilePackages map. 6.27 + if (size > 0) 6.28 + profilePackages.put(p.name, pkgs.toArray(new PackageDoc[pkgs.size()])); 6.29 prev = pkgs; 6.30 } 6.31 6.32 @@ -719,6 +727,17 @@ 6.33 } 6.34 6.35 /** 6.36 + * Check the validity of the given profile. Return false if there are no 6.37 + * valid packages to be documented for the profile. 6.38 + * 6.39 + * @param profileName the profile that needs to be validated. 6.40 + * @return true if the profile has valid packages to be documented. 6.41 + */ 6.42 + public boolean shouldDocumentProfile(String profileName) { 6.43 + return profilePackages.containsKey(profileName); 6.44 + } 6.45 + 6.46 + /** 6.47 * Check the validity of the given Source or Output File encoding on this 6.48 * platform. 6.49 *
7.1 --- a/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java Wed Sep 11 08:30:58 2013 -0400 7.2 +++ b/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java Wed Sep 11 14:50:11 2013 -0700 7.3 @@ -23,7 +23,7 @@ 7.4 7.5 /* 7.6 * @test 7.7 - * @bug 8006124 8009684 8015663 7.8 + * @bug 8006124 8009684 8015663 8015496 7.9 * @summary Test javadoc options support for profiles. 7.10 * @author Evgeniya Stepanova 7.11 * @library ../lib/ 7.12 @@ -35,6 +35,7 @@ 7.13 //Test information. 7.14 private static final String BUG_ID = "8006124-8009684"; 7.15 private static final String PROFILE_CONFIGURATION_BUG_ID = BUG_ID + "-3"; 7.16 + private static final String NODEPR_NOPKGS_BUG_ID = BUG_ID + "-4"; 7.17 //Javadoc arguments. 7.18 private static final String[] ARGS3 = new String[]{ 7.19 "-d", PROFILE_CONFIGURATION_BUG_ID, "-sourcepath", SRC_DIR, "-nocomment", 7.20 @@ -42,6 +43,30 @@ 7.21 "-doctitle", "Simple doctitle", "-use", "pkg3", "pkg1", "pkg2", "pkg4", 7.22 "pkg5", "-packagesheader", "Simple packages header","pkgDeprecated" 7.23 }; 7.24 + private static final String[] ARGS4 = new String[]{ 7.25 + "-d", NODEPR_NOPKGS_BUG_ID, "-sourcepath", SRC_DIR, "-nocomment", "-nodeprecated", 7.26 + "-keywords", "-Xprofilespath", SRC_DIR + FS + "profile-rtjar-includes-nopkgs.txt", 7.27 + "-doctitle", "Simple doctitle", "-use", "-packagesheader", "Simple packages header", 7.28 + "pkg1", "pkg2", "pkg3", "pkg4", "pkg5", "pkgDeprecated" 7.29 + }; 7.30 + private static final String[][] NODEPR_NOPKGS_TEST = { 7.31 + {NODEPR_NOPKGS_BUG_ID + FS + "overview-summary.html", 7.32 + "<ul>" + NL + "<li><a href=\"compact2-summary.html\" target=\"classFrame\">" + 7.33 + "compact2</a></li>" + NL + "<li><a href=\"compact3-summary.html\" target=\"" + 7.34 + "classFrame\">compact3</a></li>" + NL + "</ul>" 7.35 + }, 7.36 + {NODEPR_NOPKGS_BUG_ID + FS + "profile-overview-frame.html", 7.37 + "<ul title=\"Profiles\">" + NL + "<li><a href=\"compact2-frame.html\" target=\"packageListFrame\">" + 7.38 + "compact2</a></li>" + NL + "<li><a href=\"compact3-frame.html\" target=\"" + 7.39 + "packageListFrame\">compact3</a></li>" + NL + "</ul>" 7.40 + } 7.41 + }; 7.42 + private static final String[][] NODEPR_NOPKGS_NEGATED_TEST = { 7.43 + {NODEPR_NOPKGS_BUG_ID + FS + "overview-summary.html", 7.44 + "compact1" 7.45 + } 7.46 + }; 7.47 + 7.48 private static final String[][] PROFILES_CONFIGURATION_TEST = { 7.49 //-use option test string fo profile view page 7.50 {PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html","<li>Use</li>" 7.51 @@ -57,6 +82,12 @@ 7.52 //-keywords option test string for profiles 7.53 {PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html", 7.54 "<meta name=\"keywords\" content=\"compact1 profile\">" 7.55 + }, 7.56 + //Deprecated information on a package 7.57 + {PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html", 7.58 + "<h3><a href=\"pkgDeprecated/compact1-package-summary.html\" target=\"" + 7.59 + "classFrame\">pkgDeprecated</a></h3>" + NL + "<div class=\"deprecatedContent\">" + 7.60 + "<span class=\"strong\">Deprecated.</span></div>" 7.61 } 7.62 }; 7.63 private static final String[][] PROFILES_CONFIGURATION_NEGATED_TEST = { 7.64 @@ -75,6 +106,8 @@ 7.65 TestProfilesConfiguration tester = new TestProfilesConfiguration(); 7.66 run(tester, ARGS3, PROFILES_CONFIGURATION_TEST, 7.67 PROFILES_CONFIGURATION_NEGATED_TEST); 7.68 + run(tester, ARGS4, NODEPR_NOPKGS_TEST, 7.69 + NODEPR_NOPKGS_NEGATED_TEST); 7.70 tester.printSummary(); 7.71 } 7.72
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/com/sun/javadoc/testProfiles/profile-rtjar-includes-nopkgs.txt Wed Sep 11 14:50:11 2013 -0700 8.3 @@ -0,0 +1,41 @@ 8.4 +PROFILE_1_RTJAR_INCLUDE_PACKAGES := 8.5 + 8.6 +PROFILE_1_RTJAR_INCLUDE_TYPES := 8.7 + 8.8 +PROFILE_1_RTJAR_EXCLUDE_TYPES := 8.9 + 8.10 +PROFILE_1_INCLUDE_METAINF_SERVICES := 8.11 + 8.12 + 8.13 +PROFILE_2_RTJAR_INCLUDE_PACKAGES := \ 8.14 + pkg4 \ 8.15 + pkgDeprecated 8.16 + 8.17 +PROFILE_2_RTJAR_INCLUDE_TYPES := 8.18 + 8.19 +PROFILE_2_RTJAR_EXCLUDE_TYPES := \ 8.20 + pkg4/Anno1Pkg4.class 8.21 + 8.22 +PROFILE_2_INCLUDE_METAINF_SERVICES := 8.23 + 8.24 + 8.25 +PROFILE_3_RTJAR_INCLUDE_PACKAGES := \ 8.26 + pkg5 8.27 + 8.28 +PROFILE_3_RTJAR_INCLUDE_TYPES := 8.29 + 8.30 +PROFILE_3_RTJAR_EXCLUDE_TYPES := 8.31 + 8.32 +PROFILE_3_INCLUDE_METAINF_SERVICES := 8.33 + 8.34 + 8.35 +PROFILE_4_RTJAR_INCLUDE_PACKAGES := \ 8.36 + pkg1 8.37 + 8.38 +PROFILE_4_RTJAR_INCLUDE_TYPES := 8.39 + 8.40 +PROFILE_4_RTJAR_EXCLUDE_TYPES := 8.41 + 8.42 +PROFILE_4_INCLUDE_METAINF_SERVICES := 8.43 + 8.44 +