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

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

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

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 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 * Generate the package index page "overview-summary.html" for the right-hand
aoqi@0 39 * frame. A click on the package name on this page will update the same frame
aoqi@0 40 * with the "package-summary.html" file for the clicked package.
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 Atul M Dambalkar
aoqi@0 48 * @author Bhavesh Patel (Modified)
aoqi@0 49 */
aoqi@0 50 public class PackageIndexWriter extends AbstractPackageIndexWriter {
aoqi@0 51
aoqi@0 52 /**
aoqi@0 53 * Root of the program structure. Used for "overview" documentation.
aoqi@0 54 */
aoqi@0 55 private RootDoc root;
aoqi@0 56
aoqi@0 57 /**
aoqi@0 58 * Map representing the group of packages as specified on the command line.
aoqi@0 59 *
aoqi@0 60 * @see Group
aoqi@0 61 */
aoqi@0 62 private Map<String,List<PackageDoc>> groupPackageMap;
aoqi@0 63
aoqi@0 64 /**
aoqi@0 65 * List to store the order groups as specified on the command line.
aoqi@0 66 */
aoqi@0 67 private List<String> groupList;
aoqi@0 68
aoqi@0 69 /**
aoqi@0 70 * Construct the PackageIndexWriter. Also constructs the grouping
aoqi@0 71 * information as provided on the command line by "-group" option. Stores
aoqi@0 72 * the order of groups specified by the user.
aoqi@0 73 *
aoqi@0 74 * @see Group
aoqi@0 75 */
aoqi@0 76 public PackageIndexWriter(ConfigurationImpl configuration,
aoqi@0 77 DocPath filename)
aoqi@0 78 throws IOException {
aoqi@0 79 super(configuration, filename);
aoqi@0 80 this.root = configuration.root;
aoqi@0 81 groupPackageMap = configuration.group.groupPackages(packages);
aoqi@0 82 groupList = configuration.group.getGroupList();
aoqi@0 83 }
aoqi@0 84
aoqi@0 85 /**
aoqi@0 86 * Generate the package index page for the right-hand frame.
aoqi@0 87 *
aoqi@0 88 * @param configuration the current configuration of the doclet.
aoqi@0 89 */
aoqi@0 90 public static void generate(ConfigurationImpl configuration) {
aoqi@0 91 PackageIndexWriter packgen;
aoqi@0 92 DocPath filename = DocPaths.OVERVIEW_SUMMARY;
aoqi@0 93 try {
aoqi@0 94 packgen = new PackageIndexWriter(configuration, filename);
aoqi@0 95 packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
aoqi@0 96 packgen.close();
aoqi@0 97 } catch (IOException exc) {
aoqi@0 98 configuration.standardmessage.error(
aoqi@0 99 "doclet.exception_encountered",
aoqi@0 100 exc.toString(), filename);
aoqi@0 101 throw new DocletAbortException(exc);
aoqi@0 102 }
aoqi@0 103 }
aoqi@0 104
aoqi@0 105 /**
aoqi@0 106 * Depending upon the grouping information and their titles, add
aoqi@0 107 * separate table indices for each package group.
aoqi@0 108 *
aoqi@0 109 * @param body the documentation tree to which the index will be added
aoqi@0 110 */
aoqi@0 111 protected void addIndex(Content body) {
aoqi@0 112 for (int i = 0; i < groupList.size(); i++) {
aoqi@0 113 String groupname = groupList.get(i);
aoqi@0 114 List<PackageDoc> list = groupPackageMap.get(groupname);
aoqi@0 115 if (list != null && list.size() > 0) {
aoqi@0 116 addIndexContents(list.toArray(new PackageDoc[list.size()]),
aoqi@0 117 groupname, configuration.getText("doclet.Member_Table_Summary",
aoqi@0 118 groupname, configuration.getText("doclet.packages")), body);
aoqi@0 119 }
aoqi@0 120 }
aoqi@0 121 }
aoqi@0 122
aoqi@0 123 /**
aoqi@0 124 * {@inheritDoc}
aoqi@0 125 */
aoqi@0 126 protected void addProfilesList(Content profileSummary, Content body) {
aoqi@0 127 Content h2 = HtmlTree.HEADING(HtmlTag.H2, profileSummary);
aoqi@0 128 Content profilesDiv = HtmlTree.DIV(h2);
aoqi@0 129 Content ul = new HtmlTree(HtmlTag.UL);
aoqi@0 130 String profileName;
aoqi@0 131 for (int i = 1; i < configuration.profiles.getProfileCount(); i++) {
aoqi@0 132 profileName = Profile.lookup(i).name;
aoqi@0 133 // If the profile has valid packages to be documented, add it to the
aoqi@0 134 // profiles list on overview-summary.html page.
aoqi@0 135 if (configuration.shouldDocumentProfile(profileName)) {
aoqi@0 136 Content profileLinkContent = getTargetProfileLink("classFrame",
aoqi@0 137 new StringContent(profileName), profileName);
aoqi@0 138 Content li = HtmlTree.LI(profileLinkContent);
aoqi@0 139 ul.addContent(li);
aoqi@0 140 }
aoqi@0 141 }
aoqi@0 142 profilesDiv.addContent(ul);
aoqi@0 143 Content div = HtmlTree.DIV(HtmlStyle.contentContainer, profilesDiv);
aoqi@0 144 body.addContent(div);
aoqi@0 145 }
aoqi@0 146
aoqi@0 147 /**
aoqi@0 148 * {@inheritDoc}
aoqi@0 149 */
aoqi@0 150 protected void addPackagesList(PackageDoc[] packages, String text,
aoqi@0 151 String tableSummary, Content body) {
aoqi@0 152 Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary,
aoqi@0 153 getTableCaption(new RawHtml(text)));
aoqi@0 154 table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
aoqi@0 155 Content tbody = new HtmlTree(HtmlTag.TBODY);
aoqi@0 156 addPackagesList(packages, tbody);
aoqi@0 157 table.addContent(tbody);
aoqi@0 158 Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
aoqi@0 159 body.addContent(div);
aoqi@0 160 }
aoqi@0 161
aoqi@0 162 /**
aoqi@0 163 * Adds list of packages in the index table. Generate link to each package.
aoqi@0 164 *
aoqi@0 165 * @param packages Packages to which link is to be generated
aoqi@0 166 * @param tbody the documentation tree to which the list will be added
aoqi@0 167 */
aoqi@0 168 protected void addPackagesList(PackageDoc[] packages, Content tbody) {
aoqi@0 169 for (int i = 0; i < packages.length; i++) {
aoqi@0 170 if (packages[i] != null && packages[i].name().length() > 0) {
aoqi@0 171 if (configuration.nodeprecated && Util.isDeprecated(packages[i]))
aoqi@0 172 continue;
aoqi@0 173 Content packageLinkContent = getPackageLink(packages[i],
aoqi@0 174 getPackageName(packages[i]));
aoqi@0 175 Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
aoqi@0 176 HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
aoqi@0 177 tdSummary.addStyle(HtmlStyle.colLast);
aoqi@0 178 addSummaryComment(packages[i], tdSummary);
aoqi@0 179 HtmlTree tr = HtmlTree.TR(tdPackage);
aoqi@0 180 tr.addContent(tdSummary);
aoqi@0 181 if (i%2 == 0)
aoqi@0 182 tr.addStyle(HtmlStyle.altColor);
aoqi@0 183 else
aoqi@0 184 tr.addStyle(HtmlStyle.rowColor);
aoqi@0 185 tbody.addContent(tr);
aoqi@0 186 }
aoqi@0 187 }
aoqi@0 188 }
aoqi@0 189
aoqi@0 190 /**
aoqi@0 191 * Adds the overview summary comment for this documentation. Add one line
aoqi@0 192 * summary at the top of the page and generate a link to the description,
aoqi@0 193 * which is added at the end of this page.
aoqi@0 194 *
aoqi@0 195 * @param body the documentation tree to which the overview header will be added
aoqi@0 196 */
aoqi@0 197 protected void addOverviewHeader(Content body) {
aoqi@0 198 if (root.inlineTags().length > 0) {
aoqi@0 199 HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
aoqi@0 200 subTitleDiv.addStyle(HtmlStyle.subTitle);
aoqi@0 201 addSummaryComment(root, subTitleDiv);
aoqi@0 202 Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
aoqi@0 203 Content see = seeLabel;
aoqi@0 204 see.addContent(" ");
aoqi@0 205 Content descPara = HtmlTree.P(see);
aoqi@0 206 Content descLink = getHyperLink(getDocLink(
aoqi@0 207 SectionName.OVERVIEW_DESCRIPTION),
aoqi@0 208 descriptionLabel, "", "");
aoqi@0 209 descPara.addContent(descLink);
aoqi@0 210 div.addContent(descPara);
aoqi@0 211 body.addContent(div);
aoqi@0 212 }
aoqi@0 213 }
aoqi@0 214
aoqi@0 215 /**
aoqi@0 216 * Adds the overview comment as provided in the file specified by the
aoqi@0 217 * "-overview" option on the command line.
aoqi@0 218 *
aoqi@0 219 * @param htmltree the documentation tree to which the overview comment will
aoqi@0 220 * be added
aoqi@0 221 */
aoqi@0 222 protected void addOverviewComment(Content htmltree) {
aoqi@0 223 if (root.inlineTags().length > 0) {
aoqi@0 224 htmltree.addContent(
aoqi@0 225 getMarkerAnchor(SectionName.OVERVIEW_DESCRIPTION));
aoqi@0 226 addInlineComment(root, htmltree);
aoqi@0 227 }
aoqi@0 228 }
aoqi@0 229
aoqi@0 230 /**
aoqi@0 231 * Adds the tag information as provided in the file specified by the
aoqi@0 232 * "-overview" option on the command line.
aoqi@0 233 *
aoqi@0 234 * @param body the documentation tree to which the overview will be added
aoqi@0 235 */
aoqi@0 236 protected void addOverview(Content body) throws IOException {
aoqi@0 237 HtmlTree div = new HtmlTree(HtmlTag.DIV);
aoqi@0 238 div.addStyle(HtmlStyle.contentContainer);
aoqi@0 239 addOverviewComment(div);
aoqi@0 240 addTagsInfo(root, div);
aoqi@0 241 body.addContent(div);
aoqi@0 242 }
aoqi@0 243
aoqi@0 244 /**
aoqi@0 245 * Adds the top text (from the -top option), the upper
aoqi@0 246 * navigation bar, and then the title (from the"-title"
aoqi@0 247 * option), at the top of page.
aoqi@0 248 *
aoqi@0 249 * @body the documentation tree to which the navigation bar header will be added
aoqi@0 250 */
aoqi@0 251 protected void addNavigationBarHeader(Content body) {
aoqi@0 252 addTop(body);
aoqi@0 253 addNavLinks(true, body);
aoqi@0 254 addConfigurationTitle(body);
aoqi@0 255 }
aoqi@0 256
aoqi@0 257 /**
aoqi@0 258 * Adds the lower navigation bar and the bottom text
aoqi@0 259 * (from the -bottom option) at the bottom of page.
aoqi@0 260 *
aoqi@0 261 * @param body the documentation tree to which the navigation bar footer will be added
aoqi@0 262 */
aoqi@0 263 protected void addNavigationBarFooter(Content body) {
aoqi@0 264 addNavLinks(false, body);
aoqi@0 265 addBottom(body);
aoqi@0 266 }
aoqi@0 267 }

mercurial