Tue, 14 May 2013 10:14:56 -0700
8012295: Cleanup JavaFX features in standard doclet
Reviewed-by: darcy
duke@1 | 1 | /* |
jjg@1735 | 2 | * Copyright (c) 2003, 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 | |
bpatel@233 | 28 | import com.sun.javadoc.*; |
jjg@1743 | 29 | import com.sun.tools.doclets.formats.html.markup.ContentBuilder; |
jjg@1742 | 30 | import com.sun.tools.doclets.formats.html.markup.HtmlAttr; |
jjg@1743 | 31 | import com.sun.tools.doclets.formats.html.markup.HtmlStyle; |
jjg@1742 | 32 | import com.sun.tools.doclets.formats.html.markup.HtmlTag; |
jjg@1742 | 33 | import com.sun.tools.doclets.formats.html.markup.HtmlTree; |
jjg@1743 | 34 | import com.sun.tools.doclets.formats.html.markup.RawHtml; |
jjg@1742 | 35 | import com.sun.tools.doclets.formats.html.markup.StringContent; |
duke@1 | 36 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 37 | import com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder; |
duke@1 | 38 | import com.sun.tools.doclets.internal.toolkit.taglets.*; |
duke@1 | 39 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 40 | |
duke@1 | 41 | /** |
duke@1 | 42 | * The taglet writer that writes HTML. |
duke@1 | 43 | * |
jjg@1359 | 44 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 45 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 46 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 47 | * deletion without notice.</b> |
jjg@1359 | 48 | * |
duke@1 | 49 | * @since 1.5 |
duke@1 | 50 | * @author Jamie Ho |
bpatel@233 | 51 | * @author Bhavesh Patel (Modified) |
duke@1 | 52 | */ |
duke@1 | 53 | |
duke@1 | 54 | public class TagletWriterImpl extends TagletWriter { |
duke@1 | 55 | |
jjg@1410 | 56 | private final HtmlDocletWriter htmlWriter; |
jjg@1410 | 57 | private final ConfigurationImpl configuration; |
duke@1 | 58 | |
duke@1 | 59 | public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) { |
jjg@1410 | 60 | super(isFirstSentence); |
duke@1 | 61 | this.htmlWriter = htmlWriter; |
jjg@1410 | 62 | configuration = htmlWriter.configuration; |
duke@1 | 63 | } |
duke@1 | 64 | |
duke@1 | 65 | /** |
duke@1 | 66 | * {@inheritDoc} |
duke@1 | 67 | */ |
duke@1 | 68 | public TagletOutput getOutputInstance() { |
jjg@1743 | 69 | return new TagletOutputImpl(); |
duke@1 | 70 | } |
duke@1 | 71 | |
duke@1 | 72 | /** |
duke@1 | 73 | * {@inheritDoc} |
duke@1 | 74 | */ |
jjg@1742 | 75 | protected TagletOutput codeTagOutput(Tag tag) { |
jjg@1742 | 76 | Content result = HtmlTree.CODE(new StringContent(tag.text())); |
jjg@1743 | 77 | return new TagletOutputImpl(result); |
jjg@1742 | 78 | } |
jjg@1742 | 79 | |
jjg@1742 | 80 | /** |
jjg@1742 | 81 | * {@inheritDoc} |
jjg@1742 | 82 | */ |
duke@1 | 83 | public TagletOutput getDocRootOutput() { |
jjg@1410 | 84 | if (configuration.docrootparent.length() > 0) |
jjg@1410 | 85 | return new TagletOutputImpl(configuration.docrootparent); |
jjg@1372 | 86 | else if (htmlWriter.pathToRoot.isEmpty()) |
jjg@1372 | 87 | return new TagletOutputImpl("."); |
bpatel@997 | 88 | else |
jjg@1372 | 89 | return new TagletOutputImpl(htmlWriter.pathToRoot.getPath()); |
duke@1 | 90 | } |
duke@1 | 91 | |
duke@1 | 92 | /** |
duke@1 | 93 | * {@inheritDoc} |
duke@1 | 94 | */ |
duke@1 | 95 | public TagletOutput deprecatedTagOutput(Doc doc) { |
jjg@1743 | 96 | ContentBuilder result = new ContentBuilder(); |
duke@1 | 97 | Tag[] deprs = doc.tags("deprecated"); |
duke@1 | 98 | if (doc instanceof ClassDoc) { |
duke@1 | 99 | if (Util.isDeprecated((ProgramElementDoc) doc)) { |
jjg@1743 | 100 | result.addContent(HtmlTree.SPAN(HtmlStyle.strong, |
jjg@1743 | 101 | new StringContent(configuration.getText("doclet.Deprecated")))); |
jjg@1743 | 102 | result.addContent(RawHtml.nbsp); |
duke@1 | 103 | if (deprs.length > 0) { |
duke@1 | 104 | Tag[] commentTags = deprs[0].inlineTags(); |
duke@1 | 105 | if (commentTags.length > 0) { |
jjg@1743 | 106 | result.addContent(commentTagsToOutput(null, doc, |
jjg@1744 | 107 | deprs[0].inlineTags(), false).getContent() |
duke@1 | 108 | ); |
duke@1 | 109 | } |
duke@1 | 110 | } |
duke@1 | 111 | } |
duke@1 | 112 | } else { |
duke@1 | 113 | MemberDoc member = (MemberDoc) doc; |
duke@1 | 114 | if (Util.isDeprecated((ProgramElementDoc) doc)) { |
jjg@1743 | 115 | result.addContent(HtmlTree.SPAN(HtmlStyle.strong, |
jjg@1743 | 116 | new StringContent(configuration.getText("doclet.Deprecated")))); |
jjg@1743 | 117 | result.addContent(RawHtml.nbsp); |
duke@1 | 118 | if (deprs.length > 0) { |
jjg@1744 | 119 | TagletOutputImpl body = commentTagsToOutput(null, doc, |
jjg@1743 | 120 | deprs[0].inlineTags(), false); |
jjg@1744 | 121 | result.addContent(HtmlTree.I(body.getContent())); |
duke@1 | 122 | } |
duke@1 | 123 | } else { |
duke@1 | 124 | if (Util.isDeprecated(member.containingClass())) { |
jjg@1743 | 125 | result.addContent(HtmlTree.SPAN(HtmlStyle.strong, |
jjg@1743 | 126 | new StringContent(configuration.getText("doclet.Deprecated")))); |
jjg@1743 | 127 | result.addContent(RawHtml.nbsp); |
duke@1 | 128 | } |
duke@1 | 129 | } |
duke@1 | 130 | } |
jjg@1743 | 131 | return new TagletOutputImpl(result); |
duke@1 | 132 | } |
duke@1 | 133 | |
duke@1 | 134 | /** |
duke@1 | 135 | * {@inheritDoc} |
duke@1 | 136 | */ |
jjg@1742 | 137 | protected TagletOutput literalTagOutput(Tag tag) { |
jjg@1742 | 138 | Content result = new StringContent(tag.text()); |
jjg@1743 | 139 | return new TagletOutputImpl(result); |
jjg@1742 | 140 | } |
jjg@1742 | 141 | |
jjg@1742 | 142 | /** |
jjg@1742 | 143 | * {@inheritDoc} |
jjg@1742 | 144 | */ |
duke@1 | 145 | public MessageRetriever getMsgRetriever() { |
jjg@1410 | 146 | return configuration.message; |
duke@1 | 147 | } |
duke@1 | 148 | |
duke@1 | 149 | /** |
duke@1 | 150 | * {@inheritDoc} |
duke@1 | 151 | */ |
duke@1 | 152 | public TagletOutput getParamHeader(String header) { |
jjg@1743 | 153 | HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong, |
jjg@1743 | 154 | new StringContent(header))); |
jjg@1743 | 155 | return new TagletOutputImpl(result); |
duke@1 | 156 | } |
duke@1 | 157 | |
duke@1 | 158 | /** |
duke@1 | 159 | * {@inheritDoc} |
duke@1 | 160 | */ |
duke@1 | 161 | public TagletOutput paramTagOutput(ParamTag paramTag, String paramName) { |
jjg@1743 | 162 | ContentBuilder body = new ContentBuilder(); |
jjg@1743 | 163 | body.addContent(HtmlTree.CODE(new RawHtml(paramName))); |
jjg@1743 | 164 | body.addContent(" - "); |
jjg@1745 | 165 | body.addContent(htmlWriter.commentTagsToContent(paramTag, null, paramTag.inlineTags(), false)); |
jjg@1743 | 166 | HtmlTree result = HtmlTree.DD(body); |
jjg@1743 | 167 | return new TagletOutputImpl(result); |
duke@1 | 168 | } |
duke@1 | 169 | |
duke@1 | 170 | /** |
duke@1 | 171 | * {@inheritDoc} |
duke@1 | 172 | */ |
jjg@1749 | 173 | public TagletOutput propertyTagOutput(Tag tag, String prefix) { |
jjg@1749 | 174 | Content body = new ContentBuilder(); |
jjg@1749 | 175 | body.addContent(new RawHtml(prefix)); |
jjg@1749 | 176 | body.addContent(" "); |
jjg@1749 | 177 | body.addContent(HtmlTree.CODE(new RawHtml(tag.text()))); |
jjg@1749 | 178 | body.addContent("."); |
jjg@1749 | 179 | Content result = HtmlTree.P(body); |
jjg@1749 | 180 | return new TagletOutputImpl(result); |
jjg@1749 | 181 | } |
jjg@1749 | 182 | |
jjg@1749 | 183 | /** |
jjg@1749 | 184 | * {@inheritDoc} |
jjg@1749 | 185 | */ |
duke@1 | 186 | public TagletOutput returnTagOutput(Tag returnTag) { |
jjg@1743 | 187 | ContentBuilder result = new ContentBuilder(); |
jjg@1743 | 188 | result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong, |
jjg@1743 | 189 | new StringContent(configuration.getText("doclet.Returns"))))); |
jjg@1745 | 190 | result.addContent(HtmlTree.DD(htmlWriter.commentTagsToContent( |
jjg@1745 | 191 | returnTag, null, returnTag.inlineTags(), false))); |
jjg@1743 | 192 | return new TagletOutputImpl(result); |
duke@1 | 193 | } |
duke@1 | 194 | |
duke@1 | 195 | /** |
duke@1 | 196 | * {@inheritDoc} |
duke@1 | 197 | */ |
duke@1 | 198 | public TagletOutput seeTagOutput(Doc holder, SeeTag[] seeTags) { |
jjg@1743 | 199 | ContentBuilder body = new ContentBuilder(); |
duke@1 | 200 | if (seeTags.length > 0) { |
duke@1 | 201 | for (int i = 0; i < seeTags.length; ++i) { |
jjg@1743 | 202 | appendSeparatorIfNotEmpty(body); |
jjg@1745 | 203 | body.addContent(htmlWriter.seeTagToContent(seeTags[i])); |
duke@1 | 204 | } |
duke@1 | 205 | } |
duke@1 | 206 | if (holder.isField() && ((FieldDoc)holder).constantValue() != null && |
duke@1 | 207 | htmlWriter instanceof ClassWriterImpl) { |
duke@1 | 208 | //Automatically add link to constant values page for constant fields. |
jjg@1743 | 209 | appendSeparatorIfNotEmpty(body); |
jjg@1373 | 210 | DocPath constantsPath = |
jjg@1373 | 211 | htmlWriter.pathToRoot.resolve(DocPaths.CONSTANT_VALUES); |
jjg@1373 | 212 | String whichConstant = |
jjg@1373 | 213 | ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName() + "." + ((FieldDoc) holder).name(); |
jjg@1373 | 214 | DocLink link = constantsPath.fragment(whichConstant); |
jjg@1743 | 215 | body.addContent(htmlWriter.getHyperLink(link, |
jjg@1743 | 216 | new StringContent(configuration.getText("doclet.Constants_Summary")))); |
duke@1 | 217 | } |
duke@1 | 218 | if (holder.isClass() && ((ClassDoc)holder).isSerializable()) { |
duke@1 | 219 | //Automatically add link to serialized form page for serializable classes. |
bpatel@233 | 220 | if ((SerializedFormBuilder.serialInclude(holder) && |
duke@1 | 221 | SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) { |
jjg@1743 | 222 | appendSeparatorIfNotEmpty(body); |
jjg@1373 | 223 | DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM); |
jjg@1373 | 224 | DocLink link = serialPath.fragment(((ClassDoc)holder).qualifiedName()); |
jjg@1743 | 225 | body.addContent(htmlWriter.getHyperLink(link, |
jjg@1743 | 226 | new StringContent(configuration.getText("doclet.Serialized_Form")))); |
duke@1 | 227 | } |
duke@1 | 228 | } |
jjg@1743 | 229 | if (body.isEmpty()) |
jjg@1743 | 230 | return new TagletOutputImpl(body); |
jjg@1743 | 231 | |
jjg@1743 | 232 | ContentBuilder result = new ContentBuilder(); |
jjg@1743 | 233 | result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong, |
jjg@1743 | 234 | new StringContent(configuration.getText("doclet.See_Also"))))); |
jjg@1743 | 235 | result.addContent(HtmlTree.DD(body)); |
jjg@1743 | 236 | return new TagletOutputImpl(result); |
jjg@1743 | 237 | |
duke@1 | 238 | } |
duke@1 | 239 | |
jjg@1743 | 240 | private void appendSeparatorIfNotEmpty(ContentBuilder body) { |
jjg@1743 | 241 | if (!body.isEmpty()) { |
jjg@1743 | 242 | body.addContent(", "); |
jjg@1743 | 243 | body.addContent(DocletConstants.NL); |
duke@1 | 244 | } |
jjg@1743 | 245 | } |
duke@1 | 246 | |
duke@1 | 247 | /** |
duke@1 | 248 | * {@inheritDoc} |
duke@1 | 249 | */ |
duke@1 | 250 | public TagletOutput simpleTagOutput(Tag[] simpleTags, String header) { |
jjg@1743 | 251 | ContentBuilder result = new ContentBuilder(); |
jjg@1743 | 252 | result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong, new RawHtml(header)))); |
jjg@1743 | 253 | ContentBuilder body = new ContentBuilder(); |
duke@1 | 254 | for (int i = 0; i < simpleTags.length; i++) { |
duke@1 | 255 | if (i > 0) { |
jjg@1743 | 256 | body.addContent(", "); |
duke@1 | 257 | } |
jjg@1745 | 258 | body.addContent(htmlWriter.commentTagsToContent( |
jjg@1745 | 259 | simpleTags[i], null, simpleTags[i].inlineTags(), false)); |
duke@1 | 260 | } |
jjg@1743 | 261 | result.addContent(HtmlTree.DD(body)); |
bpatel@233 | 262 | return new TagletOutputImpl(result); |
duke@1 | 263 | } |
duke@1 | 264 | |
duke@1 | 265 | /** |
duke@1 | 266 | * {@inheritDoc} |
duke@1 | 267 | */ |
duke@1 | 268 | public TagletOutput simpleTagOutput(Tag simpleTag, String header) { |
jjg@1743 | 269 | ContentBuilder result = new ContentBuilder(); |
jjg@1743 | 270 | result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong, new RawHtml(header)))); |
jjg@1745 | 271 | Content body = htmlWriter.commentTagsToContent( |
jjg@1745 | 272 | simpleTag, null, simpleTag.inlineTags(), false); |
jjg@1743 | 273 | result.addContent(HtmlTree.DD(body)); |
jjg@1743 | 274 | return new TagletOutputImpl(result); |
duke@1 | 275 | } |
duke@1 | 276 | |
duke@1 | 277 | /** |
duke@1 | 278 | * {@inheritDoc} |
duke@1 | 279 | */ |
duke@1 | 280 | public TagletOutput getThrowsHeader() { |
jjg@1743 | 281 | HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong, |
jjg@1743 | 282 | new StringContent(configuration.getText("doclet.Throws")))); |
jjg@1743 | 283 | return new TagletOutputImpl(result); |
duke@1 | 284 | } |
duke@1 | 285 | |
duke@1 | 286 | /** |
duke@1 | 287 | * {@inheritDoc} |
duke@1 | 288 | */ |
duke@1 | 289 | public TagletOutput throwsTagOutput(ThrowsTag throwsTag) { |
jjg@1743 | 290 | ContentBuilder body = new ContentBuilder(); |
jjg@1743 | 291 | Content excName = (throwsTag.exceptionType() == null) ? |
jjg@1743 | 292 | new RawHtml(throwsTag.exceptionName()) : |
jjg@1735 | 293 | htmlWriter.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, |
jjg@1743 | 294 | throwsTag.exceptionType())); |
jjg@1743 | 295 | body.addContent(HtmlTree.CODE(excName)); |
jjg@1745 | 296 | Content desc = htmlWriter.commentTagsToContent(throwsTag, null, |
jjg@1743 | 297 | throwsTag.inlineTags(), false); |
jjg@1743 | 298 | if (desc != null && !desc.isEmpty()) { |
jjg@1743 | 299 | body.addContent(" - "); |
jjg@1745 | 300 | body.addContent(desc); |
duke@1 | 301 | } |
jjg@1743 | 302 | HtmlTree res2 = HtmlTree.DD(body); |
jjg@1743 | 303 | return new TagletOutputImpl(res2); |
duke@1 | 304 | } |
duke@1 | 305 | |
duke@1 | 306 | /** |
duke@1 | 307 | * {@inheritDoc} |
duke@1 | 308 | */ |
duke@1 | 309 | public TagletOutput throwsTagOutput(Type throwsType) { |
jjg@1743 | 310 | HtmlTree result = HtmlTree.DD(HtmlTree.CODE(htmlWriter.getLink( |
jjg@1743 | 311 | new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, throwsType)))); |
jjg@1743 | 312 | return new TagletOutputImpl(result); |
duke@1 | 313 | } |
duke@1 | 314 | |
duke@1 | 315 | /** |
duke@1 | 316 | * {@inheritDoc} |
duke@1 | 317 | */ |
duke@1 | 318 | public TagletOutput valueTagOutput(FieldDoc field, String constantVal, |
duke@1 | 319 | boolean includeLink) { |
duke@1 | 320 | return new TagletOutputImpl(includeLink ? |
jjg@1735 | 321 | htmlWriter.getDocLink(LinkInfoImpl.Kind.VALUE_TAG, field, |
jjg@1743 | 322 | constantVal, false) : new RawHtml(constantVal)); |
duke@1 | 323 | } |
duke@1 | 324 | |
duke@1 | 325 | /** |
duke@1 | 326 | * {@inheritDoc} |
duke@1 | 327 | */ |
jjg@1744 | 328 | public TagletOutputImpl commentTagsToOutput(Tag holderTag, Tag[] tags) { |
duke@1 | 329 | return commentTagsToOutput(holderTag, null, tags, false); |
duke@1 | 330 | } |
duke@1 | 331 | |
duke@1 | 332 | /** |
duke@1 | 333 | * {@inheritDoc} |
duke@1 | 334 | */ |
jjg@1744 | 335 | public TagletOutputImpl commentTagsToOutput(Doc holderDoc, Tag[] tags) { |
duke@1 | 336 | return commentTagsToOutput(null, holderDoc, tags, false); |
duke@1 | 337 | } |
duke@1 | 338 | |
duke@1 | 339 | /** |
duke@1 | 340 | * {@inheritDoc} |
duke@1 | 341 | */ |
jjg@1744 | 342 | public TagletOutputImpl commentTagsToOutput(Tag holderTag, |
duke@1 | 343 | Doc holderDoc, Tag[] tags, boolean isFirstSentence) { |
jjg@1745 | 344 | return new TagletOutputImpl(htmlWriter.commentTagsToContent( |
jjg@1745 | 345 | holderTag, holderDoc, tags, isFirstSentence)); |
duke@1 | 346 | } |
duke@1 | 347 | |
duke@1 | 348 | /** |
duke@1 | 349 | * {@inheritDoc} |
duke@1 | 350 | */ |
duke@1 | 351 | public Configuration configuration() { |
jjg@1410 | 352 | return configuration; |
duke@1 | 353 | } |
duke@1 | 354 | } |