src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2015, 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. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2016, 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. Oracle designates this
*** 21,40 ****
* 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 com.sun.tools.doclets.formats.html;
import java.io.*;
import java.util.*;
! import com.sun.javadoc.*;
! import com.sun.tools.doclets.formats.html.markup.*;
! import com.sun.tools.doclets.internal.toolkit.*;
! import com.sun.tools.doclets.internal.toolkit.util.*;
/**
* Class to generate file for each package contents in the right-hand
* frame. This will list all the Class Kinds in the package. A click on any
* class-kind will update the frame with the clicked class-kind page.
*
--- 21,51 ----
* 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 jdk.javadoc.internal.doclets.formats.html;
import java.io.*;
import java.util.*;
! import javax.lang.model.element.PackageElement;
! import javax.lang.model.element.TypeElement;
+ import com.sun.source.doctree.DocTree;
+ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+ import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
+ import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+ import jdk.javadoc.internal.doclets.toolkit.Content;
+ import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
+ import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
+ import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+ import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+
/**
* Class to generate file for each package contents in the right-hand
* frame. This will list all the Class Kinds in the package. A click on any
* class-kind will update the frame with the clicked class-kind page.
*
*** 50,70 ****
implements PackageSummaryWriter {
/**
* The prev package name in the alpha-order list.
*/
! protected PackageDoc prev;
/**
* The next package name in the alpha-order list.
*/
! protected PackageDoc next;
/**
* The package being documented.
*/
! protected PackageDoc packageDoc;
/**
* The HTML tree for main tag.
*/
protected HtmlTree mainTree = HtmlTree.MAIN();
--- 61,81 ----
implements PackageSummaryWriter {
/**
* The prev package name in the alpha-order list.
*/
! protected PackageElement prev;
/**
* The next package name in the alpha-order list.
*/
! protected PackageElement next;
/**
* The package being documented.
*/
! protected PackageElement packageElement;
/**
* The HTML tree for main tag.
*/
protected HtmlTree mainTree = HtmlTree.MAIN();
*** 81,108 ****
* "package-summary.html" file in the "java/lang" directory. It will also
* create "java/lang" directory in the current or the destination directory
* if it doesn't exist.
*
* @param configuration the configuration of the doclet.
! * @param packageDoc PackageDoc under consideration.
* @param prev Previous package in the sorted array.
* @param next Next package in the sorted array.
*/
public PackageWriterImpl(ConfigurationImpl configuration,
! PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
throws IOException {
! super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_SUMMARY));
this.prev = prev;
this.next = next;
! this.packageDoc = packageDoc;
}
/**
* {@inheritDoc}
*/
public Content getPackageHeader(String heading) {
! HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getPackageName(packageDoc)));
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
? HtmlTree.HEADER()
: bodyTree;
addTop(htmlTree);
addNavLinks(true, htmlTree);
--- 92,121 ----
* "package-summary.html" file in the "java/lang" directory. It will also
* create "java/lang" directory in the current or the destination directory
* if it doesn't exist.
*
* @param configuration the configuration of the doclet.
! * @param packageElement PackageElement under consideration.
* @param prev Previous package in the sorted array.
* @param next Next package in the sorted array.
*/
public PackageWriterImpl(ConfigurationImpl configuration,
! PackageElement packageElement, PackageElement prev, PackageElement next)
throws IOException {
! super(configuration, DocPath
! .forPackage(packageElement)
! .resolve(DocPaths.PACKAGE_SUMMARY));
this.prev = prev;
this.next = next;
! this.packageElement = packageElement;
}
/**
* {@inheritDoc}
*/
public Content getPackageHeader(String heading) {
! HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getPackageName(packageElement)));
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
? HtmlTree.HEADER()
: bodyTree;
addTop(htmlTree);
addNavLinks(true, htmlTree);
*** 110,132 ****
bodyTree.addContent(htmlTree);
}
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.header);
Content annotationContent = new HtmlTree(HtmlTag.P);
! addAnnotationInfo(packageDoc, annotationContent);
div.addContent(annotationContent);
Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
HtmlStyle.title, packageLabel);
tHeading.addContent(getSpace());
Content packageHead = new StringContent(heading);
tHeading.addContent(packageHead);
div.addContent(tHeading);
addDeprecationInfo(div);
! if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) {
HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV);
docSummaryDiv.addStyle(HtmlStyle.docSummary);
! addSummaryComment(packageDoc, docSummaryDiv);
div.addContent(docSummaryDiv);
Content space = getSpace();
Content descLink = getHyperLink(getDocLink(
SectionName.PACKAGE_DESCRIPTION),
descriptionLabel, "", "");
--- 123,145 ----
bodyTree.addContent(htmlTree);
}
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.header);
Content annotationContent = new HtmlTree(HtmlTag.P);
! addAnnotationInfo(packageElement, annotationContent);
div.addContent(annotationContent);
Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
HtmlStyle.title, packageLabel);
tHeading.addContent(getSpace());
Content packageHead = new StringContent(heading);
tHeading.addContent(packageHead);
div.addContent(tHeading);
addDeprecationInfo(div);
! if (!utils.getBody(packageElement).isEmpty() && !configuration.nocomment) {
HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV);
docSummaryDiv.addStyle(HtmlStyle.docSummary);
! addSummaryComment(packageElement, docSummaryDiv);
div.addContent(docSummaryDiv);
Content space = getSpace();
Content descLink = getHyperLink(getDocLink(
SectionName.PACKAGE_DESCRIPTION),
descriptionLabel, "", "");
*** 154,173 ****
* Add the package deprecation information to the documentation tree.
*
* @param div the content tree to which the deprecation information will be added
*/
public void addDeprecationInfo(Content div) {
! Tag[] deprs = packageDoc.tags("deprecated");
! if (utils.isDeprecated(packageDoc)) {
HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
deprDiv.addStyle(HtmlStyle.deprecatedContent);
Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
deprDiv.addContent(deprPhrase);
! if (deprs.length > 0) {
! Tag[] commentTags = deprs[0].inlineTags();
! if (commentTags.length > 0) {
! addInlineDeprecatedComment(packageDoc, deprs[0], deprDiv);
}
}
div.addContent(deprDiv);
}
}
--- 167,187 ----
* Add the package deprecation information to the documentation tree.
*
* @param div the content tree to which the deprecation information will be added
*/
public void addDeprecationInfo(Content div) {
! List<? extends DocTree> deprs = utils.getBlockTags(packageElement, DocTree.Kind.DEPRECATED);
! if (utils.isDeprecated(packageElement)) {
! CommentHelper ch = utils.getCommentHelper(packageElement);
HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
deprDiv.addStyle(HtmlStyle.deprecatedContent);
Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
deprDiv.addContent(deprPhrase);
! if (!deprs.isEmpty()) {
! List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
! if (!commentTags.isEmpty()) {
! addInlineDeprecatedComment(packageElement, deprs.get(0), deprDiv);
}
}
div.addContent(deprDiv);
}
}
*** 182,225 ****
}
/**
* {@inheritDoc}
*/
! public void addClassesSummary(ClassDoc[] classes, String label,
! String tableSummary, String[] tableHeader, Content summaryContentTree) {
! if(classes.length > 0) {
! Arrays.sort(classes);
Content caption = getTableCaption(new RawHtml(label));
Content table = (configuration.isOutputHtml5())
? HtmlTree.TABLE(HtmlStyle.typeSummary, caption)
: HtmlTree.TABLE(HtmlStyle.typeSummary, tableSummary, caption);
table.addContent(getSummaryTableHeader(tableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
! for (int i = 0; i < classes.length; i++) {
! if (!utils.isCoreClass(classes[i]) ||
! !configuration.isGeneratedDoc(classes[i])) {
continue;
}
Content classContent = getLink(new LinkInfoImpl(
! configuration, LinkInfoImpl.Kind.PACKAGE, classes[i]));
Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
HtmlTree tr = HtmlTree.TR(tdClass);
! if (i%2 == 0)
! tr.addStyle(HtmlStyle.altColor);
! else
! tr.addStyle(HtmlStyle.rowColor);
HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
tdClassDescription.addStyle(HtmlStyle.colLast);
! if (utils.isDeprecated(classes[i])) {
tdClassDescription.addContent(deprecatedLabel);
! if (classes[i].tags("deprecated").length > 0) {
! addSummaryDeprecatedComment(classes[i],
! classes[i].tags("deprecated")[0], tdClassDescription);
}
}
- else
- addSummaryComment(classes[i], tdClassDescription);
tr.addContent(tdClassDescription);
tbody.addContent(tr);
}
table.addContent(tbody);
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
--- 196,238 ----
}
/**
* {@inheritDoc}
*/
! public void addClassesSummary(SortedSet<TypeElement> classes, String label,
! String tableSummary, List<String> tableHeader, Content summaryContentTree) {
! if(!classes.isEmpty()) {
Content caption = getTableCaption(new RawHtml(label));
Content table = (configuration.isOutputHtml5())
? HtmlTree.TABLE(HtmlStyle.typeSummary, caption)
: HtmlTree.TABLE(HtmlStyle.typeSummary, tableSummary, caption);
table.addContent(getSummaryTableHeader(tableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
! boolean altColor = false;
! for (TypeElement klass : classes) {
! altColor = !altColor;
! if (!utils.isCoreClass(klass) ||
! !configuration.isGeneratedDoc(klass)) {
continue;
}
Content classContent = getLink(new LinkInfoImpl(
! configuration, LinkInfoImpl.Kind.PACKAGE, klass));
Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
HtmlTree tr = HtmlTree.TR(tdClass);
! tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
!
HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
tdClassDescription.addStyle(HtmlStyle.colLast);
! if (utils.isDeprecated(klass)) {
tdClassDescription.addContent(deprecatedLabel);
! List<? extends DocTree> tags = utils.getDeprecatedTrees(klass);
! if (!tags.isEmpty()) {
! addSummaryDeprecatedComment(klass, tags.get(0), tdClassDescription);
}
+ } else {
+ addSummaryComment(klass, tdClassDescription);
}
tr.addContent(tdClassDescription);
tbody.addContent(tr);
}
table.addContent(tbody);
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
*** 229,251 ****
/**
* {@inheritDoc}
*/
public void addPackageDescription(Content packageContentTree) {
! if (packageDoc.inlineTags().length > 0) {
packageContentTree.addContent(
getMarkerAnchor(SectionName.PACKAGE_DESCRIPTION));
Content h2Content = new StringContent(
configuration.getText("doclet.Package_Description",
! packageDoc.name()));
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, h2Content);
if (configuration.allowTag(HtmlTag.SECTION)) {
sectionTree.addContent(heading);
! addInlineComment(packageDoc, sectionTree);
} else {
packageContentTree.addContent(heading);
! addInlineComment(packageDoc, packageContentTree);
}
}
}
/**
--- 242,264 ----
/**
* {@inheritDoc}
*/
public void addPackageDescription(Content packageContentTree) {
! if (!utils.getBody(packageElement).isEmpty()) {
packageContentTree.addContent(
getMarkerAnchor(SectionName.PACKAGE_DESCRIPTION));
Content h2Content = new StringContent(
configuration.getText("doclet.Package_Description",
! packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement)));
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, h2Content);
if (configuration.allowTag(HtmlTag.SECTION)) {
sectionTree.addContent(heading);
! addInlineComment(packageElement, sectionTree);
} else {
packageContentTree.addContent(heading);
! addInlineComment(packageElement, packageContentTree);
}
}
}
/**
*** 253,263 ****
*/
public void addPackageTags(Content packageContentTree) {
Content htmlTree = (configuration.allowTag(HtmlTag.SECTION))
? sectionTree
: packageContentTree;
! addTagsInfo(packageDoc, htmlTree);
}
/**
* {@inheritDoc}
*/
--- 266,276 ----
*/
public void addPackageTags(Content packageContentTree) {
Content htmlTree = (configuration.allowTag(HtmlTag.SECTION))
? sectionTree
: packageContentTree;
! addTagsInfo(packageElement, htmlTree);
}
/**
* {@inheritDoc}
*/
*** 287,297 ****
/**
* {@inheritDoc}
*/
public void printDocument(Content contentTree) throws IOException {
! printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageDoc),
true, contentTree);
}
/**
* Get "Use" link for this pacakge in the navigation bar.
--- 300,310 ----
/**
* {@inheritDoc}
*/
public void printDocument(Content contentTree) throws IOException {
! printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageElement),
true, contentTree);
}
/**
* Get "Use" link for this pacakge in the navigation bar.
*** 313,323 ****
public Content getNavLinkPrevious() {
Content li;
if (prev == null) {
li = HtmlTree.LI(prevpackageLabel);
} else {
! DocPath path = DocPath.relativePath(packageDoc, prev);
li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
prevpackageLabel, "", ""));
}
return li;
}
--- 326,336 ----
public Content getNavLinkPrevious() {
Content li;
if (prev == null) {
li = HtmlTree.LI(prevpackageLabel);
} else {
! DocPath path = DocPath.relativePath(packageElement, prev);
li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
prevpackageLabel, "", ""));
}
return li;
}
*** 330,340 ****
public Content getNavLinkNext() {
Content li;
if (next == null) {
li = HtmlTree.LI(nextpackageLabel);
} else {
! DocPath path = DocPath.relativePath(packageDoc, next);
li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
nextpackageLabel, "", ""));
}
return li;
}
--- 343,353 ----
public Content getNavLinkNext() {
Content li;
if (next == null) {
li = HtmlTree.LI(nextpackageLabel);
} else {
! DocPath path = DocPath.relativePath(packageElement, next);
li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
nextpackageLabel, "", ""));
}
return li;
}