langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Taglet.java
author jjg
Thu, 23 Mar 2017 10:58:16 -0700
changeset 44388 4d0903f1f311
parent 44189 dd311cfb920b
child 44688 7ef050121b50
permissions -rw-r--r--
8176836: Provide Taglet with context Reviewed-by: ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     1
/*
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
     2
 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     4
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    10
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    15
 * accompanied this code).
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    16
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    20
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    23
 * questions.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    24
 */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    25
44189
dd311cfb920b 8176331: Simplify new doclet packages
jjg
parents: 44180
diff changeset
    26
package jdk.javadoc.doclet;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    27
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    28
import java.util.List;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    29
import java.util.Set;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    30
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    31
import javax.lang.model.element.Element;
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    32
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    33
import com.sun.source.doctree.DocTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    34
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    35
/**
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    36
 * The interface for a custom taglet supported by doclets such as
44189
dd311cfb920b 8176331: Simplify new doclet packages
jjg
parents: 44180
diff changeset
    37
 * the {@link jdk.javadoc.doclet.StandardDoclet standard doclet}.
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    38
 * Custom taglets are used to handle custom tags in documentation
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    39
 * comments.
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    40
 *
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    41
 * <p>A custom taglet must implement this interface, and must have
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    42
 * a public default constructor (i.e. a public constructor with no
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    43
 * parameters), by which, the doclet will instantiate and
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    44
 * register the custom taglet.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    45
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    46
 * @since 9
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    47
 */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    48
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    49
public interface Taglet {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    50
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    51
    /**
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    52
     * Returns the set of locations in which a tag may be used.
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    53
     * @return the set of locations in which a tag may be used
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    54
     */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    55
    Set<Location> getAllowedLocations();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    56
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    57
    /**
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    58
     * Indicates whether this taglet is for inline tags or not.
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    59
     * @return true if this taglet is for an inline tag, and false otherwise
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    60
     */
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 38911
diff changeset
    61
    boolean isInlineTag();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    62
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    63
    /**
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    64
     * Returns the name of the tag.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    65
     * @return the name of this custom tag.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    66
     */
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 38911
diff changeset
    67
    String getName();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    68
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    69
    /**
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    70
     * Initializes this taglet with the given doclet environment and doclet.
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    71
     *
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    72
     * @apiNote
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    73
     * The environment may be used to access utility classes for
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    74
     * {@link javax.lang.model.util.Elements elements} and
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    75
     * {@link javax.lang.model.util.Types types} if needed.
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    76
     *
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    77
     * @implSpec
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    78
     * This implementation does nothing.
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    79
     *
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    80
     * @param env the environment in which the doclet and taglet are running
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    81
     * @param doclet the doclet that instantiated this taglet
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    82
     */
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    83
    default void init(DocletEnvironment env, Doclet doclet) { }
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    84
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    85
    /**
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    86
     * Returns the string representation of a series of instances of
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    87
     * this tag to be included in the generated output.
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    88
     * If this taglet is for an {@link #isInlineTag inline} tag} it will
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    89
     * be called once per instance of the tag, each time with a singleton list.
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    90
     * Otherwise, if this tag is a block tag, it will be called once per
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    91
     * comment, with a list of all the instances of the tag in a comment.
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    92
     * @param tags the list of instances of this tag
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    93
     * @param element the element to which the enclosing comment belongs
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    94
     * @return the string representation of the tags to be included in
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
    95
     *  the generated output
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    96
     */
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    97
    String toString(List<? extends DocTree> tags, Element element);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    98
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    99
    /**
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 42277
diff changeset
   100
     * The kind of location in which a tag may be used.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   101
     */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   102
    public static enum Location {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   103
        /** In an Overview document. */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   104
        OVERVIEW,
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
   105
        /** In the documentation for a module. */
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
   106
        MODULE,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   107
        /** In the documentation for a package. */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   108
        PACKAGE,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   109
        /** In the documentation for a class, interface or enum. */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   110
        TYPE,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   111
        /** In the documentation for a constructor. */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   112
        CONSTRUCTOR,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   113
        /** In the documentation for a method. */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   114
        METHOD,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   115
        /** In the documentation for a field. */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   116
        FIELD
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   117
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   118
}