Sun, 24 Feb 2013 11:36:58 -0800
7112427: The doclet needs to be able to generate JavaFX documentation.
Reviewed-by: jjg
Contributed-by: jan.valenta@oracle.com
jjg@1606 | 1 | /* |
jjg@1606 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
jjg@1606 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@1606 | 4 | * |
jjg@1606 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@1606 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jjg@1606 | 7 | * published by the Free Software Foundation. Oracle designates this |
jjg@1606 | 8 | * particular file as subject to the "Classpath" exception as provided |
jjg@1606 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
jjg@1606 | 10 | * |
jjg@1606 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@1606 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@1606 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@1606 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@1606 | 15 | * accompanied this code). |
jjg@1606 | 16 | * |
jjg@1606 | 17 | * You should have received a copy of the GNU General Public License version |
jjg@1606 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@1606 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@1606 | 20 | * |
jjg@1606 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
jjg@1606 | 22 | * or visit www.oracle.com if you need additional information or have any |
jjg@1606 | 23 | * questions. |
jjg@1606 | 24 | */ |
jjg@1606 | 25 | |
jjg@1606 | 26 | package com.sun.tools.doclets.formats.html; |
jjg@1606 | 27 | |
jjg@1606 | 28 | import java.io.*; |
jjg@1606 | 29 | |
jjg@1606 | 30 | import com.sun.javadoc.*; |
jjg@1606 | 31 | import com.sun.tools.doclets.formats.html.markup.*; |
jjg@1606 | 32 | import com.sun.tools.doclets.internal.toolkit.*; |
jjg@1606 | 33 | import com.sun.tools.doclets.internal.toolkit.util.*; |
jjg@1606 | 34 | |
jjg@1606 | 35 | /** |
jjg@1606 | 36 | * Writes property documentation in HTML format. |
jjg@1606 | 37 | * |
jjg@1606 | 38 | * <p><b>This is NOT part of any supported API. |
jjg@1606 | 39 | * If you write code that depends on this, you do so at your own risk. |
jjg@1606 | 40 | * This code and its internal interfaces are subject to change or |
jjg@1606 | 41 | * deletion without notice.</b> |
jjg@1606 | 42 | * |
jjg@1606 | 43 | * @author Robert Field |
jjg@1606 | 44 | * @author Atul M Dambalkar |
jjg@1606 | 45 | * @author Jamie Ho (rewrite) |
jjg@1606 | 46 | * @author Bhavesh Patel (Modified) |
jjg@1606 | 47 | */ |
jjg@1606 | 48 | public class PropertyWriterImpl extends AbstractMemberWriter |
jjg@1606 | 49 | implements PropertyWriter, MemberSummaryWriter { |
jjg@1606 | 50 | |
jjg@1606 | 51 | public PropertyWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) { |
jjg@1606 | 52 | super(writer, classdoc); |
jjg@1606 | 53 | } |
jjg@1606 | 54 | |
jjg@1606 | 55 | /** |
jjg@1606 | 56 | * {@inheritDoc} |
jjg@1606 | 57 | */ |
jjg@1606 | 58 | public Content getMemberSummaryHeader(ClassDoc classDoc, |
jjg@1606 | 59 | Content memberSummaryTree) { |
jjg@1606 | 60 | memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY); |
jjg@1606 | 61 | Content memberTree = writer.getMemberTreeHeader(); |
jjg@1606 | 62 | writer.addSummaryHeader(this, classDoc, memberTree); |
jjg@1606 | 63 | return memberTree; |
jjg@1606 | 64 | } |
jjg@1606 | 65 | |
jjg@1606 | 66 | /** |
jjg@1606 | 67 | * {@inheritDoc} |
jjg@1606 | 68 | */ |
jjg@1606 | 69 | public Content getPropertyDetailsTreeHeader(ClassDoc classDoc, |
jjg@1606 | 70 | Content memberDetailsTree) { |
jjg@1606 | 71 | memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS); |
jjg@1606 | 72 | Content propertyDetailsTree = writer.getMemberTreeHeader(); |
jjg@1606 | 73 | propertyDetailsTree.addContent(writer.getMarkerAnchor("property_detail")); |
jjg@1606 | 74 | Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, |
jjg@1606 | 75 | writer.propertyDetailsLabel); |
jjg@1606 | 76 | propertyDetailsTree.addContent(heading); |
jjg@1606 | 77 | return propertyDetailsTree; |
jjg@1606 | 78 | } |
jjg@1606 | 79 | |
jjg@1606 | 80 | /** |
jjg@1606 | 81 | * {@inheritDoc} |
jjg@1606 | 82 | */ |
jjg@1606 | 83 | public Content getPropertyDocTreeHeader(MethodDoc property, |
jjg@1606 | 84 | Content propertyDetailsTree) { |
jjg@1606 | 85 | propertyDetailsTree.addContent( |
jjg@1606 | 86 | writer.getMarkerAnchor(property.name())); |
jjg@1606 | 87 | Content propertyDocTree = writer.getMemberTreeHeader(); |
jjg@1606 | 88 | Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); |
jjg@1606 | 89 | heading.addContent(property.name().substring(0, property.name().lastIndexOf("Property"))); |
jjg@1606 | 90 | propertyDocTree.addContent(heading); |
jjg@1606 | 91 | return propertyDocTree; |
jjg@1606 | 92 | } |
jjg@1606 | 93 | |
jjg@1606 | 94 | /** |
jjg@1606 | 95 | * {@inheritDoc} |
jjg@1606 | 96 | */ |
jjg@1606 | 97 | public Content getSignature(MethodDoc property) { |
jjg@1606 | 98 | Content pre = new HtmlTree(HtmlTag.PRE); |
jjg@1606 | 99 | writer.addAnnotationInfo(property, pre); |
jjg@1606 | 100 | addModifiers(property, pre); |
jjg@1606 | 101 | Content propertylink = new RawHtml(writer.getLink(new LinkInfoImpl( |
jjg@1606 | 102 | configuration, LinkInfoImpl.CONTEXT_MEMBER, |
jjg@1606 | 103 | property.returnType()))); |
jjg@1606 | 104 | pre.addContent(propertylink); |
jjg@1606 | 105 | pre.addContent(" "); |
jjg@1606 | 106 | if (configuration.linksource) { |
jjg@1606 | 107 | Content propertyName = new StringContent(property.name()); |
jjg@1606 | 108 | writer.addSrcLink(property, propertyName, pre); |
jjg@1606 | 109 | } else { |
jjg@1606 | 110 | addName(property.name(), pre); |
jjg@1606 | 111 | } |
jjg@1606 | 112 | return pre; |
jjg@1606 | 113 | } |
jjg@1606 | 114 | |
jjg@1606 | 115 | /** |
jjg@1606 | 116 | * {@inheritDoc} |
jjg@1606 | 117 | */ |
jjg@1606 | 118 | public void addDeprecated(MethodDoc property, Content propertyDocTree) { |
jjg@1606 | 119 | } |
jjg@1606 | 120 | |
jjg@1606 | 121 | /** |
jjg@1606 | 122 | * {@inheritDoc} |
jjg@1606 | 123 | */ |
jjg@1606 | 124 | public void addComments(MethodDoc property, Content propertyDocTree) { |
jjg@1606 | 125 | ClassDoc holder = property.containingClass(); |
jjg@1606 | 126 | if (property.inlineTags().length > 0) { |
jjg@1606 | 127 | if (holder.equals(classdoc) || |
jjg@1606 | 128 | (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) { |
jjg@1606 | 129 | writer.addInlineComment(property, propertyDocTree); |
jjg@1606 | 130 | } else { |
jjg@1606 | 131 | Content link = new RawHtml( |
jjg@1606 | 132 | writer.getDocLink(LinkInfoImpl.CONTEXT_PROPERTY_DOC_COPY, |
jjg@1606 | 133 | holder, property, |
jjg@1606 | 134 | holder.isIncluded() ? |
jjg@1606 | 135 | holder.typeName() : holder.qualifiedTypeName(), |
jjg@1606 | 136 | false)); |
jjg@1606 | 137 | Content codeLink = HtmlTree.CODE(link); |
jjg@1606 | 138 | Content strong = HtmlTree.STRONG(holder.isClass()? |
jjg@1606 | 139 | writer.descfrmClassLabel : writer.descfrmInterfaceLabel); |
jjg@1606 | 140 | strong.addContent(writer.getSpace()); |
jjg@1606 | 141 | strong.addContent(codeLink); |
jjg@1606 | 142 | propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong)); |
jjg@1606 | 143 | writer.addInlineComment(property, propertyDocTree); |
jjg@1606 | 144 | } |
jjg@1606 | 145 | } |
jjg@1606 | 146 | } |
jjg@1606 | 147 | |
jjg@1606 | 148 | /** |
jjg@1606 | 149 | * {@inheritDoc} |
jjg@1606 | 150 | */ |
jjg@1606 | 151 | public void addTags(MethodDoc property, Content propertyDocTree) { |
jjg@1606 | 152 | writer.addTagsInfo(property, propertyDocTree); |
jjg@1606 | 153 | } |
jjg@1606 | 154 | |
jjg@1606 | 155 | /** |
jjg@1606 | 156 | * {@inheritDoc} |
jjg@1606 | 157 | */ |
jjg@1606 | 158 | public Content getPropertyDetails(Content propertyDetailsTree) { |
jjg@1606 | 159 | return getMemberTree(propertyDetailsTree); |
jjg@1606 | 160 | } |
jjg@1606 | 161 | |
jjg@1606 | 162 | /** |
jjg@1606 | 163 | * {@inheritDoc} |
jjg@1606 | 164 | */ |
jjg@1606 | 165 | public Content getPropertyDoc(Content propertyDocTree, |
jjg@1606 | 166 | boolean isLastContent) { |
jjg@1606 | 167 | return getMemberTree(propertyDocTree, isLastContent); |
jjg@1606 | 168 | } |
jjg@1606 | 169 | |
jjg@1606 | 170 | /** |
jjg@1606 | 171 | * Close the writer. |
jjg@1606 | 172 | */ |
jjg@1606 | 173 | public void close() throws IOException { |
jjg@1606 | 174 | writer.close(); |
jjg@1606 | 175 | } |
jjg@1606 | 176 | |
jjg@1606 | 177 | public int getMemberKind() { |
jjg@1606 | 178 | return VisibleMemberMap.PROPERTIES; |
jjg@1606 | 179 | } |
jjg@1606 | 180 | |
jjg@1606 | 181 | /** |
jjg@1606 | 182 | * {@inheritDoc} |
jjg@1606 | 183 | */ |
jjg@1606 | 184 | public void addSummaryLabel(Content memberTree) { |
jjg@1606 | 185 | Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, |
jjg@1606 | 186 | writer.getResource("doclet.Property_Summary")); |
jjg@1606 | 187 | memberTree.addContent(label); |
jjg@1606 | 188 | } |
jjg@1606 | 189 | |
jjg@1606 | 190 | /** |
jjg@1606 | 191 | * {@inheritDoc} |
jjg@1606 | 192 | */ |
jjg@1606 | 193 | public String getTableSummary() { |
jjg@1606 | 194 | return configuration.getText("doclet.Member_Table_Summary", |
jjg@1606 | 195 | configuration.getText("doclet.Property_Summary"), |
jjg@1606 | 196 | configuration.getText("doclet.properties")); |
jjg@1606 | 197 | } |
jjg@1606 | 198 | |
jjg@1606 | 199 | /** |
jjg@1606 | 200 | * {@inheritDoc} |
jjg@1606 | 201 | */ |
jjg@1606 | 202 | public String getCaption() { |
jjg@1606 | 203 | return configuration.getText("doclet.Properties"); |
jjg@1606 | 204 | } |
jjg@1606 | 205 | |
jjg@1606 | 206 | /** |
jjg@1606 | 207 | * {@inheritDoc} |
jjg@1606 | 208 | */ |
jjg@1606 | 209 | public String[] getSummaryTableHeader(ProgramElementDoc member) { |
jjg@1606 | 210 | String[] header = new String[] { |
jjg@1606 | 211 | configuration.getText("doclet.Type"), |
jjg@1606 | 212 | configuration.getText("doclet.0_and_1", |
jjg@1606 | 213 | configuration.getText("doclet.Property"), |
jjg@1606 | 214 | configuration.getText("doclet.Description")) |
jjg@1606 | 215 | }; |
jjg@1606 | 216 | return header; |
jjg@1606 | 217 | } |
jjg@1606 | 218 | |
jjg@1606 | 219 | /** |
jjg@1606 | 220 | * {@inheritDoc} |
jjg@1606 | 221 | */ |
jjg@1606 | 222 | public void addSummaryAnchor(ClassDoc cd, Content memberTree) { |
jjg@1606 | 223 | memberTree.addContent(writer.getMarkerAnchor("property_summary")); |
jjg@1606 | 224 | } |
jjg@1606 | 225 | |
jjg@1606 | 226 | /** |
jjg@1606 | 227 | * {@inheritDoc} |
jjg@1606 | 228 | */ |
jjg@1606 | 229 | public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { |
jjg@1606 | 230 | inheritedTree.addContent(writer.getMarkerAnchor( |
jjg@1606 | 231 | "properties_inherited_from_class_" + configuration.getClassName(cd))); |
jjg@1606 | 232 | } |
jjg@1606 | 233 | |
jjg@1606 | 234 | /** |
jjg@1606 | 235 | * {@inheritDoc} |
jjg@1606 | 236 | */ |
jjg@1606 | 237 | public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) { |
jjg@1606 | 238 | Content classLink = new RawHtml(writer.getPreQualifiedClassLink( |
jjg@1606 | 239 | LinkInfoImpl.CONTEXT_MEMBER, cd, false)); |
jjg@1606 | 240 | Content label = new StringContent(cd.isClass() ? |
jjg@1606 | 241 | configuration.getText("doclet.Properties_Inherited_From_Class") : |
jjg@1606 | 242 | configuration.getText("doclet.Properties_Inherited_From_Interface")); |
jjg@1606 | 243 | Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, |
jjg@1606 | 244 | label); |
jjg@1606 | 245 | labelHeading.addContent(writer.getSpace()); |
jjg@1606 | 246 | labelHeading.addContent(classLink); |
jjg@1606 | 247 | inheritedTree.addContent(labelHeading); |
jjg@1606 | 248 | } |
jjg@1606 | 249 | |
jjg@1606 | 250 | /** |
jjg@1606 | 251 | * {@inheritDoc} |
jjg@1606 | 252 | */ |
jjg@1606 | 253 | protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member, |
jjg@1606 | 254 | Content tdSummary) { |
jjg@1606 | 255 | Content strong = HtmlTree.STRONG(new RawHtml( |
jjg@1606 | 256 | writer.getDocLink(context, |
jjg@1606 | 257 | cd, |
jjg@1606 | 258 | (MemberDoc) member, |
jjg@1606 | 259 | member.name().substring(0, member.name().lastIndexOf("Property")), |
jjg@1606 | 260 | false, |
jjg@1606 | 261 | true))); |
jjg@1606 | 262 | |
jjg@1606 | 263 | Content code = HtmlTree.CODE(strong); |
jjg@1606 | 264 | tdSummary.addContent(code); |
jjg@1606 | 265 | } |
jjg@1606 | 266 | |
jjg@1606 | 267 | /** |
jjg@1606 | 268 | * {@inheritDoc} |
jjg@1606 | 269 | */ |
jjg@1606 | 270 | protected void addInheritedSummaryLink(ClassDoc cd, |
jjg@1606 | 271 | ProgramElementDoc member, Content linksTree) { |
jjg@1606 | 272 | linksTree.addContent(new RawHtml( |
jjg@1606 | 273 | writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member, |
jjg@1606 | 274 | ((member.name().lastIndexOf("Property") != -1) && configuration.javafx) |
jjg@1606 | 275 | ? member.name().substring(0, member.name().length() - "Property".length()) |
jjg@1606 | 276 | : member.name(), |
jjg@1606 | 277 | false, true))); |
jjg@1606 | 278 | } |
jjg@1606 | 279 | |
jjg@1606 | 280 | /** |
jjg@1606 | 281 | * {@inheritDoc} |
jjg@1606 | 282 | */ |
jjg@1606 | 283 | protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) { |
jjg@1606 | 284 | MethodDoc property = (MethodDoc)member; |
jjg@1606 | 285 | addModifierAndType(property, property.returnType(), tdSummaryType); |
jjg@1606 | 286 | } |
jjg@1606 | 287 | |
jjg@1606 | 288 | /** |
jjg@1606 | 289 | * {@inheritDoc} |
jjg@1606 | 290 | */ |
jjg@1606 | 291 | protected Content getDeprecatedLink(ProgramElementDoc member) { |
jjg@1606 | 292 | return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, |
jjg@1606 | 293 | (MemberDoc) member, ((MethodDoc)member).qualifiedName()); |
jjg@1606 | 294 | } |
jjg@1606 | 295 | |
jjg@1606 | 296 | /** |
jjg@1606 | 297 | * {@inheritDoc} |
jjg@1606 | 298 | */ |
jjg@1606 | 299 | protected Content getNavSummaryLink(ClassDoc cd, boolean link) { |
jjg@1606 | 300 | if (link) { |
jjg@1606 | 301 | return writer.getHyperLink((cd == null)? |
jjg@1606 | 302 | "property_summary": |
jjg@1606 | 303 | "properties_inherited_from_class_" + |
jjg@1606 | 304 | configuration.getClassName(cd), |
jjg@1606 | 305 | writer.getResource("doclet.navProperty")); |
jjg@1606 | 306 | } else { |
jjg@1606 | 307 | return writer.getResource("doclet.navProperty"); |
jjg@1606 | 308 | } |
jjg@1606 | 309 | } |
jjg@1606 | 310 | |
jjg@1606 | 311 | /** |
jjg@1606 | 312 | * {@inheritDoc} |
jjg@1606 | 313 | */ |
jjg@1606 | 314 | protected void addNavDetailLink(boolean link, Content liNav) { |
jjg@1606 | 315 | if (link) { |
jjg@1606 | 316 | liNav.addContent(writer.getHyperLink("property_detail", |
jjg@1606 | 317 | writer.getResource("doclet.navProperty"))); |
jjg@1606 | 318 | } else { |
jjg@1606 | 319 | liNav.addContent(writer.getResource("doclet.navProperty")); |
jjg@1606 | 320 | } |
jjg@1606 | 321 | } |
jjg@1606 | 322 | } |