Wed, 10 Oct 2012 16:48:21 -0700
8000665: fix "internal API" comments on javadoc files
Reviewed-by: darcy
duke@1 | 1 | /* |
jjg@1357 | 2 | * Copyright (c) 1997, 2012, 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 | |
jjg@1357 | 28 | import java.lang.reflect.Modifier; |
bpatel@766 | 29 | import java.util.*; |
jjg@1357 | 30 | |
bpatel@233 | 31 | import com.sun.javadoc.*; |
bpatel@766 | 32 | import com.sun.tools.doclets.formats.html.markup.*; |
bpatel@766 | 33 | import com.sun.tools.doclets.internal.toolkit.*; |
jjg@1357 | 34 | import com.sun.tools.doclets.internal.toolkit.taglets.*; |
duke@1 | 35 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 36 | |
duke@1 | 37 | /** |
duke@1 | 38 | * The base class for member writers. |
duke@1 | 39 | * |
jjg@1359 | 40 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 41 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 42 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 43 | * deletion without notice.</b> |
jjg@1359 | 44 | * |
duke@1 | 45 | * @author Robert Field |
duke@1 | 46 | * @author Atul M Dambalkar |
duke@1 | 47 | * @author Jamie Ho (Re-write) |
bpatel@233 | 48 | * @author Bhavesh Patel (Modified) |
duke@1 | 49 | */ |
duke@1 | 50 | public abstract class AbstractMemberWriter { |
duke@1 | 51 | |
duke@1 | 52 | protected boolean printedSummaryHeader = false; |
duke@1 | 53 | protected final SubWriterHolderWriter writer; |
duke@1 | 54 | protected final ClassDoc classdoc; |
duke@1 | 55 | public final boolean nodepr; |
duke@1 | 56 | |
duke@1 | 57 | public AbstractMemberWriter(SubWriterHolderWriter writer, |
duke@1 | 58 | ClassDoc classdoc) { |
duke@1 | 59 | this.writer = writer; |
duke@1 | 60 | this.nodepr = configuration().nodeprecated; |
duke@1 | 61 | this.classdoc = classdoc; |
duke@1 | 62 | } |
duke@1 | 63 | |
duke@1 | 64 | public AbstractMemberWriter(SubWriterHolderWriter writer) { |
duke@1 | 65 | this(writer, null); |
duke@1 | 66 | } |
duke@1 | 67 | |
duke@1 | 68 | /*** abstracts ***/ |
duke@1 | 69 | |
bpatel@766 | 70 | /** |
bpatel@766 | 71 | * Add the summary label for the member. |
bpatel@766 | 72 | * |
bpatel@766 | 73 | * @param memberTree the content tree to which the label will be added |
bpatel@766 | 74 | */ |
bpatel@766 | 75 | public abstract void addSummaryLabel(Content memberTree); |
bpatel@243 | 76 | |
bpatel@766 | 77 | /** |
bpatel@766 | 78 | * Get the summary for the member summary table. |
bpatel@766 | 79 | * |
bpatel@766 | 80 | * @return a string for the table summary |
bpatel@766 | 81 | */ |
bpatel@766 | 82 | public abstract String getTableSummary(); |
bpatel@243 | 83 | |
bpatel@766 | 84 | /** |
bpatel@766 | 85 | * Get the caption for the member summary table. |
bpatel@766 | 86 | * |
bpatel@766 | 87 | * @return a string for the table caption |
bpatel@766 | 88 | */ |
bpatel@766 | 89 | public abstract String getCaption(); |
duke@1 | 90 | |
bpatel@766 | 91 | /** |
bpatel@766 | 92 | * Get the summary table header for the member. |
bpatel@766 | 93 | * |
bpatel@766 | 94 | * @param member the member to be documented |
bpatel@766 | 95 | * @return the summary table header |
bpatel@766 | 96 | */ |
bpatel@766 | 97 | public abstract String[] getSummaryTableHeader(ProgramElementDoc member); |
duke@1 | 98 | |
bpatel@766 | 99 | /** |
bpatel@766 | 100 | * Add inherited summary lable for the member. |
bpatel@766 | 101 | * |
bpatel@766 | 102 | * @param cd the class doc to which to link to |
bpatel@766 | 103 | * @param inheritedTree the content tree to which the inherited summary label will be added |
bpatel@766 | 104 | */ |
bpatel@766 | 105 | public abstract void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree); |
duke@1 | 106 | |
bpatel@766 | 107 | /** |
bpatel@766 | 108 | * Add the anchor for the summary section of the member. |
bpatel@766 | 109 | * |
bpatel@766 | 110 | * @param cd the class doc to be documented |
bpatel@766 | 111 | * @param memberTree the content tree to which the summary anchor will be added |
bpatel@766 | 112 | */ |
bpatel@766 | 113 | public abstract void addSummaryAnchor(ClassDoc cd, Content memberTree); |
duke@1 | 114 | |
bpatel@766 | 115 | /** |
bpatel@766 | 116 | * Add the anchor for the inherited summary section of the member. |
bpatel@766 | 117 | * |
bpatel@766 | 118 | * @param cd the class doc to be documented |
bpatel@766 | 119 | * @param inheritedTree the content tree to which the inherited summary anchor will be added |
bpatel@766 | 120 | */ |
bpatel@766 | 121 | public abstract void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree); |
duke@1 | 122 | |
bpatel@766 | 123 | /** |
bpatel@766 | 124 | * Add the summary type for the member. |
bpatel@766 | 125 | * |
bpatel@766 | 126 | * @param member the member to be documented |
bpatel@766 | 127 | * @param tdSummaryType the content tree to which the type will be added |
bpatel@766 | 128 | */ |
bpatel@766 | 129 | protected abstract void addSummaryType(ProgramElementDoc member, |
bpatel@766 | 130 | Content tdSummaryType); |
bpatel@766 | 131 | |
bpatel@766 | 132 | /** |
bpatel@766 | 133 | * Add the summary link for the member. |
bpatel@766 | 134 | * |
bpatel@766 | 135 | * @param cd the class doc to be documented |
bpatel@766 | 136 | * @param member the member to be documented |
bpatel@766 | 137 | * @param tdSummary the content tree to which the link will be added |
bpatel@766 | 138 | */ |
bpatel@766 | 139 | protected void addSummaryLink(ClassDoc cd, ProgramElementDoc member, |
bpatel@766 | 140 | Content tdSummary) { |
bpatel@766 | 141 | addSummaryLink(LinkInfoImpl.CONTEXT_MEMBER, cd, member, tdSummary); |
duke@1 | 142 | } |
duke@1 | 143 | |
bpatel@766 | 144 | /** |
bpatel@766 | 145 | * Add the summary link for the member. |
bpatel@766 | 146 | * |
bpatel@766 | 147 | * @param context the id of the context where the link will be printed |
bpatel@766 | 148 | * @param cd the class doc to be documented |
bpatel@766 | 149 | * @param member the member to be documented |
bpatel@766 | 150 | * @param tdSummary the content tree to which the summary link will be added |
bpatel@766 | 151 | */ |
bpatel@766 | 152 | protected abstract void addSummaryLink(int context, |
bpatel@766 | 153 | ClassDoc cd, ProgramElementDoc member, Content tdSummary); |
duke@1 | 154 | |
bpatel@766 | 155 | /** |
bpatel@766 | 156 | * Add the inherited summary link for the member. |
bpatel@766 | 157 | * |
bpatel@766 | 158 | * @param cd the class doc to be documented |
bpatel@766 | 159 | * @param member the member to be documented |
bpatel@766 | 160 | * @param linksTree the content tree to which the inherited summary link will be added |
bpatel@766 | 161 | */ |
bpatel@766 | 162 | protected abstract void addInheritedSummaryLink(ClassDoc cd, |
bpatel@766 | 163 | ProgramElementDoc member, Content linksTree); |
duke@1 | 164 | |
bpatel@766 | 165 | /** |
bpatel@766 | 166 | * Get the deprecated link. |
bpatel@766 | 167 | * |
bpatel@766 | 168 | * @param member the member being linked to |
bpatel@766 | 169 | * @return a content tree representing the link |
bpatel@766 | 170 | */ |
bpatel@766 | 171 | protected abstract Content getDeprecatedLink(ProgramElementDoc member); |
duke@1 | 172 | |
bpatel@766 | 173 | /** |
bpatel@766 | 174 | * Get the navigation summary link. |
bpatel@766 | 175 | * |
bpatel@766 | 176 | * @param cd the class doc to be documented |
bpatel@766 | 177 | * @param link true if its a link else the label to be printed |
bpatel@766 | 178 | * @return a content tree for the navigation summary link. |
bpatel@766 | 179 | */ |
bpatel@766 | 180 | protected abstract Content getNavSummaryLink(ClassDoc cd, boolean link); |
duke@1 | 181 | |
bpatel@766 | 182 | /** |
bpatel@766 | 183 | * Add the navigation detail link. |
bpatel@766 | 184 | * |
bpatel@766 | 185 | * @param link true if its a link else the label to be printed |
bpatel@766 | 186 | * @param liNav the content tree to which the navigation detail link will be added |
bpatel@766 | 187 | */ |
bpatel@766 | 188 | protected abstract void addNavDetailLink(boolean link, Content liNav); |
duke@1 | 189 | |
duke@1 | 190 | /*** ***/ |
duke@1 | 191 | |
duke@1 | 192 | protected void print(String str) { |
duke@1 | 193 | writer.print(str); |
duke@1 | 194 | writer.displayLength += str.length(); |
duke@1 | 195 | } |
duke@1 | 196 | |
duke@1 | 197 | protected void print(char ch) { |
duke@1 | 198 | writer.print(ch); |
duke@1 | 199 | writer.displayLength++; |
duke@1 | 200 | } |
duke@1 | 201 | |
bpatel@182 | 202 | protected void strong(String str) { |
bpatel@182 | 203 | writer.strong(str); |
duke@1 | 204 | writer.displayLength += str.length(); |
duke@1 | 205 | } |
duke@1 | 206 | |
duke@1 | 207 | /** |
bpatel@766 | 208 | * Add the member name to the content tree and modifies the display length. |
bpatel@766 | 209 | * |
bpatel@766 | 210 | * @param name the member name to be added to the content tree. |
bpatel@766 | 211 | * @param htmltree the content tree to which the name will be added. |
bpatel@766 | 212 | */ |
bpatel@766 | 213 | protected void addName(String name, Content htmltree) { |
bpatel@766 | 214 | htmltree.addContent(name); |
bpatel@766 | 215 | writer.displayLength += name.length(); |
bpatel@766 | 216 | } |
bpatel@766 | 217 | |
bpatel@766 | 218 | /** |
duke@1 | 219 | * Return a string describing the access modifier flags. |
duke@1 | 220 | * Don't include native or synchronized. |
duke@1 | 221 | * |
duke@1 | 222 | * The modifier names are returned in canonical order, as |
duke@1 | 223 | * specified by <em>The Java Language Specification</em>. |
duke@1 | 224 | */ |
duke@1 | 225 | protected String modifierString(MemberDoc member) { |
duke@1 | 226 | int ms = member.modifierSpecifier(); |
duke@1 | 227 | int no = Modifier.NATIVE | Modifier.SYNCHRONIZED; |
duke@1 | 228 | return Modifier.toString(ms & ~no); |
duke@1 | 229 | } |
duke@1 | 230 | |
duke@1 | 231 | protected String typeString(MemberDoc member) { |
duke@1 | 232 | String type = ""; |
duke@1 | 233 | if (member instanceof MethodDoc) { |
duke@1 | 234 | type = ((MethodDoc)member).returnType().toString(); |
duke@1 | 235 | } else if (member instanceof FieldDoc) { |
duke@1 | 236 | type = ((FieldDoc)member).type().toString(); |
duke@1 | 237 | } |
duke@1 | 238 | return type; |
duke@1 | 239 | } |
duke@1 | 240 | |
bpatel@766 | 241 | /** |
bpatel@766 | 242 | * Add the modifier for the member. |
bpatel@766 | 243 | * |
bpatel@766 | 244 | * @param member the member for which teh modifier will be added. |
bpatel@766 | 245 | * @param htmltree the content tree to which the modifier information will be added. |
bpatel@766 | 246 | */ |
bpatel@766 | 247 | protected void addModifiers(MemberDoc member, Content htmltree) { |
duke@1 | 248 | String mod = modifierString(member); |
duke@1 | 249 | // According to JLS, we should not be showing public modifier for |
duke@1 | 250 | // interface methods. |
duke@1 | 251 | if ((member.isField() || member.isMethod()) && |
duke@1 | 252 | writer instanceof ClassWriterImpl && |
bpatel@766 | 253 | ((ClassWriterImpl) writer).getClassDoc().isInterface()) { |
duke@1 | 254 | mod = Util.replaceText(mod, "public", "").trim(); |
duke@1 | 255 | } |
duke@1 | 256 | if(mod.length() > 0) { |
bpatel@766 | 257 | htmltree.addContent(mod); |
bpatel@766 | 258 | htmltree.addContent(writer.getSpace()); |
duke@1 | 259 | } |
duke@1 | 260 | } |
duke@1 | 261 | |
duke@1 | 262 | protected String makeSpace(int len) { |
duke@1 | 263 | if (len <= 0) { |
duke@1 | 264 | return ""; |
duke@1 | 265 | } |
duke@1 | 266 | StringBuffer sb = new StringBuffer(len); |
duke@1 | 267 | for(int i = 0; i < len; i++) { |
duke@1 | 268 | sb.append(' '); |
duke@1 | 269 | } |
duke@1 | 270 | return sb.toString(); |
duke@1 | 271 | } |
duke@1 | 272 | |
duke@1 | 273 | /** |
bpatel@766 | 274 | * Add the modifier and type for the member in the member summary. |
bpatel@766 | 275 | * |
bpatel@766 | 276 | * @param member the member to add the type for |
bpatel@766 | 277 | * @param type the type to add |
bpatel@766 | 278 | * @param tdSummaryType the content tree to which the modified and type will be added |
duke@1 | 279 | */ |
bpatel@766 | 280 | protected void addModifierAndType(ProgramElementDoc member, Type type, |
bpatel@766 | 281 | Content tdSummaryType) { |
bpatel@766 | 282 | HtmlTree code = new HtmlTree(HtmlTag.CODE); |
bpatel@766 | 283 | addModifier(member, code); |
duke@1 | 284 | if (type == null) { |
duke@1 | 285 | if (member.isClass()) { |
bpatel@766 | 286 | code.addContent("class"); |
duke@1 | 287 | } else { |
bpatel@766 | 288 | code.addContent("interface"); |
duke@1 | 289 | } |
bpatel@766 | 290 | code.addContent(writer.getSpace()); |
duke@1 | 291 | } else { |
duke@1 | 292 | if (member instanceof ExecutableMemberDoc && |
duke@1 | 293 | ((ExecutableMemberDoc) member).typeParameters().length > 0) { |
duke@1 | 294 | //Code to avoid ugly wrapping in member summary table. |
bpatel@766 | 295 | int displayLength = ((AbstractExecutableMemberWriter) this).addTypeParameters( |
bpatel@766 | 296 | (ExecutableMemberDoc) member, code); |
duke@1 | 297 | if (displayLength > 10) { |
bpatel@766 | 298 | code.addContent(new HtmlTree(HtmlTag.BR)); |
duke@1 | 299 | } |
bpatel@766 | 300 | code.addContent(new RawHtml( |
bpatel@766 | 301 | writer.getLink(new LinkInfoImpl( |
bpatel@766 | 302 | LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type)))); |
duke@1 | 303 | } else { |
bpatel@766 | 304 | code.addContent(new RawHtml( |
bpatel@766 | 305 | writer.getLink(new LinkInfoImpl( |
bpatel@766 | 306 | LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type)))); |
duke@1 | 307 | } |
duke@1 | 308 | |
duke@1 | 309 | } |
bpatel@766 | 310 | tdSummaryType.addContent(code); |
duke@1 | 311 | } |
duke@1 | 312 | |
duke@1 | 313 | private void printModifier(ProgramElementDoc member) { |
duke@1 | 314 | if (member.isProtected()) { |
duke@1 | 315 | print("protected "); |
duke@1 | 316 | } else if (member.isPrivate()) { |
duke@1 | 317 | print("private "); |
duke@1 | 318 | } else if (!member.isPublic()) { // Package private |
duke@1 | 319 | writer.printText("doclet.Package_private"); |
duke@1 | 320 | print(" "); |
duke@1 | 321 | } |
duke@1 | 322 | if (member.isMethod() && ((MethodDoc)member).isAbstract()) { |
duke@1 | 323 | print("abstract "); |
duke@1 | 324 | } |
duke@1 | 325 | if (member.isStatic()) { |
duke@1 | 326 | print("static"); |
duke@1 | 327 | } |
duke@1 | 328 | } |
duke@1 | 329 | |
bpatel@233 | 330 | /** |
bpatel@766 | 331 | * Add the modifier for the member. |
bpatel@766 | 332 | * |
bpatel@766 | 333 | * @param member the member to add the type for |
bpatel@766 | 334 | * @param code the content tree to which the modified will be added |
bpatel@766 | 335 | */ |
bpatel@766 | 336 | private void addModifier(ProgramElementDoc member, Content code) { |
bpatel@766 | 337 | if (member.isProtected()) { |
bpatel@766 | 338 | code.addContent("protected "); |
bpatel@766 | 339 | } else if (member.isPrivate()) { |
bpatel@766 | 340 | code.addContent("private "); |
bpatel@766 | 341 | } else if (!member.isPublic()) { // Package private |
bpatel@766 | 342 | code.addContent(configuration().getText("doclet.Package_private")); |
bpatel@766 | 343 | code.addContent(" "); |
bpatel@766 | 344 | } |
bpatel@766 | 345 | if (member.isMethod() && ((MethodDoc)member).isAbstract()) { |
bpatel@766 | 346 | code.addContent("abstract "); |
bpatel@766 | 347 | } |
bpatel@766 | 348 | if (member.isStatic()) { |
bpatel@766 | 349 | code.addContent("static "); |
bpatel@766 | 350 | } |
bpatel@766 | 351 | } |
bpatel@766 | 352 | |
bpatel@766 | 353 | /** |
bpatel@766 | 354 | * Add the deprecated information for the given member. |
bpatel@233 | 355 | * |
bpatel@233 | 356 | * @param member the member being documented. |
bpatel@766 | 357 | * @param contentTree the content tree to which the deprecated information will be added. |
bpatel@233 | 358 | */ |
bpatel@766 | 359 | protected void addDeprecatedInfo(ProgramElementDoc member, Content contentTree) { |
bpatel@233 | 360 | String output = (new DeprecatedTaglet()).getTagletOutput(member, |
bpatel@233 | 361 | writer.getTagletWriterInstance(false)).toString().trim(); |
bpatel@233 | 362 | if (!output.isEmpty()) { |
bpatel@766 | 363 | Content deprecatedContent = new RawHtml(output); |
bpatel@766 | 364 | Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent); |
bpatel@766 | 365 | contentTree.addContent(div); |
bpatel@233 | 366 | } |
bpatel@233 | 367 | } |
bpatel@233 | 368 | |
bpatel@766 | 369 | /** |
bpatel@766 | 370 | * Add the comment for the given member. |
bpatel@766 | 371 | * |
bpatel@766 | 372 | * @param member the member being documented. |
jjg@1358 | 373 | * @param htmltree the content tree to which the comment will be added. |
bpatel@766 | 374 | */ |
bpatel@766 | 375 | protected void addComment(ProgramElementDoc member, Content htmltree) { |
duke@1 | 376 | if (member.inlineTags().length > 0) { |
bpatel@766 | 377 | writer.addInlineComment(member, htmltree); |
duke@1 | 378 | } |
duke@1 | 379 | } |
duke@1 | 380 | |
duke@1 | 381 | protected String name(ProgramElementDoc member) { |
duke@1 | 382 | return member.name(); |
duke@1 | 383 | } |
duke@1 | 384 | |
bpatel@766 | 385 | /** |
bpatel@766 | 386 | * Get the header for the section. |
bpatel@766 | 387 | * |
bpatel@766 | 388 | * @param member the member being documented. |
bpatel@766 | 389 | * @return a header content for the section. |
bpatel@766 | 390 | */ |
bpatel@766 | 391 | protected Content getHead(MemberDoc member) { |
bpatel@766 | 392 | Content memberContent = new RawHtml(member.name()); |
bpatel@766 | 393 | Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent); |
bpatel@766 | 394 | return heading; |
duke@1 | 395 | } |
duke@1 | 396 | |
duke@1 | 397 | /** |
duke@1 | 398 | * Return true if the given <code>ProgramElement</code> is inherited |
duke@1 | 399 | * by the class that is being documented. |
duke@1 | 400 | * |
duke@1 | 401 | * @param ped The <code>ProgramElement</code> being checked. |
duke@1 | 402 | * return true if the <code>ProgramElement</code> is being inherited and |
duke@1 | 403 | * false otherwise. |
duke@1 | 404 | */ |
duke@1 | 405 | protected boolean isInherited(ProgramElementDoc ped){ |
duke@1 | 406 | if(ped.isPrivate() || (ped.isPackagePrivate() && |
duke@1 | 407 | ! ped.containingPackage().equals(classdoc.containingPackage()))){ |
duke@1 | 408 | return false; |
duke@1 | 409 | } |
duke@1 | 410 | return true; |
duke@1 | 411 | } |
duke@1 | 412 | |
duke@1 | 413 | /** |
bpatel@766 | 414 | * Add deprecated information to the documentation tree |
bpatel@766 | 415 | * |
bpatel@766 | 416 | * @param deprmembers list of deprecated members |
bpatel@766 | 417 | * @param headingKey the caption for the deprecated members table |
bpatel@766 | 418 | * @param tableSummary the summary for the deprecated members table |
bpatel@766 | 419 | * @param tableHeader table headers for the deprecated members table |
bpatel@766 | 420 | * @param contentTree the content tree to which the deprecated members table will be added |
duke@1 | 421 | */ |
bpatel@766 | 422 | protected void addDeprecatedAPI(List<Doc> deprmembers, String headingKey, |
bpatel@766 | 423 | String tableSummary, String[] tableHeader, Content contentTree) { |
duke@1 | 424 | if (deprmembers.size() > 0) { |
bpatel@766 | 425 | Content table = HtmlTree.TABLE(0, 3, 0, tableSummary, |
bpatel@766 | 426 | writer.getTableCaption(configuration().getText(headingKey))); |
bpatel@766 | 427 | table.addContent(writer.getSummaryTableHeader(tableHeader, "col")); |
bpatel@766 | 428 | Content tbody = new HtmlTree(HtmlTag.TBODY); |
duke@1 | 429 | for (int i = 0; i < deprmembers.size(); i++) { |
duke@1 | 430 | ProgramElementDoc member =(ProgramElementDoc)deprmembers.get(i); |
bpatel@766 | 431 | HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getDeprecatedLink(member)); |
duke@1 | 432 | if (member.tags("deprecated").length > 0) |
bpatel@766 | 433 | writer.addInlineDeprecatedComment(member, |
bpatel@766 | 434 | member.tags("deprecated")[0], td); |
bpatel@766 | 435 | HtmlTree tr = HtmlTree.TR(td); |
bpatel@766 | 436 | if (i%2 == 0) |
bpatel@766 | 437 | tr.addStyle(HtmlStyle.altColor); |
bpatel@766 | 438 | else |
bpatel@766 | 439 | tr.addStyle(HtmlStyle.rowColor); |
bpatel@766 | 440 | tbody.addContent(tr); |
duke@1 | 441 | } |
bpatel@766 | 442 | table.addContent(tbody); |
bpatel@766 | 443 | Content li = HtmlTree.LI(HtmlStyle.blockList, table); |
bpatel@766 | 444 | Content ul = HtmlTree.UL(HtmlStyle.blockList, li); |
bpatel@766 | 445 | contentTree.addContent(ul); |
duke@1 | 446 | } |
duke@1 | 447 | } |
duke@1 | 448 | |
duke@1 | 449 | /** |
bpatel@766 | 450 | * Add use information to the documentation tree. |
bpatel@766 | 451 | * |
bpatel@766 | 452 | * @param mems list of program elements for which the use information will be added |
bpatel@766 | 453 | * @param heading the section heading |
bpatel@766 | 454 | * @param tableSummary the summary for the use table |
bpatel@766 | 455 | * @param contentTree the content tree to which the use information will be added |
duke@1 | 456 | */ |
bpatel@766 | 457 | protected void addUseInfo(List<? extends ProgramElementDoc> mems, |
bpatel@766 | 458 | String heading, String tableSummary, Content contentTree) { |
duke@1 | 459 | if (mems == null) { |
duke@1 | 460 | return; |
duke@1 | 461 | } |
jjg@74 | 462 | List<? extends ProgramElementDoc> members = mems; |
bpatel@243 | 463 | boolean printedUseTableHeader = false; |
duke@1 | 464 | if (members.size() > 0) { |
bpatel@766 | 465 | Content table = HtmlTree.TABLE(0, 3, 0, tableSummary, |
bpatel@766 | 466 | writer.getTableCaption(heading)); |
bpatel@766 | 467 | Content tbody = new HtmlTree(HtmlTag.TBODY); |
bpatel@766 | 468 | Iterator<? extends ProgramElementDoc> it = members.iterator(); |
bpatel@766 | 469 | for (int i = 0; it.hasNext(); i++) { |
jjg@74 | 470 | ProgramElementDoc pgmdoc = it.next(); |
duke@1 | 471 | ClassDoc cd = pgmdoc.containingClass(); |
bpatel@243 | 472 | if (!printedUseTableHeader) { |
bpatel@766 | 473 | table.addContent(writer.getSummaryTableHeader( |
bpatel@766 | 474 | this.getSummaryTableHeader(pgmdoc), "col")); |
bpatel@243 | 475 | printedUseTableHeader = true; |
bpatel@243 | 476 | } |
bpatel@766 | 477 | HtmlTree tr = new HtmlTree(HtmlTag.TR); |
bpatel@766 | 478 | if (i % 2 == 0) { |
bpatel@766 | 479 | tr.addStyle(HtmlStyle.altColor); |
bpatel@766 | 480 | } else { |
bpatel@766 | 481 | tr.addStyle(HtmlStyle.rowColor); |
bpatel@766 | 482 | } |
bpatel@766 | 483 | HtmlTree tdFirst = new HtmlTree(HtmlTag.TD); |
bpatel@766 | 484 | tdFirst.addStyle(HtmlStyle.colFirst); |
bpatel@766 | 485 | writer.addSummaryType(this, pgmdoc, tdFirst); |
bpatel@766 | 486 | tr.addContent(tdFirst); |
bpatel@766 | 487 | HtmlTree tdLast = new HtmlTree(HtmlTag.TD); |
bpatel@766 | 488 | tdLast.addStyle(HtmlStyle.colLast); |
duke@1 | 489 | if (cd != null && !(pgmdoc instanceof ConstructorDoc) |
bpatel@766 | 490 | && !(pgmdoc instanceof ClassDoc)) { |
bpatel@766 | 491 | HtmlTree name = new HtmlTree(HtmlTag.SPAN); |
bpatel@766 | 492 | name.addStyle(HtmlStyle.strong); |
bpatel@766 | 493 | name.addContent(cd.name() + "."); |
bpatel@766 | 494 | tdLast.addContent(name); |
duke@1 | 495 | } |
bpatel@766 | 496 | addSummaryLink(pgmdoc instanceof ClassDoc ? |
bpatel@766 | 497 | LinkInfoImpl.CONTEXT_CLASS_USE : LinkInfoImpl.CONTEXT_MEMBER, |
bpatel@766 | 498 | cd, pgmdoc, tdLast); |
bpatel@766 | 499 | writer.addSummaryLinkComment(this, pgmdoc, tdLast); |
bpatel@766 | 500 | tr.addContent(tdLast); |
bpatel@766 | 501 | tbody.addContent(tr); |
duke@1 | 502 | } |
bpatel@766 | 503 | table.addContent(tbody); |
bpatel@766 | 504 | contentTree.addContent(table); |
duke@1 | 505 | } |
duke@1 | 506 | } |
duke@1 | 507 | |
bpatel@766 | 508 | /** |
bpatel@766 | 509 | * Add the navigation detail link. |
bpatel@766 | 510 | * |
bpatel@766 | 511 | * @param members the members to be linked |
bpatel@766 | 512 | * @param liNav the content tree to which the navigation detail link will be added |
bpatel@766 | 513 | */ |
bpatel@766 | 514 | protected void addNavDetailLink(List<?> members, Content liNav) { |
bpatel@766 | 515 | addNavDetailLink(members.size() > 0 ? true : false, liNav); |
duke@1 | 516 | } |
duke@1 | 517 | |
bpatel@766 | 518 | /** |
bpatel@766 | 519 | * Add the navigation summary link. |
bpatel@766 | 520 | * |
bpatel@766 | 521 | * @param members members to be linked |
bpatel@766 | 522 | * @param visibleMemberMap the visible inherited members map |
bpatel@766 | 523 | * @param liNav the content tree to which the navigation summary link will be added |
bpatel@766 | 524 | */ |
bpatel@766 | 525 | protected void addNavSummaryLink(List<?> members, |
bpatel@766 | 526 | VisibleMemberMap visibleMemberMap, Content liNav) { |
duke@1 | 527 | if (members.size() > 0) { |
bpatel@766 | 528 | liNav.addContent(getNavSummaryLink(null, true)); |
duke@1 | 529 | return; |
bpatel@766 | 530 | } |
bpatel@766 | 531 | ClassDoc icd = classdoc.superclass(); |
bpatel@766 | 532 | while (icd != null) { |
bpatel@766 | 533 | List<?> inhmembers = visibleMemberMap.getMembersFor(icd); |
bpatel@766 | 534 | if (inhmembers.size() > 0) { |
bpatel@766 | 535 | liNav.addContent(getNavSummaryLink(icd, true)); |
bpatel@766 | 536 | return; |
duke@1 | 537 | } |
bpatel@766 | 538 | icd = icd.superclass(); |
duke@1 | 539 | } |
bpatel@766 | 540 | liNav.addContent(getNavSummaryLink(null, false)); |
duke@1 | 541 | } |
duke@1 | 542 | |
duke@1 | 543 | protected void serialWarning(SourcePosition pos, String key, String a1, String a2) { |
duke@1 | 544 | if (configuration().serialwarn) { |
duke@1 | 545 | ConfigurationImpl.getInstance().getDocletSpecificMsg().warning(pos, key, a1, a2); |
duke@1 | 546 | } |
duke@1 | 547 | } |
duke@1 | 548 | |
duke@1 | 549 | public ProgramElementDoc[] eligibleMembers(ProgramElementDoc[] members) { |
duke@1 | 550 | return nodepr? Util.excludeDeprecatedMembers(members): members; |
duke@1 | 551 | } |
duke@1 | 552 | |
duke@1 | 553 | public ConfigurationImpl configuration() { |
duke@1 | 554 | return writer.configuration; |
duke@1 | 555 | } |
duke@1 | 556 | |
duke@1 | 557 | /** |
bpatel@766 | 558 | * Add the member summary for the given class. |
bpatel@766 | 559 | * |
bpatel@766 | 560 | * @param classDoc the class that is being documented |
bpatel@766 | 561 | * @param member the member being documented |
bpatel@766 | 562 | * @param firstSentenceTags the first sentence tags to be added to the summary |
bpatel@766 | 563 | * @param tableTree the content tree to which the documentation will be added |
bpatel@766 | 564 | * @param counter the counter for determing style for the table row |
duke@1 | 565 | */ |
bpatel@766 | 566 | public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member, |
bpatel@766 | 567 | Tag[] firstSentenceTags, Content tableTree, int counter) { |
bpatel@766 | 568 | HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD); |
bpatel@766 | 569 | tdSummaryType.addStyle(HtmlStyle.colFirst); |
bpatel@766 | 570 | writer.addSummaryType(this, member, tdSummaryType); |
bpatel@766 | 571 | HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); |
bpatel@766 | 572 | setSummaryColumnStyle(tdSummary); |
bpatel@766 | 573 | addSummaryLink(classDoc, member, tdSummary); |
bpatel@766 | 574 | writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary); |
bpatel@766 | 575 | HtmlTree tr = HtmlTree.TR(tdSummaryType); |
bpatel@766 | 576 | tr.addContent(tdSummary); |
bpatel@766 | 577 | if (counter%2 == 0) |
bpatel@766 | 578 | tr.addStyle(HtmlStyle.altColor); |
bpatel@766 | 579 | else |
bpatel@766 | 580 | tr.addStyle(HtmlStyle.rowColor); |
bpatel@766 | 581 | tableTree.addContent(tr); |
bpatel@766 | 582 | } |
bpatel@766 | 583 | |
bpatel@766 | 584 | /** |
bpatel@766 | 585 | * Set the style for the summary column. |
bpatel@766 | 586 | * |
bpatel@766 | 587 | * @param tdTree the column for which the style will be set |
bpatel@766 | 588 | */ |
bpatel@766 | 589 | public void setSummaryColumnStyle(HtmlTree tdTree) { |
bpatel@766 | 590 | tdTree.addStyle(HtmlStyle.colLast); |
bpatel@766 | 591 | } |
bpatel@766 | 592 | |
bpatel@766 | 593 | /** |
bpatel@766 | 594 | * Add inherited member summary for the given class and member. |
bpatel@766 | 595 | * |
bpatel@766 | 596 | * @param classDoc the class the inherited member belongs to |
bpatel@766 | 597 | * @param nestedClass the inherited member that is summarized |
bpatel@766 | 598 | * @param isFirst true if this is the first member in the list |
bpatel@766 | 599 | * @param isLast true if this is the last member in the list |
bpatel@766 | 600 | * @param linksTree the content tree to which the summary will be added |
bpatel@766 | 601 | */ |
bpatel@766 | 602 | public void addInheritedMemberSummary(ClassDoc classDoc, |
bpatel@766 | 603 | ProgramElementDoc nestedClass, boolean isFirst, boolean isLast, |
bpatel@766 | 604 | Content linksTree) { |
bpatel@766 | 605 | writer.addInheritedMemberSummary(this, classDoc, nestedClass, isFirst, |
bpatel@766 | 606 | linksTree); |
bpatel@766 | 607 | } |
bpatel@766 | 608 | |
bpatel@766 | 609 | /** |
bpatel@766 | 610 | * Get the inherited summary header for the given class. |
bpatel@766 | 611 | * |
bpatel@766 | 612 | * @param classDoc the class the inherited member belongs to |
bpatel@766 | 613 | * @return a content tree for the inherited summary header |
bpatel@766 | 614 | */ |
bpatel@766 | 615 | public Content getInheritedSummaryHeader(ClassDoc classDoc) { |
bpatel@766 | 616 | Content inheritedTree = writer.getMemberTreeHeader(); |
bpatel@766 | 617 | writer.addInheritedSummaryHeader(this, classDoc, inheritedTree); |
bpatel@766 | 618 | return inheritedTree; |
bpatel@766 | 619 | } |
bpatel@766 | 620 | |
bpatel@766 | 621 | /** |
bpatel@766 | 622 | * Get the inherited summary links tree. |
bpatel@766 | 623 | * |
bpatel@766 | 624 | * @return a content tree for the inherited summary links |
bpatel@766 | 625 | */ |
bpatel@766 | 626 | public Content getInheritedSummaryLinksTree() { |
bpatel@766 | 627 | return new HtmlTree(HtmlTag.CODE); |
bpatel@766 | 628 | } |
bpatel@766 | 629 | |
bpatel@766 | 630 | /** |
bpatel@766 | 631 | * Get the summary table tree for the given class. |
bpatel@766 | 632 | * |
bpatel@766 | 633 | * @param classDoc the class for which the summary table is generated |
bpatel@766 | 634 | * @return a content tree for the summary table |
bpatel@766 | 635 | */ |
bpatel@766 | 636 | public Content getSummaryTableTree(ClassDoc classDoc) { |
bpatel@766 | 637 | return writer.getSummaryTableTree(this, classDoc); |
bpatel@766 | 638 | } |
bpatel@766 | 639 | |
bpatel@766 | 640 | /** |
bpatel@766 | 641 | * Get the member tree to be documented. |
bpatel@766 | 642 | * |
bpatel@766 | 643 | * @param memberTree the content tree of member to be documented |
bpatel@766 | 644 | * @return a content tree that will be added to the class documentation |
bpatel@766 | 645 | */ |
bpatel@766 | 646 | public Content getMemberTree(Content memberTree) { |
bpatel@766 | 647 | return writer.getMemberTree(memberTree); |
bpatel@766 | 648 | } |
bpatel@766 | 649 | |
bpatel@766 | 650 | /** |
bpatel@766 | 651 | * Get the member tree to be documented. |
bpatel@766 | 652 | * |
bpatel@766 | 653 | * @param memberTree the content tree of member to be documented |
bpatel@766 | 654 | * @param isLastContent true if the content to be added is the last content |
bpatel@766 | 655 | * @return a content tree that will be added to the class documentation |
bpatel@766 | 656 | */ |
bpatel@766 | 657 | public Content getMemberTree(Content memberTree, boolean isLastContent) { |
bpatel@766 | 658 | if (isLastContent) |
bpatel@766 | 659 | return HtmlTree.UL(HtmlStyle.blockListLast, memberTree); |
bpatel@766 | 660 | else |
bpatel@766 | 661 | return HtmlTree.UL(HtmlStyle.blockList, memberTree); |
duke@1 | 662 | } |
duke@1 | 663 | } |