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