1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/javadoc/package-info.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,148 @@ 1.4 +/* 1.5 + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +/** 1.30 +The Doclet API (also called the Javadoc API) provides a mechanism 1.31 +for clients to inspect the source-level structure of programs and 1.32 +libraries, including javadoc comments embedded in the source. 1.33 +This is useful for documentation, program checking, automatic 1.34 +code generation and many other tools. 1.35 +<p> 1.36 + 1.37 +Doclets are invoked by javadoc and use this API to write out 1.38 +program information to files. For example, the standard doclet is called 1.39 +by default and writes out documentation to HTML files. 1.40 +<p> 1.41 + 1.42 +The invocation is defined by the abstract {@link com.sun.javadoc.Doclet} class 1.43 +-- the entry point is the {@link com.sun.javadoc.Doclet#start(RootDoc) start} method: 1.44 +<pre> 1.45 + public static boolean <b>start</b>(RootDoc root) 1.46 +</pre> 1.47 +The {@link com.sun.javadoc.RootDoc} instance holds the root of the program structure 1.48 +information. From this root all other program structure 1.49 +information can be extracted. 1.50 +<p> 1.51 + 1.52 +<a name="terminology"></a> 1.53 +<h3>Terminology</h3> 1.54 + 1.55 +<a name="included"></a> 1.56 +When calling javadoc, you pass in package names and source file names -- 1.57 +these are called the <em>specified</em> packages and classes. 1.58 +You also pass in Javadoc options; the <em>access control</em> Javadoc options 1.59 +(<code>-public</code>, <code>-protected</code>, <code>-package</code>, 1.60 +and <code>-private</code>) filter program elements, producing a 1.61 +result set, called the <em>included</em> set, or "documented" set. 1.62 +(The unfiltered set is also available through 1.63 +{@link com.sun.javadoc.PackageDoc#allClasses(boolean) allClasses(false)}.) 1.64 +<p> 1.65 + 1.66 +<a name="class"></a> 1.67 +Throughout this API, the term <em>class</em> is normally a 1.68 +shorthand for "class or interface", as in: {@link com.sun.javadoc.ClassDoc}, 1.69 +{@link com.sun.javadoc.PackageDoc#allClasses() allClasses()}, and 1.70 +{@link com.sun.javadoc.PackageDoc#findClass(String) findClass(String)}. 1.71 +In only a couple of other places, it means "class, as opposed to interface", 1.72 +as in: {@link com.sun.javadoc.Doc#isClass()}. 1.73 +In the second sense, this API calls out four kinds of classes: 1.74 +{@linkplain com.sun.javadoc.Doc#isOrdinaryClass() ordinary classes}, 1.75 +{@linkplain com.sun.javadoc.Doc#isEnum() enums}, 1.76 +{@linkplain com.sun.javadoc.Doc#isError() errors} and 1.77 +{@linkplain com.sun.javadoc.Doc#isException() exceptions}. 1.78 +Throughout the API, the detailed description of each program element 1.79 +describes explicitly which meaning is being used. 1.80 +<p> 1.81 + 1.82 +<a name="qualified"></a> 1.83 +A <em>qualified</em> class or interface name is one that has its package 1.84 +name prepended to it, such as <code>java.lang.String</code>. A non-qualified 1.85 +name has no package name, such as <code>String</code>. 1.86 +<p> 1.87 + 1.88 +<a name="example"></a> 1.89 +<h3>Example</h3> 1.90 + 1.91 +The following is an example doclet that 1.92 +displays information in the <code>@param</code> tags of the processed 1.93 +classes: 1.94 +<pre> 1.95 +import com.sun.javadoc.*; 1.96 + 1.97 +public class ListParams extends <font color=red title="Doclet API">Doclet</font> { 1.98 + 1.99 + public static boolean start(<font color=red title="Doclet API">RootDoc</font> root) { 1.100 + <font color=red title="Doclet API">ClassDoc</font>[] classes = root.<font color=red title="Doclet API">classes</font>(); 1.101 + for (int i = 0; i < classes.length; ++i) { 1.102 + <font color=red title="Doclet API">ClassDoc</font> cd = classes[i]; 1.103 + printMembers(cd.<font color=red title="Doclet API">constructors</font>()); 1.104 + printMembers(cd.<font color=red title="Doclet API">methods</font>()); 1.105 + } 1.106 + return true; 1.107 + } 1.108 + 1.109 + static void printMembers(<font color=red title="Doclet API">ExecutableMemberDoc</font>[] mems) { 1.110 + for (int i = 0; i < mems.length; ++i) { 1.111 + <font color=red title="Doclet API">ParamTag</font>[] params = mems[i].<font color=red title="Doclet API">paramTags</font>(); 1.112 + System.out.println(mems[i].<font color=red title="Doclet API">qualifiedName</font>()); 1.113 + for (int j = 0; j < params.length; ++j) { 1.114 + System.out.println(" " + params[j].<font color=red title="Doclet API">parameterName</font>() 1.115 + + " - " + params[j].<font color=red title="Doclet API">parameterComment</font>()); 1.116 + } 1.117 + } 1.118 + } 1.119 +} 1.120 +</pre> 1.121 +Interfaces and methods from the Javadoc API are marked in 1.122 +<font color=red title="Doclet API">red</font>. 1.123 +{@link com.sun.javadoc.Doclet Doclet} is an abstract class that specifies 1.124 +the invocation interface for doclets, 1.125 +{@link com.sun.javadoc.Doclet Doclet} holds class or interface information, 1.126 +{@link com.sun.javadoc.ExecutableMemberDoc} is a 1.127 +superinterface of {@link com.sun.javadoc.MethodDoc} and 1.128 +{@link com.sun.javadoc.ConstructorDoc}, 1.129 +and {@link com.sun.javadoc.ParamTag} holds information 1.130 +from "<code>@param</code>" tags. 1.131 +<p> 1.132 +This doclet when invoked with a command line like: 1.133 +<pre> 1.134 + javadoc -doclet ListParams -sourcepath <source-location> java.util 1.135 +</pre> 1.136 +producing output like: 1.137 +<pre> 1.138 + ... 1.139 + java.util.ArrayList.add 1.140 + index - index at which the specified element is to be inserted. 1.141 + element - element to be inserted. 1.142 + java.util.ArrayList.remove 1.143 + index - the index of the element to removed. 1.144 + ... 1.145 + 1.146 +</pre> 1.147 +@see com.sun.javadoc.Doclet 1.148 +@see com.sun.javadoc.RootDoc 1.149 +*/ 1.150 +@jdk.Exported 1.151 +package com.sun.javadoc;