Tue, 03 Dec 2013 14:21:45 -0800
8025416: doclet not substituting {@docRoot} in some cases
Reviewed-by: jjg
bpatel@1568 | 1 | /* |
bpatel@1568 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
bpatel@1568 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bpatel@1568 | 4 | * |
bpatel@1568 | 5 | * This code is free software; you can redistribute it and/or modify it |
bpatel@1568 | 6 | * under the terms of the GNU General Public License version 2 only, as |
bpatel@1568 | 7 | * published by the Free Software Foundation. Oracle designates this |
bpatel@1568 | 8 | * particular file as subject to the "Classpath" exception as provided |
bpatel@1568 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
bpatel@1568 | 10 | * |
bpatel@1568 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
bpatel@1568 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bpatel@1568 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bpatel@1568 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
bpatel@1568 | 15 | * accompanied this code). |
bpatel@1568 | 16 | * |
bpatel@1568 | 17 | * You should have received a copy of the GNU General Public License version |
bpatel@1568 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
bpatel@1568 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bpatel@1568 | 20 | * |
bpatel@1568 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bpatel@1568 | 22 | * or visit www.oracle.com if you need additional information or have any |
bpatel@1568 | 23 | * questions. |
bpatel@1568 | 24 | */ |
bpatel@1568 | 25 | |
bpatel@1568 | 26 | package com.sun.tools.doclets.formats.html; |
bpatel@1568 | 27 | |
bpatel@1568 | 28 | import java.io.*; |
bpatel@1568 | 29 | import java.util.*; |
bpatel@1568 | 30 | |
bpatel@1568 | 31 | import com.sun.javadoc.*; |
bpatel@1568 | 32 | import com.sun.tools.javac.jvm.Profile; |
bpatel@1568 | 33 | import com.sun.tools.doclets.formats.html.markup.*; |
bpatel@1568 | 34 | import com.sun.tools.doclets.internal.toolkit.*; |
bpatel@1568 | 35 | import com.sun.tools.doclets.internal.toolkit.util.*; |
bpatel@1568 | 36 | |
bpatel@1568 | 37 | /** |
bpatel@1568 | 38 | * Class to generate file for each profile contents in the right-hand |
bpatel@1568 | 39 | * frame. This will list all the packages and Class Kinds in the profile. A click on any |
bpatel@1568 | 40 | * class-kind will update the frame with the clicked class-kind page. A click on any |
bpatel@1568 | 41 | * package will update the frame with the clicked profile package page. |
bpatel@1568 | 42 | * |
bpatel@1568 | 43 | * <p><b>This is NOT part of any supported API. |
bpatel@1568 | 44 | * If you write code that depends on this, you do so at your own risk. |
bpatel@1568 | 45 | * This code and its internal interfaces are subject to change or |
bpatel@1568 | 46 | * deletion without notice.</b> |
bpatel@1568 | 47 | * |
bpatel@1568 | 48 | * @author Bhavesh Patel |
bpatel@1568 | 49 | */ |
bpatel@1568 | 50 | public class ProfileWriterImpl extends HtmlDocletWriter |
bpatel@1568 | 51 | implements ProfileSummaryWriter { |
bpatel@1568 | 52 | |
bpatel@1568 | 53 | /** |
bpatel@1568 | 54 | * The prev profile name in the alpha-order list. |
bpatel@1568 | 55 | */ |
bpatel@1568 | 56 | protected Profile prevProfile; |
bpatel@1568 | 57 | |
bpatel@1568 | 58 | /** |
bpatel@1568 | 59 | * The next profile name in the alpha-order list. |
bpatel@1568 | 60 | */ |
bpatel@1568 | 61 | protected Profile nextProfile; |
bpatel@1568 | 62 | |
bpatel@1568 | 63 | /** |
bpatel@1568 | 64 | * The profile being documented. |
bpatel@1568 | 65 | */ |
bpatel@1568 | 66 | protected Profile profile; |
bpatel@1568 | 67 | |
bpatel@1568 | 68 | /** |
bpatel@1568 | 69 | * Constructor to construct ProfileWriter object and to generate |
bpatel@1568 | 70 | * "profileName-summary.html" file. |
bpatel@1568 | 71 | * |
bpatel@1568 | 72 | * @param configuration the configuration of the doclet. |
bpatel@1568 | 73 | * @param profile Profile under consideration. |
bpatel@1568 | 74 | * @param prevProfile Previous profile in the sorted array. |
bpatel@1568 | 75 | * @param nextProfile Next profile in the sorted array. |
bpatel@1568 | 76 | */ |
bpatel@1568 | 77 | public ProfileWriterImpl(ConfigurationImpl configuration, |
bpatel@1568 | 78 | Profile profile, Profile prevProfile, Profile nextProfile) |
bpatel@1568 | 79 | throws IOException { |
bpatel@1568 | 80 | super(configuration, DocPaths.profileSummary(profile.name)); |
bpatel@1568 | 81 | this.prevProfile = prevProfile; |
bpatel@1568 | 82 | this.nextProfile = nextProfile; |
bpatel@1568 | 83 | this.profile = profile; |
bpatel@1568 | 84 | } |
bpatel@1568 | 85 | |
bpatel@1568 | 86 | /** |
bpatel@1568 | 87 | * {@inheritDoc} |
bpatel@1568 | 88 | */ |
bpatel@1568 | 89 | public Content getProfileHeader(String heading) { |
bpatel@1568 | 90 | String profileName = profile.name; |
bpatel@1568 | 91 | Content bodyTree = getBody(true, getWindowTitle(profileName)); |
bpatel@1568 | 92 | addTop(bodyTree); |
bpatel@1568 | 93 | addNavLinks(true, bodyTree); |
bpatel@1568 | 94 | HtmlTree div = new HtmlTree(HtmlTag.DIV); |
bpatel@1568 | 95 | div.addStyle(HtmlStyle.header); |
bpatel@1568 | 96 | Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, |
bpatel@1568 | 97 | HtmlStyle.title, profileLabel); |
bpatel@1568 | 98 | tHeading.addContent(getSpace()); |
bpatel@1568 | 99 | Content profileHead = new RawHtml(heading); |
bpatel@1568 | 100 | tHeading.addContent(profileHead); |
bpatel@1568 | 101 | div.addContent(tHeading); |
bpatel@1568 | 102 | bodyTree.addContent(div); |
bpatel@1568 | 103 | return bodyTree; |
bpatel@1568 | 104 | } |
bpatel@1568 | 105 | |
bpatel@1568 | 106 | /** |
bpatel@1568 | 107 | * {@inheritDoc} |
bpatel@1568 | 108 | */ |
bpatel@1568 | 109 | public Content getContentHeader() { |
bpatel@1568 | 110 | HtmlTree div = new HtmlTree(HtmlTag.DIV); |
bpatel@1568 | 111 | div.addStyle(HtmlStyle.contentContainer); |
bpatel@1568 | 112 | return div; |
bpatel@1568 | 113 | } |
bpatel@1568 | 114 | |
bpatel@1568 | 115 | /** |
bpatel@1568 | 116 | * {@inheritDoc} |
bpatel@1568 | 117 | */ |
bpatel@1568 | 118 | public Content getSummaryHeader() { |
bpatel@1568 | 119 | HtmlTree li = new HtmlTree(HtmlTag.LI); |
bpatel@1568 | 120 | li.addStyle(HtmlStyle.blockList); |
bpatel@1568 | 121 | return li; |
bpatel@1568 | 122 | } |
bpatel@1568 | 123 | |
bpatel@1568 | 124 | /** |
bpatel@1568 | 125 | * {@inheritDoc} |
bpatel@1568 | 126 | */ |
bpatel@1568 | 127 | public Content getSummaryTree(Content summaryContentTree) { |
bpatel@1568 | 128 | HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree); |
bpatel@1568 | 129 | HtmlTree div = HtmlTree.DIV(HtmlStyle.summary, ul); |
bpatel@1568 | 130 | return div; |
bpatel@1568 | 131 | } |
bpatel@1568 | 132 | |
bpatel@1568 | 133 | /** |
bpatel@1568 | 134 | * {@inheritDoc} |
bpatel@1568 | 135 | */ |
bpatel@1568 | 136 | public Content getPackageSummaryHeader(PackageDoc pkg) { |
bpatel@1568 | 137 | Content pkgName = getTargetProfilePackageLink(pkg, |
bpatel@1568 | 138 | "classFrame", new StringContent(pkg.name()), profile.name); |
bpatel@1568 | 139 | Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName); |
bpatel@1568 | 140 | HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading); |
bpatel@2023 | 141 | addPackageDeprecationInfo(li, pkg); |
bpatel@1568 | 142 | return li; |
bpatel@1568 | 143 | } |
bpatel@1568 | 144 | |
bpatel@1568 | 145 | /** |
bpatel@1568 | 146 | * {@inheritDoc} |
bpatel@1568 | 147 | */ |
bpatel@1568 | 148 | public Content getPackageSummaryTree(Content packageSummaryContentTree) { |
bpatel@1568 | 149 | HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, packageSummaryContentTree); |
bpatel@1568 | 150 | return ul; |
bpatel@1568 | 151 | } |
bpatel@1568 | 152 | |
bpatel@1568 | 153 | /** |
bpatel@1568 | 154 | * {@inheritDoc} |
bpatel@1568 | 155 | */ |
bpatel@1568 | 156 | public void addClassesSummary(ClassDoc[] classes, String label, |
bpatel@1568 | 157 | String tableSummary, String[] tableHeader, Content packageSummaryContentTree) { |
bpatel@1568 | 158 | addClassesSummary(classes, label, tableSummary, tableHeader, |
bpatel@1568 | 159 | packageSummaryContentTree, profile.value); |
bpatel@1568 | 160 | } |
bpatel@1568 | 161 | |
bpatel@1568 | 162 | /** |
bpatel@1568 | 163 | * {@inheritDoc} |
bpatel@1568 | 164 | */ |
bpatel@1568 | 165 | public void addProfileFooter(Content contentTree) { |
bpatel@1568 | 166 | addNavLinks(false, contentTree); |
bpatel@1568 | 167 | addBottom(contentTree); |
bpatel@1568 | 168 | } |
bpatel@1568 | 169 | |
bpatel@1568 | 170 | /** |
bpatel@1568 | 171 | * {@inheritDoc} |
bpatel@1568 | 172 | */ |
bpatel@1568 | 173 | public void printDocument(Content contentTree) throws IOException { |
bpatel@1568 | 174 | printHtmlDocument(configuration.metakeywords.getMetaKeywords(profile), |
bpatel@1568 | 175 | true, contentTree); |
bpatel@1568 | 176 | } |
bpatel@1568 | 177 | |
bpatel@1568 | 178 | /** |
bpatel@2023 | 179 | * Add the profile package deprecation information to the documentation tree. |
bpatel@2023 | 180 | * |
bpatel@2023 | 181 | * @param li the content tree to which the deprecation information will be added |
bpatel@2023 | 182 | * @param pkg the PackageDoc that is added |
bpatel@2023 | 183 | */ |
bpatel@2023 | 184 | public void addPackageDeprecationInfo(Content li, PackageDoc pkg) { |
bpatel@2023 | 185 | Tag[] deprs; |
bpatel@2023 | 186 | if (Util.isDeprecated(pkg)) { |
bpatel@2023 | 187 | deprs = pkg.tags("deprecated"); |
bpatel@2023 | 188 | HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); |
bpatel@2023 | 189 | deprDiv.addStyle(HtmlStyle.deprecatedContent); |
bpatel@2147 | 190 | Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); |
bpatel@2023 | 191 | deprDiv.addContent(deprPhrase); |
bpatel@2023 | 192 | if (deprs.length > 0) { |
bpatel@2023 | 193 | Tag[] commentTags = deprs[0].inlineTags(); |
bpatel@2023 | 194 | if (commentTags.length > 0) { |
bpatel@2023 | 195 | addInlineDeprecatedComment(pkg, deprs[0], deprDiv); |
bpatel@2023 | 196 | } |
bpatel@2023 | 197 | } |
bpatel@2023 | 198 | li.addContent(deprDiv); |
bpatel@2023 | 199 | } |
bpatel@2023 | 200 | } |
bpatel@2023 | 201 | |
bpatel@2023 | 202 | /** |
bpatel@1568 | 203 | * Get "PREV PROFILE" link in the navigation bar. |
bpatel@1568 | 204 | * |
bpatel@1568 | 205 | * @return a content tree for the previous link |
bpatel@1568 | 206 | */ |
bpatel@1568 | 207 | public Content getNavLinkPrevious() { |
bpatel@1568 | 208 | Content li; |
bpatel@1568 | 209 | if (prevProfile == null) { |
bpatel@1568 | 210 | li = HtmlTree.LI(prevprofileLabel); |
bpatel@1568 | 211 | } else { |
bpatel@1568 | 212 | li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary( |
bpatel@1568 | 213 | prevProfile.name)), prevprofileLabel, "", "")); |
bpatel@1568 | 214 | } |
bpatel@1568 | 215 | return li; |
bpatel@1568 | 216 | } |
bpatel@1568 | 217 | |
bpatel@1568 | 218 | /** |
bpatel@1568 | 219 | * Get "NEXT PROFILE" link in the navigation bar. |
bpatel@1568 | 220 | * |
bpatel@1568 | 221 | * @return a content tree for the next link |
bpatel@1568 | 222 | */ |
bpatel@1568 | 223 | public Content getNavLinkNext() { |
bpatel@1568 | 224 | Content li; |
bpatel@1568 | 225 | if (nextProfile == null) { |
bpatel@1568 | 226 | li = HtmlTree.LI(nextprofileLabel); |
bpatel@1568 | 227 | } else { |
bpatel@1568 | 228 | li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary( |
bpatel@1568 | 229 | nextProfile.name)), nextprofileLabel, "", "")); |
bpatel@1568 | 230 | } |
bpatel@1568 | 231 | return li; |
bpatel@1568 | 232 | } |
bpatel@1568 | 233 | } |