langtools/src/jdk.javadoc/share/classes/com/sun/javadoc/Doclet.java
changeset 25874 83c19f00452c
parent 23136 aa8958a4c8f4
child 38617 d93a7f64e231
equal deleted inserted replaced
25873:024ed9c9ed13 25874:83c19f00452c
       
     1 /*
       
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package com.sun.javadoc;
       
    27 
       
    28 /**
       
    29  * This is an example of a starting class for a doclet,
       
    30  * showing the entry-point methods.  A starting class must
       
    31  * import com.sun.javadoc.* and implement the
       
    32  * {@code start(RootDoc)} method, as described in the
       
    33  * <a href="package-summary.html#package_description">package
       
    34  * description</a>.  If the doclet takes command line options,
       
    35  * it must also implement {@code optionLength} and
       
    36  * {@code validOptions}.
       
    37  *
       
    38  * <p> A doclet supporting the language features added since 1.1
       
    39  * (such as generics and annotations) should indicate this
       
    40  * by implementing {@code languageVersion}.  In the absence of
       
    41  * this the doclet should not invoke any of the Doclet API methods
       
    42  * added since 1.5, and
       
    43  * the results of several other methods are modified so as
       
    44  * to conceal the new constructs (such as type parameters) from
       
    45  * the doclet.
       
    46  *
       
    47  * <p> To start the doclet, pass
       
    48  * {@code -doclet} followed by the fully-qualified
       
    49  * name of the starting class on the javadoc tool command line.
       
    50  */
       
    51 public abstract class Doclet {
       
    52 
       
    53     /**
       
    54      * Generate documentation here.
       
    55      * This method is required for all doclets.
       
    56      *
       
    57      * @param root Supply the RootDoc to the method.
       
    58      * @return true on success.
       
    59      */
       
    60     public static boolean start(RootDoc root) {
       
    61         return true;
       
    62     }
       
    63 
       
    64     /**
       
    65      * Check for doclet-added options.  Returns the number of
       
    66      * arguments you must specify on the command line for the
       
    67      * given option.  For example, "-d docs" would return 2.
       
    68      * <P>
       
    69      * This method is required if the doclet contains any options.
       
    70      * If this method is missing, Javadoc will print an invalid flag
       
    71      * error for every option.
       
    72      *
       
    73      * @param option the option for which the number of arguements is returned.
       
    74      * @return number of arguments on the command line for an option
       
    75      *         including the option name itself.  Zero return means
       
    76      *         option not known.  Negative value means error occurred.
       
    77      */
       
    78     public static int optionLength(String option) {
       
    79         return 0;  // default is option unknown
       
    80     }
       
    81 
       
    82     /**
       
    83      * Check that options have the correct arguments.
       
    84      * <P>
       
    85      * This method is not required, but is recommended,
       
    86      * as every option will be considered valid if this method
       
    87      * is not present.  It will default gracefully (to true)
       
    88      * if absent.
       
    89      * <P>
       
    90      * Printing option related error messages (using the provided
       
    91      * DocErrorReporter) is the responsibility of this method.
       
    92      *
       
    93      * @param options Supply valid options as an array of Strings.
       
    94      * @param reporter The DocErrorReporter responsible for these options.
       
    95      * @return true if the options are valid.
       
    96      */
       
    97     public static boolean validOptions(String options[][],
       
    98                                        DocErrorReporter reporter) {
       
    99         return true;  // default is options are valid
       
   100     }
       
   101 
       
   102     /**
       
   103      * Return the version of the Java Programming Language supported
       
   104      * by this doclet.
       
   105      * <p>
       
   106      * This method is required by any doclet supporting a language version
       
   107      * newer than 1.1.
       
   108      *
       
   109      * @return  the language version supported by this doclet.
       
   110      * @since 1.5
       
   111      */
       
   112     public static LanguageVersion languageVersion() {
       
   113         return LanguageVersion.JAVA_1_1;
       
   114     }
       
   115 }