src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java

Wed, 10 Oct 2012 16:48:21 -0700

author
jjg
date
Wed, 10 Oct 2012 16:48:21 -0700
changeset 1359
25e14ad23cef
parent 1357
c75be5bc5283
child 1364
8db45b13526e
permissions
-rw-r--r--

8000665: fix "internal API" comments on javadoc files
Reviewed-by: darcy

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

mercurial