Path: blob/master/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Doclet.java
41159 views
/*1* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package jdk.javadoc.doclet;2627import java.util.List;28import java.util.Locale;29import java.util.Set;3031import javax.lang.model.SourceVersion;3233/**34* The user doclet must implement this interface, as described in the35* <a href="package-summary.html#package-description">package description</a>.36* Each implementation of a Doclet must provide a public no-argument constructor37* to be used by tools to instantiate the doclet. The tool infrastructure will38* interact with classes implementing this interface as follows:39* <ol>40* <li> The tool will create an instance of a doclet using the no-arg constructor41* of the doclet class.42* <li> Next, the tool calls the {@link #init init} method with an appropriate locale43* and reporter.44* <li> Afterwards, the tool calls {@link #getSupportedOptions getSupportedOptions},45* and {@link #getSupportedSourceVersion getSupportedSourceVersion}.46* These methods are only called once.47* <li> As appropriate, the tool calls the {@link #run run} method on the doclet48* object, giving it a DocletEnvironment object, from which the doclet can determine49* the elements to be included in the documentation.50* </ol>51* <p>52* If a doclet object is created and used without the above protocol being followed,53* then the doclet's behavior is not defined by this interface specification.54* <p> To start the doclet, pass {@code -doclet} followed by the fully-qualified55* name of the entry point class (i.e. the implementation of this interface) on56* the javadoc tool command line.57*58* @since 959*/60public interface Doclet {6162/**63* Initializes this doclet with the given locale and error reporter.64* This locale will be used by the reporter and the doclet components.65*66* @param locale the locale to be used67* @param reporter the reporter to be used68*/69void init(Locale locale, Reporter reporter);7071/**72* Returns a name identifying the doclet. A name is a simple identifier73* without white spaces, as defined in <cite>The Java Language Specification</cite>,74* section 6.2 "Names and Identifiers".75*76* @return name of the Doclet77*/78String getName();7980/**81* Returns all the supported options.82*83* @return a set containing all the supported options, an empty set if none84*/85Set<? extends Option> getSupportedOptions();8687/**88* Returns the version of the Java Programming Language supported89* by this doclet.90*91* @return the language version supported by this doclet, usually92* the latest version93*/94SourceVersion getSupportedSourceVersion();9596/**97* The entry point of the doclet. Further processing will commence as98* instructed by this method.99*100* @param environment from which essential information can be extracted101* @return true on success102*/103boolean run(DocletEnvironment environment);104105/**106* An encapsulation of option name, aliases, parameters and descriptions107* as used by the Doclet.108*/109interface Option {110/**111* Returns the number of arguments, this option will consume.112* @return number of consumed arguments113*/114int getArgumentCount();115116/**117* Returns the description of the option. For instance, the option "group", would118* return the synopsis of the option such as, "groups the documents".119* @return description if set, otherwise an empty String120*/121String getDescription();122123/**124* Returns the option kind.125* @return the kind of this option126*/127Option.Kind getKind();128129/**130* Returns the list of names that may be used to identify the option. For instance, the131* list could be {@code ["-classpath", "--class-path"]} for the132* option "-classpath", with an alias "--class-path".133* @return the names of the option134*/135List<String> getNames();136137/**138* Returns the parameters of the option. For instance "name <p1>:<p2>.."139* @return parameters if set, otherwise an empty String140*/141String getParameters();142143/**144* Processes the option and arguments as needed. This method will145* be invoked if the given option name matches the option.146* @param option the option147* @param arguments a list encapsulating the arguments148* @return true if operation succeeded, false otherwise149*/150boolean process(String option, List<String> arguments);151152/**153* The kind of an option.154*/155enum Kind {156/** An extended option, such as those prefixed with {@code -X}. */157EXTENDED,158/** A standard option. */159STANDARD,160/** An implementation-reserved option. */161OTHER;162}163}164}165166167