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

Thu, 31 Aug 2017 15:17:03 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:17:03 +0800
changeset 2525
2eb010b6cb22
parent 2147
130b8c0e570e
parent 0
959103a6100f
permissions
-rw-r--r--

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 contents in the right-hand
aoqi@0 39 * frame. This will list all the packages and Class Kinds in the profile. A click on any
aoqi@0 40 * class-kind will update the frame with the clicked class-kind page. A click on any
aoqi@0 41 * package will update the frame with the clicked profile package page.
aoqi@0 42 *
aoqi@0 43 * <p><b>This is NOT part of any supported API.
aoqi@0 44 * If you write code that depends on this, you do so at your own risk.
aoqi@0 45 * This code and its internal interfaces are subject to change or
aoqi@0 46 * deletion without notice.</b>
aoqi@0 47 *
aoqi@0 48 * @author Bhavesh Patel
aoqi@0 49 */
aoqi@0 50 public class ProfileWriterImpl extends HtmlDocletWriter
aoqi@0 51 implements ProfileSummaryWriter {
aoqi@0 52
aoqi@0 53 /**
aoqi@0 54 * The prev profile name in the alpha-order list.
aoqi@0 55 */
aoqi@0 56 protected Profile prevProfile;
aoqi@0 57
aoqi@0 58 /**
aoqi@0 59 * The next profile name in the alpha-order list.
aoqi@0 60 */
aoqi@0 61 protected Profile nextProfile;
aoqi@0 62
aoqi@0 63 /**
aoqi@0 64 * The profile being documented.
aoqi@0 65 */
aoqi@0 66 protected Profile profile;
aoqi@0 67
aoqi@0 68 /**
aoqi@0 69 * Constructor to construct ProfileWriter object and to generate
aoqi@0 70 * "profileName-summary.html" file.
aoqi@0 71 *
aoqi@0 72 * @param configuration the configuration of the doclet.
aoqi@0 73 * @param profile Profile under consideration.
aoqi@0 74 * @param prevProfile Previous profile in the sorted array.
aoqi@0 75 * @param nextProfile Next profile in the sorted array.
aoqi@0 76 */
aoqi@0 77 public ProfileWriterImpl(ConfigurationImpl configuration,
aoqi@0 78 Profile profile, Profile prevProfile, Profile nextProfile)
aoqi@0 79 throws IOException {
aoqi@0 80 super(configuration, DocPaths.profileSummary(profile.name));
aoqi@0 81 this.prevProfile = prevProfile;
aoqi@0 82 this.nextProfile = nextProfile;
aoqi@0 83 this.profile = profile;
aoqi@0 84 }
aoqi@0 85
aoqi@0 86 /**
aoqi@0 87 * {@inheritDoc}
aoqi@0 88 */
aoqi@0 89 public Content getProfileHeader(String heading) {
aoqi@0 90 String profileName = profile.name;
aoqi@0 91 Content bodyTree = getBody(true, getWindowTitle(profileName));
aoqi@0 92 addTop(bodyTree);
aoqi@0 93 addNavLinks(true, bodyTree);
aoqi@0 94 HtmlTree div = new HtmlTree(HtmlTag.DIV);
aoqi@0 95 div.addStyle(HtmlStyle.header);
aoqi@0 96 Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
aoqi@0 97 HtmlStyle.title, profileLabel);
aoqi@0 98 tHeading.addContent(getSpace());
aoqi@0 99 Content profileHead = new RawHtml(heading);
aoqi@0 100 tHeading.addContent(profileHead);
aoqi@0 101 div.addContent(tHeading);
aoqi@0 102 bodyTree.addContent(div);
aoqi@0 103 return bodyTree;
aoqi@0 104 }
aoqi@0 105
aoqi@0 106 /**
aoqi@0 107 * {@inheritDoc}
aoqi@0 108 */
aoqi@0 109 public Content getContentHeader() {
aoqi@0 110 HtmlTree div = new HtmlTree(HtmlTag.DIV);
aoqi@0 111 div.addStyle(HtmlStyle.contentContainer);
aoqi@0 112 return div;
aoqi@0 113 }
aoqi@0 114
aoqi@0 115 /**
aoqi@0 116 * {@inheritDoc}
aoqi@0 117 */
aoqi@0 118 public Content getSummaryHeader() {
aoqi@0 119 HtmlTree li = new HtmlTree(HtmlTag.LI);
aoqi@0 120 li.addStyle(HtmlStyle.blockList);
aoqi@0 121 return li;
aoqi@0 122 }
aoqi@0 123
aoqi@0 124 /**
aoqi@0 125 * {@inheritDoc}
aoqi@0 126 */
aoqi@0 127 public Content getSummaryTree(Content summaryContentTree) {
aoqi@0 128 HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree);
aoqi@0 129 HtmlTree div = HtmlTree.DIV(HtmlStyle.summary, ul);
aoqi@0 130 return div;
aoqi@0 131 }
aoqi@0 132
aoqi@0 133 /**
aoqi@0 134 * {@inheritDoc}
aoqi@0 135 */
aoqi@0 136 public Content getPackageSummaryHeader(PackageDoc pkg) {
aoqi@0 137 Content pkgName = getTargetProfilePackageLink(pkg,
aoqi@0 138 "classFrame", new StringContent(pkg.name()), profile.name);
aoqi@0 139 Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName);
aoqi@0 140 HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading);
aoqi@0 141 addPackageDeprecationInfo(li, pkg);
aoqi@0 142 return li;
aoqi@0 143 }
aoqi@0 144
aoqi@0 145 /**
aoqi@0 146 * {@inheritDoc}
aoqi@0 147 */
aoqi@0 148 public Content getPackageSummaryTree(Content packageSummaryContentTree) {
aoqi@0 149 HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, packageSummaryContentTree);
aoqi@0 150 return ul;
aoqi@0 151 }
aoqi@0 152
aoqi@0 153 /**
aoqi@0 154 * {@inheritDoc}
aoqi@0 155 */
aoqi@0 156 public void addClassesSummary(ClassDoc[] classes, String label,
aoqi@0 157 String tableSummary, String[] tableHeader, Content packageSummaryContentTree) {
aoqi@0 158 addClassesSummary(classes, label, tableSummary, tableHeader,
aoqi@0 159 packageSummaryContentTree, profile.value);
aoqi@0 160 }
aoqi@0 161
aoqi@0 162 /**
aoqi@0 163 * {@inheritDoc}
aoqi@0 164 */
aoqi@0 165 public void addProfileFooter(Content contentTree) {
aoqi@0 166 addNavLinks(false, contentTree);
aoqi@0 167 addBottom(contentTree);
aoqi@0 168 }
aoqi@0 169
aoqi@0 170 /**
aoqi@0 171 * {@inheritDoc}
aoqi@0 172 */
aoqi@0 173 public void printDocument(Content contentTree) throws IOException {
aoqi@0 174 printHtmlDocument(configuration.metakeywords.getMetaKeywords(profile),
aoqi@0 175 true, contentTree);
aoqi@0 176 }
aoqi@0 177
aoqi@0 178 /**
aoqi@0 179 * Add the profile package deprecation information to the documentation tree.
aoqi@0 180 *
aoqi@0 181 * @param li the content tree to which the deprecation information will be added
aoqi@0 182 * @param pkg the PackageDoc that is added
aoqi@0 183 */
aoqi@0 184 public void addPackageDeprecationInfo(Content li, PackageDoc pkg) {
aoqi@0 185 Tag[] deprs;
aoqi@0 186 if (Util.isDeprecated(pkg)) {
aoqi@0 187 deprs = pkg.tags("deprecated");
aoqi@0 188 HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
aoqi@0 189 deprDiv.addStyle(HtmlStyle.deprecatedContent);
aoqi@0 190 Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
aoqi@0 191 deprDiv.addContent(deprPhrase);
aoqi@0 192 if (deprs.length > 0) {
aoqi@0 193 Tag[] commentTags = deprs[0].inlineTags();
aoqi@0 194 if (commentTags.length > 0) {
aoqi@0 195 addInlineDeprecatedComment(pkg, deprs[0], deprDiv);
aoqi@0 196 }
aoqi@0 197 }
aoqi@0 198 li.addContent(deprDiv);
aoqi@0 199 }
aoqi@0 200 }
aoqi@0 201
aoqi@0 202 /**
aoqi@0 203 * Get "PREV PROFILE" link in the navigation bar.
aoqi@0 204 *
aoqi@0 205 * @return a content tree for the previous link
aoqi@0 206 */
aoqi@0 207 public Content getNavLinkPrevious() {
aoqi@0 208 Content li;
aoqi@0 209 if (prevProfile == null) {
aoqi@0 210 li = HtmlTree.LI(prevprofileLabel);
aoqi@0 211 } else {
aoqi@0 212 li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary(
aoqi@0 213 prevProfile.name)), prevprofileLabel, "", ""));
aoqi@0 214 }
aoqi@0 215 return li;
aoqi@0 216 }
aoqi@0 217
aoqi@0 218 /**
aoqi@0 219 * Get "NEXT PROFILE" link in the navigation bar.
aoqi@0 220 *
aoqi@0 221 * @return a content tree for the next link
aoqi@0 222 */
aoqi@0 223 public Content getNavLinkNext() {
aoqi@0 224 Content li;
aoqi@0 225 if (nextProfile == null) {
aoqi@0 226 li = HtmlTree.LI(nextprofileLabel);
aoqi@0 227 } else {
aoqi@0 228 li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary(
aoqi@0 229 nextProfile.name)), nextprofileLabel, "", ""));
aoqi@0 230 }
aoqi@0 231 return li;
aoqi@0 232 }
aoqi@0 233 }

mercurial