changeset 2856:cf37c3775397

8015496: Information that package is deprecated is missing in profiles view Reviewed-by: jjg
author bpatel
date Wed, 11 Sep 2013 14:50:11 -0700
parents 65c218b25b61
children 5d2d484a1216
files src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java test/com/sun/javadoc/testProfiles/profile-rtjar-includes-nopkgs.txt
diffstat 8 files changed, 147 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java	Wed Sep 11 08:30:58 2013 -0400
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java	Wed Sep 11 14:50:11 2013 -0700
@@ -157,7 +157,7 @@
                 addAllProfilesLink(div);
             }
             body.addContent(div);
-            if (configuration.showProfiles) {
+            if (configuration.showProfiles && configuration.profilePackages.size() > 0) {
                 Content profileSummary = configuration.getResource("doclet.Profiles");
                 addProfilesList(profileSummary, body);
             }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java	Wed Sep 11 08:30:58 2013 -0400
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java	Wed Sep 11 14:50:11 2013 -0700
@@ -205,13 +205,20 @@
      * {@inheritDoc}
      */
     protected void generateProfileFiles() throws Exception {
-        if (configuration.showProfiles) {
+        if (configuration.showProfiles && configuration.profilePackages.size() > 0) {
             ProfileIndexFrameWriter.generate(configuration);
             Profile prevProfile = null, nextProfile;
+            String profileName;
             for (int i = 1; i < configuration.profiles.getProfileCount(); i++) {
-                ProfilePackageIndexFrameWriter.generate(configuration, Profile.lookup(i).name);
+                profileName = Profile.lookup(i).name;
+                // Generate profile package pages only if there are any packages
+                // in a profile to be documented. The profilePackages map will not
+                // contain an entry for the profile if there are no packages to be documented.
+                if (!configuration.shouldDocumentProfile(profileName))
+                    continue;
+                ProfilePackageIndexFrameWriter.generate(configuration, profileName);
                 PackageDoc[] packages = configuration.profilePackages.get(
-                        Profile.lookup(i).name);
+                        profileName);
                 PackageDoc prev = null, next;
                 for (int j = 0; j < packages.length; j++) {
                     // if -nodeprecated option is set and the package is marked as
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java	Wed Sep 11 08:30:58 2013 -0400
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java	Wed Sep 11 14:50:11 2013 -0700
@@ -130,10 +130,14 @@
         String profileName;
         for (int i = 1; i < configuration.profiles.getProfileCount(); i++) {
             profileName = Profile.lookup(i).name;
-            Content profileLinkContent = getTargetProfileLink("classFrame",
-                    new StringContent(profileName), profileName);
-            Content li = HtmlTree.LI(profileLinkContent);
-            ul.addContent(li);
+            // If the profile has valid packages to be documented, add it to the
+            // profiles list on overview-summary.html page.
+            if (configuration.shouldDocumentProfile(profileName)) {
+                Content profileLinkContent = getTargetProfileLink("classFrame",
+                        new StringContent(profileName), profileName);
+                Content li = HtmlTree.LI(profileLinkContent);
+                ul.addContent(li);
+            }
         }
         profilesDiv.addContent(ul);
         Content div = HtmlTree.DIV(HtmlStyle.contentContainer, profilesDiv);
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java	Wed Sep 11 08:30:58 2013 -0400
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java	Wed Sep 11 14:50:11 2013 -0700
@@ -88,8 +88,13 @@
         Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
         HtmlTree ul = new HtmlTree(HtmlTag.UL);
         ul.setTitle(profilesLabel);
+        String profileName;
         for (int i = 1; i < profiles.getProfileCount(); i++) {
-            ul.addContent(getProfile(i));
+            profileName = (Profile.lookup(i)).name;
+            // If the profile has valid packages to be documented, add it to the
+            // left-frame generated for profile index.
+            if (configuration.shouldDocumentProfile(profileName))
+                ul.addContent(getProfile(profileName));
         }
         div.addContent(ul);
         body.addContent(div);
@@ -98,13 +103,12 @@
     /**
      * Gets each profile name as a separate link.
      *
-     * @param profile the profile being documented
+     * @param profileName the profile being documented
      * @return content for the profile link
      */
-    protected Content getProfile(int profile) {
+    protected Content getProfile(String profileName) {
         Content profileLinkContent;
         Content profileLabel;
-        String profileName = (Profile.lookup(profile)).name;
         profileLabel = new StringContent(profileName);
         profileLinkContent = getHyperLink(DocPaths.profileFrame(profileName), profileLabel, "",
                     "packageListFrame");
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java	Wed Sep 11 08:30:58 2013 -0400
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java	Wed Sep 11 14:50:11 2013 -0700
@@ -138,6 +138,7 @@
                     "classFrame", new StringContent(pkg.name()), profile.name);
         Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName);
         HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading);
+        addPackageDeprecationInfo(li, pkg);
         return li;
     }
 
@@ -175,6 +176,30 @@
     }
 
     /**
+     * Add the profile package deprecation information to the documentation tree.
+     *
+     * @param li the content tree to which the deprecation information will be added
+     * @param pkg the PackageDoc that is added
+     */
+    public void addPackageDeprecationInfo(Content li, PackageDoc pkg) {
+        Tag[] deprs;
+        if (Util.isDeprecated(pkg)) {
+            deprs = pkg.tags("deprecated");
+            HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
+            deprDiv.addStyle(HtmlStyle.deprecatedContent);
+            Content deprPhrase = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
+            deprDiv.addContent(deprPhrase);
+            if (deprs.length > 0) {
+                Tag[] commentTags = deprs[0].inlineTags();
+                if (commentTags.length > 0) {
+                    addInlineDeprecatedComment(pkg, deprs[0], deprDiv);
+                }
+            }
+            li.addContent(deprDiv);
+        }
+    }
+
+    /**
      * Get "PREV PROFILE" link in the navigation bar.
      *
      * @return a content tree for the previous link
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Wed Sep 11 08:30:58 2013 -0400
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Wed Sep 11 14:50:11 2013 -0700
@@ -396,6 +396,9 @@
             interimResults.put(p, new ArrayList<PackageDoc>());
 
         for (PackageDoc pkg: packages) {
+            if (nodeprecated && Util.isDeprecated(pkg)) {
+                continue;
+            }
             // the getProfile method takes a type name, not a package name,
             // but isn't particularly fussy about the simple name -- so just use *
             int i = profiles.getProfile(pkg.name().replace(".", "/") + "/*");
@@ -409,12 +412,17 @@
         // Build the profilePackages structure used by the doclet
         profilePackages = new HashMap<String,PackageDoc[]>();
         List<PackageDoc> prev = Collections.<PackageDoc>emptyList();
+        int size;
         for (Map.Entry<Profile,List<PackageDoc>> e: interimResults.entrySet()) {
             Profile p = e.getKey();
             List<PackageDoc> pkgs =  e.getValue();
             pkgs.addAll(prev); // each profile contains all lower profiles
             Collections.sort(pkgs);
-            profilePackages.put(p.name, pkgs.toArray(new PackageDoc[pkgs.size()]));
+            size = pkgs.size();
+            // For a profile, if there are no packages to be documented, do not add
+            // it to profilePackages map.
+            if (size > 0)
+                profilePackages.put(p.name, pkgs.toArray(new PackageDoc[pkgs.size()]));
             prev = pkgs;
         }
 
@@ -719,6 +727,17 @@
     }
 
     /**
+     * Check the validity of the given profile. Return false if there are no
+     * valid packages to be documented for the profile.
+     *
+     * @param profileName the profile that needs to be validated.
+     * @return true if the profile has valid packages to be documented.
+     */
+    public boolean shouldDocumentProfile(String profileName) {
+        return profilePackages.containsKey(profileName);
+    }
+
+    /**
      * Check the validity of the given Source or Output File encoding on this
      * platform.
      *
--- a/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java	Wed Sep 11 08:30:58 2013 -0400
+++ b/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java	Wed Sep 11 14:50:11 2013 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      8006124 8009684 8015663
+ * @bug      8006124 8009684 8015663 8015496
  * @summary  Test javadoc options support for profiles.
  * @author   Evgeniya Stepanova
  * @library  ../lib/
@@ -35,6 +35,7 @@
     //Test information.
     private static final String BUG_ID = "8006124-8009684";
     private static final String PROFILE_CONFIGURATION_BUG_ID = BUG_ID + "-3";
+    private static final String NODEPR_NOPKGS_BUG_ID = BUG_ID + "-4";
     //Javadoc arguments.
     private static final String[] ARGS3 = new String[]{
         "-d", PROFILE_CONFIGURATION_BUG_ID, "-sourcepath", SRC_DIR, "-nocomment",
@@ -42,6 +43,30 @@
         "-doctitle", "Simple doctitle", "-use", "pkg3", "pkg1", "pkg2", "pkg4",
         "pkg5", "-packagesheader", "Simple packages header","pkgDeprecated"
     };
+    private static final String[] ARGS4 = new String[]{
+        "-d", NODEPR_NOPKGS_BUG_ID, "-sourcepath", SRC_DIR, "-nocomment", "-nodeprecated",
+        "-keywords", "-Xprofilespath", SRC_DIR + FS + "profile-rtjar-includes-nopkgs.txt",
+        "-doctitle", "Simple doctitle", "-use", "-packagesheader", "Simple packages header",
+        "pkg1", "pkg2", "pkg3", "pkg4", "pkg5", "pkgDeprecated"
+    };
+    private static final String[][] NODEPR_NOPKGS_TEST = {
+        {NODEPR_NOPKGS_BUG_ID + FS + "overview-summary.html",
+            "<ul>" + NL + "<li><a href=\"compact2-summary.html\" target=\"classFrame\">" +
+            "compact2</a></li>" + NL + "<li><a href=\"compact3-summary.html\" target=\"" +
+            "classFrame\">compact3</a></li>" + NL + "</ul>"
+        },
+        {NODEPR_NOPKGS_BUG_ID + FS + "profile-overview-frame.html",
+            "<ul title=\"Profiles\">" + NL + "<li><a href=\"compact2-frame.html\" target=\"packageListFrame\">" +
+            "compact2</a></li>" + NL + "<li><a href=\"compact3-frame.html\" target=\"" +
+            "packageListFrame\">compact3</a></li>" + NL + "</ul>"
+        }
+    };
+    private static final String[][] NODEPR_NOPKGS_NEGATED_TEST = {
+        {NODEPR_NOPKGS_BUG_ID + FS + "overview-summary.html",
+            "compact1"
+        }
+    };
+
     private static final String[][] PROFILES_CONFIGURATION_TEST = {
         //-use option test string fo profile view page
         {PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html","<li>Use</li>"
@@ -57,6 +82,12 @@
         //-keywords option test string for profiles
         {PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html",
             "<meta name=\"keywords\" content=\"compact1 profile\">"
+        },
+        //Deprecated information on a package
+        {PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html",
+            "<h3><a href=\"pkgDeprecated/compact1-package-summary.html\" target=\"" +
+            "classFrame\">pkgDeprecated</a></h3>" + NL + "<div class=\"deprecatedContent\">" +
+            "<span class=\"strong\">Deprecated.</span></div>"
         }
     };
     private static final String[][] PROFILES_CONFIGURATION_NEGATED_TEST = {
@@ -75,6 +106,8 @@
         TestProfilesConfiguration tester = new TestProfilesConfiguration();
         run(tester, ARGS3, PROFILES_CONFIGURATION_TEST,
         PROFILES_CONFIGURATION_NEGATED_TEST);
+        run(tester, ARGS4, NODEPR_NOPKGS_TEST,
+        NODEPR_NOPKGS_NEGATED_TEST);
         tester.printSummary();
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testProfiles/profile-rtjar-includes-nopkgs.txt	Wed Sep 11 14:50:11 2013 -0700
@@ -0,0 +1,41 @@
+PROFILE_1_RTJAR_INCLUDE_PACKAGES := 
+
+PROFILE_1_RTJAR_INCLUDE_TYPES := 
+
+PROFILE_1_RTJAR_EXCLUDE_TYPES := 
+
+PROFILE_1_INCLUDE_METAINF_SERVICES := 
+
+
+PROFILE_2_RTJAR_INCLUDE_PACKAGES := \
+    pkg4 \
+    pkgDeprecated 
+
+PROFILE_2_RTJAR_INCLUDE_TYPES := 
+
+PROFILE_2_RTJAR_EXCLUDE_TYPES := \
+    pkg4/Anno1Pkg4.class 
+
+PROFILE_2_INCLUDE_METAINF_SERVICES := 
+
+
+PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
+    pkg5 
+
+PROFILE_3_RTJAR_INCLUDE_TYPES := 
+
+PROFILE_3_RTJAR_EXCLUDE_TYPES := 
+
+PROFILE_3_INCLUDE_METAINF_SERVICES := 
+
+
+PROFILE_4_RTJAR_INCLUDE_PACKAGES := \
+    pkg1 
+
+PROFILE_4_RTJAR_INCLUDE_TYPES := 
+
+PROFILE_4_RTJAR_EXCLUDE_TYPES := 
+
+PROFILE_4_INCLUDE_METAINF_SERVICES :=  
+
+