src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java

Sat, 08 Sep 2012 22:43:38 -0700

author
bpatel
date
Sat, 08 Sep 2012 22:43:38 -0700
changeset 1324
fa85af323d97
parent 554
9d9f26857129
child 1357
c75be5bc5283
permissions
-rw-r--r--

7180906: Javadoc tool does not apply parameter -nosince
Reviewed-by: jjg

duke@1 1 /*
ohair@554 2 * Copyright (c) 2003, 2005, 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.internal.toolkit.taglets;
duke@1 27
duke@1 28 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 29 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 30 import com.sun.javadoc.*;
duke@1 31
duke@1 32 /**
duke@1 33 * The interface for the taglet writer.
duke@1 34 *
duke@1 35 * @since 1.5
duke@1 36 * @author Jamie Ho
duke@1 37 */
duke@1 38
duke@1 39 public abstract class TagletWriter {
duke@1 40
duke@1 41 /**
duke@1 42 * True if we only want to write the first sentence.
duke@1 43 */
duke@1 44 protected boolean isFirstSentence = false;
duke@1 45
duke@1 46 /**
duke@1 47 * @return an instance of the output object.
duke@1 48 */
duke@1 49 public abstract TagletOutput getOutputInstance();
duke@1 50
duke@1 51 /**
duke@1 52 * Returns the output for the DocRoot inline tag.
duke@1 53 * @return the output for the DocRoot inline tag.
duke@1 54 */
duke@1 55 protected abstract TagletOutput getDocRootOutput();
duke@1 56
duke@1 57 /**
duke@1 58 * Return the deprecated tag output.
duke@1 59 *
duke@1 60 * @param doc the doc to write deprecated documentation for.
duke@1 61 * @return the output of the deprecated tag.
duke@1 62 */
duke@1 63 protected abstract TagletOutput deprecatedTagOutput(Doc doc);
duke@1 64
duke@1 65 /**
duke@1 66 * Returns {@link MessageRetriever} for output purposes.
duke@1 67 *
duke@1 68 * @return {@link MessageRetriever} for output purposes.
duke@1 69 */
duke@1 70 protected abstract MessageRetriever getMsgRetriever();
duke@1 71
duke@1 72 /**
duke@1 73 * Return the header for the param tags.
duke@1 74 *
duke@1 75 * @param header the header to display.
duke@1 76 * @return the header for the param tags.
duke@1 77 */
duke@1 78 protected abstract TagletOutput getParamHeader(String header);
duke@1 79
duke@1 80 /**
duke@1 81 * Return the output for param tags.
duke@1 82 *
duke@1 83 * @param paramTag the parameter to document.
duke@1 84 * @param paramName the name of the parameter.
duke@1 85 * @return the output of the param tag.
duke@1 86 */
duke@1 87 protected abstract TagletOutput paramTagOutput(ParamTag paramTag,
duke@1 88 String paramName);
duke@1 89
duke@1 90 /**
duke@1 91 * Return the return tag output.
duke@1 92 *
duke@1 93 * @param returnTag the return tag to output.
duke@1 94 * @return the output of the return tag.
duke@1 95 */
duke@1 96 protected abstract TagletOutput returnTagOutput(Tag returnTag);
duke@1 97
duke@1 98 /**
duke@1 99 * Return the see tag output.
duke@1 100 *
duke@1 101 * @param seeTags the array of See tags.
duke@1 102 * @return the output of the see tags.
duke@1 103 */
duke@1 104 protected abstract TagletOutput seeTagOutput(Doc holder, SeeTag[] seeTags);
duke@1 105
duke@1 106 /**
duke@1 107 * Return the output for a simple tag.
duke@1 108 *
duke@1 109 * @param simpleTags the array of simple tags.
duke@1 110 * @return the output of the simple tags.
duke@1 111 */
duke@1 112 protected abstract TagletOutput simpleTagOutput(Tag[] simpleTags,
duke@1 113 String header);
duke@1 114
duke@1 115 /**
duke@1 116 * Return the output for a simple tag.
duke@1 117 *
duke@1 118 * @param simpleTag the simple tag.
duke@1 119 * @return the output of the simple tag.
duke@1 120 */
duke@1 121 protected abstract TagletOutput simpleTagOutput(Tag simpleTag, String header);
duke@1 122
duke@1 123 /**
duke@1 124 * Return the header for the throws tag.
duke@1 125 *
duke@1 126 * @return the header for the throws tag.
duke@1 127 */
duke@1 128 protected abstract TagletOutput getThrowsHeader();
duke@1 129
duke@1 130 /**
duke@1 131 * Return the header for the throws tag.
duke@1 132 *
duke@1 133 * @param throwsTag the throws tag.
duke@1 134 * @return the output of the throws tag.
duke@1 135 */
duke@1 136 protected abstract TagletOutput throwsTagOutput(ThrowsTag throwsTag);
duke@1 137
duke@1 138 /**
duke@1 139 * Return the output for the throws tag.
duke@1 140 *
duke@1 141 * @param throwsType the throws type.
duke@1 142 * @return the output of the throws type.
duke@1 143 */
duke@1 144 protected abstract TagletOutput throwsTagOutput(Type throwsType);
duke@1 145
duke@1 146 /**
duke@1 147 * Return the output for the value tag.
duke@1 148 *
duke@1 149 * @param field the constant field that holds the value tag.
duke@1 150 * @param constantVal the constant value to document.
duke@1 151 * @param includeLink true if we should link the constant text to the
duke@1 152 * constant field itself.
duke@1 153 * @return the output of the value tag.
duke@1 154 */
duke@1 155 protected abstract TagletOutput valueTagOutput(FieldDoc field,
duke@1 156 String constantVal, boolean includeLink);
duke@1 157
duke@1 158 /**
duke@1 159 * Given an output object, append to it the tag documentation for
duke@1 160 * the given member.
duke@1 161 *
duke@1 162 * @param tagletManager the manager that manages the taglets.
duke@1 163 * @param doc the Doc that we are print tags for.
duke@1 164 * @param taglets the taglets to print.
duke@1 165 * @param writer the writer that will generate the output strings.
duke@1 166 * @param output the output buffer to store the output in.
duke@1 167 */
duke@1 168 public static void genTagOuput(TagletManager tagletManager, Doc doc,
duke@1 169 Taglet[] taglets, TagletWriter writer, TagletOutput output) {
duke@1 170 tagletManager.checkTags(doc, doc.tags(), false);
duke@1 171 tagletManager.checkTags(doc, doc.inlineTags(), true);
duke@1 172 TagletOutput currentOutput = null;
duke@1 173 for (int i = 0; i < taglets.length; i++) {
duke@1 174 if (doc instanceof ClassDoc && taglets[i] instanceof ParamTaglet) {
duke@1 175 //The type parameters are documented in a special section away
duke@1 176 //from the tag info, so skip here.
duke@1 177 continue;
duke@1 178 }
duke@1 179 if (taglets[i] instanceof DeprecatedTaglet) {
duke@1 180 //Deprecated information is documented "inline", not in tag info
duke@1 181 //section.
duke@1 182 continue;
duke@1 183 }
duke@1 184 try {
duke@1 185 currentOutput = taglets[i].getTagletOutput(doc, writer);
duke@1 186 } catch (IllegalArgumentException e) {
duke@1 187 //The taglet does not take a member as an argument. Let's try
duke@1 188 //a single tag.
duke@1 189 Tag[] tags = doc.tags(taglets[i].getName());
duke@1 190 if (tags.length > 0) {
duke@1 191 currentOutput = taglets[i].getTagletOutput(tags[0], writer);
duke@1 192 }
duke@1 193 }
duke@1 194 if (currentOutput != null) {
duke@1 195 tagletManager.seenCustomTag(taglets[i].getName());
duke@1 196 output.appendOutput(currentOutput);
duke@1 197 }
duke@1 198 }
duke@1 199 }
duke@1 200
duke@1 201 /**
duke@1 202 * Given an inline tag, return its output.
duke@1 203 * @param tagletManager The taglet manager for the current doclet.
duke@1 204 * @param holderTag The tag this holds this inline tag. Null if there
duke@1 205 * is no tag that holds it.
duke@1 206 * @param inlineTag The inline tag to be documented.
duke@1 207 * @param tagletWriter The taglet writer to write the output.
duke@1 208 * @return The output of the inline tag.
duke@1 209 */
duke@1 210 public static TagletOutput getInlineTagOuput(TagletManager tagletManager,
duke@1 211 Tag holderTag, Tag inlineTag, TagletWriter tagletWriter) {
duke@1 212 Taglet[] definedTags = tagletManager.getInlineCustomTags();
duke@1 213 //This is a custom inline tag.
duke@1 214 for (int j = 0; j < definedTags.length; j++) {
duke@1 215 if (("@"+definedTags[j].getName()).equals(inlineTag.name())) {
duke@1 216 //Given a name of a seen custom tag, remove it from the
duke@1 217 // set of unseen custom tags.
duke@1 218 tagletManager.seenCustomTag(definedTags[j].getName());
duke@1 219 TagletOutput output = definedTags[j].getTagletOutput(
duke@1 220 holderTag != null &&
duke@1 221 definedTags[j].getName().equals("inheritDoc") ?
duke@1 222 holderTag : inlineTag, tagletWriter);
duke@1 223 return output;
duke@1 224 }
duke@1 225 }
duke@1 226 return null;
duke@1 227 }
duke@1 228
duke@1 229 /**
duke@1 230 * Converts inline tags and text to TagOutput, expanding the
duke@1 231 * inline tags along the way. Called wherever text can contain
duke@1 232 * an inline tag, such as in comments or in free-form text arguments
duke@1 233 * to non-inline tags.
duke@1 234 *
duke@1 235 * @param holderTag the tag that holds the documentation.
duke@1 236 * @param tags array of text tags and inline tags (often alternating)
duke@1 237 * present in the text of interest for this doc.
duke@1 238 * @return the {@link TagletOutput} representing the comments.
duke@1 239 */
duke@1 240 public abstract TagletOutput commentTagsToOutput(Tag holderTag, Tag[] tags);
duke@1 241
duke@1 242 /**
duke@1 243 * Converts inline tags and text to TagOutput, expanding the
duke@1 244 * inline tags along the way. Called wherever text can contain
duke@1 245 * an inline tag, such as in comments or in free-form text arguments
duke@1 246 * to non-inline tags.
duke@1 247 *
duke@1 248 * @param holderDoc specific doc where comment resides.
duke@1 249 * @param tags array of text tags and inline tags (often alternating)
duke@1 250 * present in the text of interest for this doc.
duke@1 251 * @return the {@link TagletOutput} representing the comments.
duke@1 252 */
duke@1 253 public abstract TagletOutput commentTagsToOutput(Doc holderDoc, Tag[] tags);
duke@1 254
duke@1 255 /**
duke@1 256 * Converts inline tags and text to TagOutput, expanding the
duke@1 257 * inline tags along the way. Called wherever text can contain
duke@1 258 * an inline tag, such as in comments or in free-form text arguments
duke@1 259 * to non-inline tags.
duke@1 260 *
duke@1 261 * @param holderTag the tag that holds the documentation.
duke@1 262 * @param holderDoc specific doc where comment resides.
duke@1 263 * @param tags array of text tags and inline tags (often alternating)
duke@1 264 * present in the text of interest for this doc.
duke@1 265 * @param isFirstSentence true if this is the first sentence.
duke@1 266 * @return the {@link TagletOutput} representing the comments.
duke@1 267 */
duke@1 268 public abstract TagletOutput commentTagsToOutput(Tag holderTag,
duke@1 269 Doc holderDoc, Tag[] tags, boolean isFirstSentence);
duke@1 270
duke@1 271 /**
duke@1 272 * @return an instance of the configuration used for this doclet.
duke@1 273 */
duke@1 274 public abstract Configuration configuration();
duke@1 275
duke@1 276 /**
duke@1 277 * @return an instance of the taglet output object.
duke@1 278 */
duke@1 279 public abstract TagletOutput getTagletOutputInstance();
duke@1 280 }

mercurial