Thu, 31 Aug 2017 15:17:03 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.tools.doclets.formats.html; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import java.io.*; |
aoqi@0 | 29 | import java.util.*; |
aoqi@0 | 30 | |
aoqi@0 | 31 | import com.sun.javadoc.*; |
aoqi@0 | 32 | import com.sun.tools.javac.jvm.Profile; |
aoqi@0 | 33 | import com.sun.tools.doclets.formats.html.markup.*; |
aoqi@0 | 34 | import com.sun.tools.doclets.internal.toolkit.*; |
aoqi@0 | 35 | import com.sun.tools.doclets.internal.toolkit.util.*; |
aoqi@0 | 36 | |
aoqi@0 | 37 | /** |
aoqi@0 | 38 | * Class to generate file for each profile package contents in the right-hand |
aoqi@0 | 39 | * frame. This will list all the Class Kinds in the package. A click on any |
aoqi@0 | 40 | * class-kind will update the frame with the clicked class-kind page. |
aoqi@0 | 41 | * |
aoqi@0 | 42 | * <p><b>This is NOT part of any supported API. |
aoqi@0 | 43 | * If you write code that depends on this, you do so at your own risk. |
aoqi@0 | 44 | * This code and its internal interfaces are subject to change or |
aoqi@0 | 45 | * deletion without notice.</b> |
aoqi@0 | 46 | * |
aoqi@0 | 47 | * @author Bhavesh Patel |
aoqi@0 | 48 | */ |
aoqi@0 | 49 | public class ProfilePackageWriterImpl extends HtmlDocletWriter |
aoqi@0 | 50 | implements ProfilePackageSummaryWriter { |
aoqi@0 | 51 | |
aoqi@0 | 52 | /** |
aoqi@0 | 53 | * The prev package name in the alpha-order list. |
aoqi@0 | 54 | */ |
aoqi@0 | 55 | protected PackageDoc prev; |
aoqi@0 | 56 | |
aoqi@0 | 57 | /** |
aoqi@0 | 58 | * The next package name in the alpha-order list. |
aoqi@0 | 59 | */ |
aoqi@0 | 60 | protected PackageDoc next; |
aoqi@0 | 61 | |
aoqi@0 | 62 | /** |
aoqi@0 | 63 | * The profile package being documented. |
aoqi@0 | 64 | */ |
aoqi@0 | 65 | protected PackageDoc packageDoc; |
aoqi@0 | 66 | |
aoqi@0 | 67 | /** |
aoqi@0 | 68 | * The name of the profile being documented. |
aoqi@0 | 69 | */ |
aoqi@0 | 70 | protected String profileName; |
aoqi@0 | 71 | |
aoqi@0 | 72 | /** |
aoqi@0 | 73 | * The value of the profile being documented. |
aoqi@0 | 74 | */ |
aoqi@0 | 75 | protected int profileValue; |
aoqi@0 | 76 | |
aoqi@0 | 77 | /** |
aoqi@0 | 78 | * Constructor to construct ProfilePackageWriter object and to generate |
aoqi@0 | 79 | * "profilename-package-summary.html" file in the respective package directory. |
aoqi@0 | 80 | * For example for profile compact1 and package "java.lang" this will generate file |
aoqi@0 | 81 | * "compact1-package-summary.html" file in the "java/lang" directory. It will also |
aoqi@0 | 82 | * create "java/lang" directory in the current or the destination directory |
aoqi@0 | 83 | * if it doesn't exist. |
aoqi@0 | 84 | * |
aoqi@0 | 85 | * @param configuration the configuration of the doclet. |
aoqi@0 | 86 | * @param packageDoc PackageDoc under consideration. |
aoqi@0 | 87 | * @param prev Previous package in the sorted array. |
aoqi@0 | 88 | * @param next Next package in the sorted array. |
aoqi@0 | 89 | * @param profile The profile being documented. |
aoqi@0 | 90 | */ |
aoqi@0 | 91 | public ProfilePackageWriterImpl(ConfigurationImpl configuration, |
aoqi@0 | 92 | PackageDoc packageDoc, PackageDoc prev, PackageDoc next, |
aoqi@0 | 93 | Profile profile) throws IOException { |
aoqi@0 | 94 | super(configuration, DocPath.forPackage(packageDoc).resolve( |
aoqi@0 | 95 | DocPaths.profilePackageSummary(profile.name))); |
aoqi@0 | 96 | this.prev = prev; |
aoqi@0 | 97 | this.next = next; |
aoqi@0 | 98 | this.packageDoc = packageDoc; |
aoqi@0 | 99 | this.profileName = profile.name; |
aoqi@0 | 100 | this.profileValue = profile.value; |
aoqi@0 | 101 | } |
aoqi@0 | 102 | |
aoqi@0 | 103 | /** |
aoqi@0 | 104 | * {@inheritDoc} |
aoqi@0 | 105 | */ |
aoqi@0 | 106 | public Content getPackageHeader(String heading) { |
aoqi@0 | 107 | String pkgName = packageDoc.name(); |
aoqi@0 | 108 | Content bodyTree = getBody(true, getWindowTitle(pkgName)); |
aoqi@0 | 109 | addTop(bodyTree); |
aoqi@0 | 110 | addNavLinks(true, bodyTree); |
aoqi@0 | 111 | HtmlTree div = new HtmlTree(HtmlTag.DIV); |
aoqi@0 | 112 | div.addStyle(HtmlStyle.header); |
aoqi@0 | 113 | Content profileContent = new StringContent(profileName); |
aoqi@0 | 114 | Content profileNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, profileContent); |
aoqi@0 | 115 | div.addContent(profileNameDiv); |
aoqi@0 | 116 | Content annotationContent = new HtmlTree(HtmlTag.P); |
aoqi@0 | 117 | addAnnotationInfo(packageDoc, annotationContent); |
aoqi@0 | 118 | div.addContent(annotationContent); |
aoqi@0 | 119 | Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, |
aoqi@0 | 120 | HtmlStyle.title, packageLabel); |
aoqi@0 | 121 | tHeading.addContent(getSpace()); |
aoqi@0 | 122 | Content packageHead = new RawHtml(heading); |
aoqi@0 | 123 | tHeading.addContent(packageHead); |
aoqi@0 | 124 | div.addContent(tHeading); |
aoqi@0 | 125 | addDeprecationInfo(div); |
aoqi@0 | 126 | if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) { |
aoqi@0 | 127 | HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV); |
aoqi@0 | 128 | docSummaryDiv.addStyle(HtmlStyle.docSummary); |
aoqi@0 | 129 | addSummaryComment(packageDoc, docSummaryDiv); |
aoqi@0 | 130 | div.addContent(docSummaryDiv); |
aoqi@0 | 131 | Content space = getSpace(); |
aoqi@0 | 132 | Content descLink = getHyperLink(getDocLink( |
aoqi@0 | 133 | SectionName.PACKAGE_DESCRIPTION), |
aoqi@0 | 134 | descriptionLabel, "", ""); |
aoqi@0 | 135 | Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink); |
aoqi@0 | 136 | div.addContent(descPara); |
aoqi@0 | 137 | } |
aoqi@0 | 138 | bodyTree.addContent(div); |
aoqi@0 | 139 | return bodyTree; |
aoqi@0 | 140 | } |
aoqi@0 | 141 | |
aoqi@0 | 142 | /** |
aoqi@0 | 143 | * {@inheritDoc} |
aoqi@0 | 144 | */ |
aoqi@0 | 145 | public Content getContentHeader() { |
aoqi@0 | 146 | HtmlTree div = new HtmlTree(HtmlTag.DIV); |
aoqi@0 | 147 | div.addStyle(HtmlStyle.contentContainer); |
aoqi@0 | 148 | return div; |
aoqi@0 | 149 | } |
aoqi@0 | 150 | |
aoqi@0 | 151 | /** |
aoqi@0 | 152 | * Add the package deprecation information to the documentation tree. |
aoqi@0 | 153 | * |
aoqi@0 | 154 | * @param div the content tree to which the deprecation information will be added |
aoqi@0 | 155 | */ |
aoqi@0 | 156 | public void addDeprecationInfo(Content div) { |
aoqi@0 | 157 | Tag[] deprs = packageDoc.tags("deprecated"); |
aoqi@0 | 158 | if (Util.isDeprecated(packageDoc)) { |
aoqi@0 | 159 | HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); |
aoqi@0 | 160 | deprDiv.addStyle(HtmlStyle.deprecatedContent); |
aoqi@0 | 161 | Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); |
aoqi@0 | 162 | deprDiv.addContent(deprPhrase); |
aoqi@0 | 163 | if (deprs.length > 0) { |
aoqi@0 | 164 | Tag[] commentTags = deprs[0].inlineTags(); |
aoqi@0 | 165 | if (commentTags.length > 0) { |
aoqi@0 | 166 | addInlineDeprecatedComment(packageDoc, deprs[0], deprDiv); |
aoqi@0 | 167 | } |
aoqi@0 | 168 | } |
aoqi@0 | 169 | div.addContent(deprDiv); |
aoqi@0 | 170 | } |
aoqi@0 | 171 | } |
aoqi@0 | 172 | |
aoqi@0 | 173 | /** |
aoqi@0 | 174 | * {@inheritDoc} |
aoqi@0 | 175 | */ |
aoqi@0 | 176 | public void addClassesSummary(ClassDoc[] classes, String label, |
aoqi@0 | 177 | String tableSummary, String[] tableHeader, Content packageSummaryContentTree) { |
aoqi@0 | 178 | HtmlTree li = new HtmlTree(HtmlTag.LI); |
aoqi@0 | 179 | li.addStyle(HtmlStyle.blockList); |
aoqi@0 | 180 | addClassesSummary(classes, label, tableSummary, tableHeader, |
aoqi@0 | 181 | li, profileValue); |
aoqi@0 | 182 | packageSummaryContentTree.addContent(li); |
aoqi@0 | 183 | } |
aoqi@0 | 184 | |
aoqi@0 | 185 | /** |
aoqi@0 | 186 | * {@inheritDoc} |
aoqi@0 | 187 | */ |
aoqi@0 | 188 | public Content getSummaryHeader() { |
aoqi@0 | 189 | HtmlTree ul = new HtmlTree(HtmlTag.UL); |
aoqi@0 | 190 | ul.addStyle(HtmlStyle.blockList); |
aoqi@0 | 191 | return ul; |
aoqi@0 | 192 | } |
aoqi@0 | 193 | |
aoqi@0 | 194 | /** |
aoqi@0 | 195 | * {@inheritDoc} |
aoqi@0 | 196 | */ |
aoqi@0 | 197 | public void addPackageDescription(Content packageContentTree) { |
aoqi@0 | 198 | if (packageDoc.inlineTags().length > 0) { |
aoqi@0 | 199 | packageContentTree.addContent( |
aoqi@0 | 200 | getMarkerAnchor(SectionName.PACKAGE_DESCRIPTION)); |
aoqi@0 | 201 | Content h2Content = new StringContent( |
aoqi@0 | 202 | configuration.getText("doclet.Package_Description", |
aoqi@0 | 203 | packageDoc.name())); |
aoqi@0 | 204 | packageContentTree.addContent(HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, |
aoqi@0 | 205 | true, h2Content)); |
aoqi@0 | 206 | addInlineComment(packageDoc, packageContentTree); |
aoqi@0 | 207 | } |
aoqi@0 | 208 | } |
aoqi@0 | 209 | |
aoqi@0 | 210 | /** |
aoqi@0 | 211 | * {@inheritDoc} |
aoqi@0 | 212 | */ |
aoqi@0 | 213 | public void addPackageTags(Content packageContentTree) { |
aoqi@0 | 214 | addTagsInfo(packageDoc, packageContentTree); |
aoqi@0 | 215 | } |
aoqi@0 | 216 | |
aoqi@0 | 217 | /** |
aoqi@0 | 218 | * {@inheritDoc} |
aoqi@0 | 219 | */ |
aoqi@0 | 220 | public void addPackageFooter(Content contentTree) { |
aoqi@0 | 221 | addNavLinks(false, contentTree); |
aoqi@0 | 222 | addBottom(contentTree); |
aoqi@0 | 223 | } |
aoqi@0 | 224 | |
aoqi@0 | 225 | /** |
aoqi@0 | 226 | * {@inheritDoc} |
aoqi@0 | 227 | */ |
aoqi@0 | 228 | public void printDocument(Content contentTree) throws IOException { |
aoqi@0 | 229 | printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageDoc), |
aoqi@0 | 230 | true, contentTree); |
aoqi@0 | 231 | } |
aoqi@0 | 232 | |
aoqi@0 | 233 | /** |
aoqi@0 | 234 | * Get "Use" link for this package in the navigation bar. |
aoqi@0 | 235 | * |
aoqi@0 | 236 | * @return a content tree for the class use link |
aoqi@0 | 237 | */ |
aoqi@0 | 238 | protected Content getNavLinkClassUse() { |
aoqi@0 | 239 | Content useLink = getHyperLink(DocPaths.PACKAGE_USE, |
aoqi@0 | 240 | useLabel, "", ""); |
aoqi@0 | 241 | Content li = HtmlTree.LI(useLink); |
aoqi@0 | 242 | return li; |
aoqi@0 | 243 | } |
aoqi@0 | 244 | |
aoqi@0 | 245 | /** |
aoqi@0 | 246 | * Get "PREV PACKAGE" link in the navigation bar. |
aoqi@0 | 247 | * |
aoqi@0 | 248 | * @return a content tree for the previous link |
aoqi@0 | 249 | */ |
aoqi@0 | 250 | public Content getNavLinkPrevious() { |
aoqi@0 | 251 | Content li; |
aoqi@0 | 252 | if (prev == null) { |
aoqi@0 | 253 | li = HtmlTree.LI(prevpackageLabel); |
aoqi@0 | 254 | } else { |
aoqi@0 | 255 | DocPath path = DocPath.relativePath(packageDoc, prev); |
aoqi@0 | 256 | li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.profilePackageSummary(profileName)), |
aoqi@0 | 257 | prevpackageLabel, "", "")); |
aoqi@0 | 258 | } |
aoqi@0 | 259 | return li; |
aoqi@0 | 260 | } |
aoqi@0 | 261 | |
aoqi@0 | 262 | /** |
aoqi@0 | 263 | * Get "NEXT PACKAGE" link in the navigation bar. |
aoqi@0 | 264 | * |
aoqi@0 | 265 | * @return a content tree for the next link |
aoqi@0 | 266 | */ |
aoqi@0 | 267 | public Content getNavLinkNext() { |
aoqi@0 | 268 | Content li; |
aoqi@0 | 269 | if (next == null) { |
aoqi@0 | 270 | li = HtmlTree.LI(nextpackageLabel); |
aoqi@0 | 271 | } else { |
aoqi@0 | 272 | DocPath path = DocPath.relativePath(packageDoc, next); |
aoqi@0 | 273 | li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.profilePackageSummary(profileName)), |
aoqi@0 | 274 | nextpackageLabel, "", "")); |
aoqi@0 | 275 | } |
aoqi@0 | 276 | return li; |
aoqi@0 | 277 | } |
aoqi@0 | 278 | |
aoqi@0 | 279 | /** |
aoqi@0 | 280 | * Get "Tree" link in the navigation bar. This will be link to the package |
aoqi@0 | 281 | * tree file. |
aoqi@0 | 282 | * |
aoqi@0 | 283 | * @return a content tree for the tree link |
aoqi@0 | 284 | */ |
aoqi@0 | 285 | protected Content getNavLinkTree() { |
aoqi@0 | 286 | Content useLink = getHyperLink(DocPaths.PACKAGE_TREE, |
aoqi@0 | 287 | treeLabel, "", ""); |
aoqi@0 | 288 | Content li = HtmlTree.LI(useLink); |
aoqi@0 | 289 | return li; |
aoqi@0 | 290 | } |
aoqi@0 | 291 | |
aoqi@0 | 292 | /** |
aoqi@0 | 293 | * Highlight "Package" in the navigation bar, as this is the package page. |
aoqi@0 | 294 | * |
aoqi@0 | 295 | * @return a content tree for the package link |
aoqi@0 | 296 | */ |
aoqi@0 | 297 | protected Content getNavLinkPackage() { |
aoqi@0 | 298 | Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel); |
aoqi@0 | 299 | return li; |
aoqi@0 | 300 | } |
aoqi@0 | 301 | } |