0N/A/*
1194N/A * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.doclets.internal.toolkit.taglets;
0N/A
0N/Aimport com.sun.tools.doclets.internal.toolkit.*;
0N/Aimport com.sun.tools.doclets.internal.toolkit.util.*;
0N/Aimport com.sun.javadoc.*;
0N/A
0N/A/**
0N/A * The interface for the taglet writer.
0N/A *
0N/A * @since 1.5
0N/A * @author Jamie Ho
0N/A */
0N/A
0N/Apublic abstract class TagletWriter {
0N/A
0N/A /**
0N/A * True if we only want to write the first sentence.
0N/A */
0N/A protected boolean isFirstSentence = false;
0N/A
0N/A /**
0N/A * @return an instance of the output object.
0N/A */
0N/A public abstract TagletOutput getOutputInstance();
0N/A
0N/A /**
0N/A * Returns the output for the DocRoot inline tag.
0N/A * @return the output for the DocRoot inline tag.
0N/A */
0N/A protected abstract TagletOutput getDocRootOutput();
0N/A
0N/A /**
0N/A * Return the deprecated tag output.
0N/A *
0N/A * @param doc the doc to write deprecated documentation for.
0N/A * @return the output of the deprecated tag.
0N/A */
0N/A protected abstract TagletOutput deprecatedTagOutput(Doc doc);
0N/A
0N/A /**
0N/A * Returns {@link MessageRetriever} for output purposes.
0N/A *
0N/A * @return {@link MessageRetriever} for output purposes.
0N/A */
0N/A protected abstract MessageRetriever getMsgRetriever();
0N/A
0N/A /**
0N/A * Return the header for the param tags.
0N/A *
0N/A * @param header the header to display.
0N/A * @return the header for the param tags.
0N/A */
0N/A protected abstract TagletOutput getParamHeader(String header);
0N/A
0N/A /**
0N/A * Return the output for param tags.
0N/A *
0N/A * @param paramTag the parameter to document.
0N/A * @param paramName the name of the parameter.
0N/A * @return the output of the param tag.
0N/A */
0N/A protected abstract TagletOutput paramTagOutput(ParamTag paramTag,
0N/A String paramName);
0N/A
0N/A /**
0N/A * Return the return tag output.
0N/A *
0N/A * @param returnTag the return tag to output.
0N/A * @return the output of the return tag.
0N/A */
0N/A protected abstract TagletOutput returnTagOutput(Tag returnTag);
0N/A
0N/A /**
0N/A * Return the see tag output.
0N/A *
0N/A * @param seeTags the array of See tags.
0N/A * @return the output of the see tags.
0N/A */
0N/A protected abstract TagletOutput seeTagOutput(Doc holder, SeeTag[] seeTags);
0N/A
0N/A /**
0N/A * Return the output for a simple tag.
0N/A *
0N/A * @param simpleTags the array of simple tags.
0N/A * @return the output of the simple tags.
0N/A */
0N/A protected abstract TagletOutput simpleTagOutput(Tag[] simpleTags,
0N/A String header);
0N/A
0N/A /**
0N/A * Return the output for a simple tag.
0N/A *
0N/A * @param simpleTag the simple tag.
0N/A * @return the output of the simple tag.
0N/A */
0N/A protected abstract TagletOutput simpleTagOutput(Tag simpleTag, String header);
0N/A
0N/A /**
0N/A * Return the header for the throws tag.
0N/A *
0N/A * @return the header for the throws tag.
0N/A */
0N/A protected abstract TagletOutput getThrowsHeader();
0N/A
0N/A /**
0N/A * Return the header for the throws tag.
0N/A *
0N/A * @param throwsTag the throws tag.
0N/A * @return the output of the throws tag.
0N/A */
0N/A protected abstract TagletOutput throwsTagOutput(ThrowsTag throwsTag);
0N/A
0N/A /**
0N/A * Return the output for the throws tag.
0N/A *
0N/A * @param throwsType the throws type.
0N/A * @return the output of the throws type.
0N/A */
0N/A protected abstract TagletOutput throwsTagOutput(Type throwsType);
0N/A
0N/A /**
0N/A * Return the output for the value tag.
0N/A *
0N/A * @param field the constant field that holds the value tag.
0N/A * @param constantVal the constant value to document.
0N/A * @param includeLink true if we should link the constant text to the
0N/A * constant field itself.
0N/A * @return the output of the value tag.
0N/A */
0N/A protected abstract TagletOutput valueTagOutput(FieldDoc field,
0N/A String constantVal, boolean includeLink);
0N/A
0N/A /**
0N/A * Given an output object, append to it the tag documentation for
0N/A * the given member.
0N/A *
0N/A * @param tagletManager the manager that manages the taglets.
0N/A * @param doc the Doc that we are print tags for.
0N/A * @param taglets the taglets to print.
0N/A * @param writer the writer that will generate the output strings.
0N/A * @param output the output buffer to store the output in.
0N/A */
0N/A public static void genTagOuput(TagletManager tagletManager, Doc doc,
0N/A Taglet[] taglets, TagletWriter writer, TagletOutput output) {
0N/A tagletManager.checkTags(doc, doc.tags(), false);
0N/A tagletManager.checkTags(doc, doc.inlineTags(), true);
0N/A TagletOutput currentOutput = null;
0N/A for (int i = 0; i < taglets.length; i++) {
1194N/A currentOutput = null;
0N/A if (doc instanceof ClassDoc && taglets[i] instanceof ParamTaglet) {
0N/A //The type parameters are documented in a special section away
0N/A //from the tag info, so skip here.
0N/A continue;
0N/A }
0N/A if (taglets[i] instanceof DeprecatedTaglet) {
0N/A //Deprecated information is documented "inline", not in tag info
0N/A //section.
0N/A continue;
0N/A }
0N/A try {
0N/A currentOutput = taglets[i].getTagletOutput(doc, writer);
0N/A } catch (IllegalArgumentException e) {
0N/A //The taglet does not take a member as an argument. Let's try
0N/A //a single tag.
0N/A Tag[] tags = doc.tags(taglets[i].getName());
0N/A if (tags.length > 0) {
0N/A currentOutput = taglets[i].getTagletOutput(tags[0], writer);
0N/A }
0N/A }
0N/A if (currentOutput != null) {
0N/A tagletManager.seenCustomTag(taglets[i].getName());
0N/A output.appendOutput(currentOutput);
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Given an inline tag, return its output.
0N/A * @param tagletManager The taglet manager for the current doclet.
0N/A * @param holderTag The tag this holds this inline tag. Null if there
0N/A * is no tag that holds it.
0N/A * @param inlineTag The inline tag to be documented.
0N/A * @param tagletWriter The taglet writer to write the output.
0N/A * @return The output of the inline tag.
0N/A */
0N/A public static TagletOutput getInlineTagOuput(TagletManager tagletManager,
0N/A Tag holderTag, Tag inlineTag, TagletWriter tagletWriter) {
0N/A Taglet[] definedTags = tagletManager.getInlineCustomTags();
0N/A //This is a custom inline tag.
0N/A for (int j = 0; j < definedTags.length; j++) {
0N/A if (("@"+definedTags[j].getName()).equals(inlineTag.name())) {
0N/A //Given a name of a seen custom tag, remove it from the
0N/A // set of unseen custom tags.
0N/A tagletManager.seenCustomTag(definedTags[j].getName());
0N/A TagletOutput output = definedTags[j].getTagletOutput(
0N/A holderTag != null &&
0N/A definedTags[j].getName().equals("inheritDoc") ?
0N/A holderTag : inlineTag, tagletWriter);
0N/A return output;
0N/A }
0N/A }
0N/A return null;
0N/A }
0N/A
0N/A /**
0N/A * Converts inline tags and text to TagOutput, expanding the
0N/A * inline tags along the way. Called wherever text can contain
0N/A * an inline tag, such as in comments or in free-form text arguments
0N/A * to non-inline tags.
0N/A *
0N/A * @param holderTag the tag that holds the documentation.
0N/A * @param tags array of text tags and inline tags (often alternating)
0N/A * present in the text of interest for this doc.
0N/A * @return the {@link TagletOutput} representing the comments.
0N/A */
0N/A public abstract TagletOutput commentTagsToOutput(Tag holderTag, Tag[] tags);
0N/A
0N/A /**
0N/A * Converts inline tags and text to TagOutput, expanding the
0N/A * inline tags along the way. Called wherever text can contain
0N/A * an inline tag, such as in comments or in free-form text arguments
0N/A * to non-inline tags.
0N/A *
0N/A * @param holderDoc specific doc where comment resides.
0N/A * @param tags array of text tags and inline tags (often alternating)
0N/A * present in the text of interest for this doc.
0N/A * @return the {@link TagletOutput} representing the comments.
0N/A */
0N/A public abstract TagletOutput commentTagsToOutput(Doc holderDoc, Tag[] tags);
0N/A
0N/A /**
0N/A * Converts inline tags and text to TagOutput, expanding the
0N/A * inline tags along the way. Called wherever text can contain
0N/A * an inline tag, such as in comments or in free-form text arguments
0N/A * to non-inline tags.
0N/A *
0N/A * @param holderTag the tag that holds the documentation.
0N/A * @param holderDoc specific doc where comment resides.
0N/A * @param tags array of text tags and inline tags (often alternating)
0N/A * present in the text of interest for this doc.
0N/A * @param isFirstSentence true if this is the first sentence.
0N/A * @return the {@link TagletOutput} representing the comments.
0N/A */
0N/A public abstract TagletOutput commentTagsToOutput(Tag holderTag,
0N/A Doc holderDoc, Tag[] tags, boolean isFirstSentence);
0N/A
0N/A /**
0N/A * @return an instance of the configuration used for this doclet.
0N/A */
0N/A public abstract Configuration configuration();
0N/A
0N/A /**
0N/A * @return an instance of the taglet output object.
0N/A */
0N/A public abstract TagletOutput getTagletOutputInstance();
0N/A}