pJs$d!"(J
javadoc $B$,F0:n$7$F$$$k%/%i%9$d%Q%C%1!<%8$K$D$$$F$N>pJs$,$"$j$^$9!#(J
RootDoc $B$O!"(J
Javadoc $B$K$h$C$F2r@O$5$l$k%/%i%9$rI=$9MWAG$r$b$D(J ClassDoc $BG[Ns$rJV$9!"(Jclasses $B%a%=%C%I$rDj5A$7$^$9!#(J
$Bfor $B%k!<%W$G!"(JClassDoc $BG[Ns$K4^$^$l$k3F%/%i%9$NL>A0$r=PNO$7$^$9!#(J
$BG[Ns(J (ClassDoc $B$r(J
println $B$K0z$-EO$9$H!"(JClassDoc $B$,I=$7$F$$$k%/%i%9$NL>A0$,=PNO$5$l$^$9!#(J
$B$3$N%I%C%/%l%C%H$rlib/tools.jar $B%U%!%$%k$K4^$^$l$F$$$^$9!#(J
$B$=$N$?$a!"%3%s%Q%$%i$N%/%i%9%Q%9$K!"(Jtools.jar $B$r4^$`I,MW$,$"$j$^$9!#(J
$BNc$r<($7$^$9!#(J
javac -classpath C:\jdk1.3\lib\tools.jar ListClass.java
ListClass $B%I%C%/%l%C%H$r-doclet $B%?%0$G;XDj$7$^$9!#(J $B$?$H$($P!"$3$N%I%C%/%l%C%H$r(J MyClass.java $B$H$$$&%U%!%$%k$KBP$7$F
% javadoc -doclet ListClass -classpath C:\jdk1.3\lib\tools.jar MyClass.java
$B=PNO$O!"!V(JMyClass$B!W$H$$$&J8;zNs$K$J$j$^$9!#(J $B$3$N%3%^%s%I$r;HMQ$9$k$K$O!"%/%i%9%Q%9>e$K(J tools.jar $B$bI,MW$G$9!#(J
$B%3%^%s%I9T%*%W%7%g%s$K$D$$$F$NCm(J: javadoc-help $B$rl9g$K$OMxMQ$G$-$^$;$s!#(J $B%+%9%?%`%I%C%/%l%C%H$G$O!"%I%C%/%l%C%HFH<+$N%3%^%s%I9T%*%W%7%g%s$rDj5A$9$k$3$H$b$G$-$^$9!#(J $B$3$N$"$H$N(J$BNc(J$B$r;2>H$7$F$/$@$5$$!#(J
API $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"(Jtext $B%a%=%C%I$O!"!V(JSome dummy text.$B!W$H$$$&J8;zNs$rJV$7$^$9!#(J
$B
import com.sun.javadoc.*;
public class ListTags {
public static boolean start(RootDoc root){
String tagName = "mytag";
writeContents(root.classes(), tagName);
return true;
}
private static void writeContents(ClassDoc[] classes, String tagName) {
for (int i=0; i
< classes.length; i++) {
boolean classNamePrinted = false;
MethodDoc[] methods = classes[i].methods();
for (int j=0; j < methods.length; j++) {
Tag[] tags = methods[j].tags(tagName);
if (tags.length > 0) {
if (!classNamePrinted) {
System.out.println("\n" + classes[i].name() + "\n");
classNamePrinted = true;
}
System.out.println(methods[j].name());
for (int k=0; k
< tags.length; k++) {
System.out.println(" " + tags[k].name() + ": "
+ tags[k].text());
}
}
}
}
}
}
$B$3$N%I%C%/%l%C%H$,8!:w$9$k%?%0$O!"(J
tagName $BJQ?t$K$h$C$F;XDj$5$l$F$$$^$9!#(J tagName $BJ8;zNs$NCM$O!"(J
$B%+%9%?%`$^$?$OI8=`$N%?%0L>$G$9!#(J $B$3$N%I%C%/%l%C%H$OI8=`=PNO$G$9$,!"(J
$B=PNO7A<0$O!"(J
$B%U%!%$%k$X$N(J HTML $B=PNO$H$$$C$?$[$+$N7A<0$KJQ99$G$-$^$9!#(J
$BNc(J - $B%+%9%?%`%3%^%s%I9T%*%W%7%g%s$N;HMQ(J
$B%+%9%?%`$N%3%^%s%I9T%*%W%7%g%s$G%I%C%/%l%C%H$r:n@.$9$k$3$H$b$G$-$^$9!#(J $B$=$N:n6HJ}K!$r8+$k$?$a!"(J
$B>e5-$N%I%C%/%l%C%HNc$r3HD%$7!"(J
$B8!:w$9$k%?%0L>$r;XDj$9$k%3%^%s%I9T%*%W%7%g%s$r;HMQ$G$-$k$h$&$K$7$F$_$^$7$g$&!#(J
$B%+%9%?%`%*%W%7%g%s$r;HMQ$9$k%I%C%/%l%C%H$O!"(J
int $B$rJV$9(J optionLength(String $B%*%W%7%g%s(J) $B$H$$$&%a%=%C%I$r$b$C$F$$$kI,MW$,$"$j$^$9!#(J
$B%I%C%/%l%C%H$KG'<1$5$;$k3F%+%9%?%`%*%W%7%g%s$K!"(J
optionLength $B$,$=$N%*%W%7%g%s$r9=@.$9$kMWAG(J ($B%H!<%/%s(J) $B$N?t$r(J
$BJV$5$J$1$l$P$J$j$^$;$s!#(J $B$3$3$G$O!"(J
-tag mytag $B$H$$$&7A<0$N%+%9%?%`%*%W%7%g%s$r;HMQ$G$-$k$h$&$K$7$F$_$^$9!#(J $B$3$N%+%9%?%`%*%W%7%g%s$G$O!"(J
-tag $B%*%W%7%g%s$=$N$b$N$H$=$NCM$N(J 2 $B$D$NMWAG$G9=@.$5$l$k$N$G!":n@.$9$k%I%C%/%l%C%H$N(J optionLength$B%a%=%C%I$O!"(J
-tag $B%*%W%7%g%s$KBP$7$F(J 2 $B$rJV$5$J$/$F$O$J$j$^$;$s!#(J
$B$^$?!"G'<1$G$-$J$$%*%W%7%g%s$KBP$7$F$O!"(J0
$B$rJV$7$^$9!#(J
$B3HD%$r;\$7$?%I%C%/%l%C%H$N40A4$J%3!<%I$r
import com.sun.javadoc.*;
public class ListTags {
public static boolean start(RootDoc root){
String tagName = readOptions(root.options());
writeContents(root.classes(), tagName);
return true;
}
private static void writeContents(ClassDoc[] classes, String tagName) {
for (int i=0; i
< classes.length; i++) {
boolean classNamePrinted = false;
MethodDoc[] methods = classes[i].methods();
for (int j=0; j < methods.length; j++) {
Tag[] tags = methods[j].tags(tagName);
if (tags.length > 0) {
if (!classNamePrinted) {
System.out.println("\n" + classes[i].name() + "\n");
classNamePrinted = true;
}
System.out.println(methods[j].name());
for (int k=0; k
< tags.length; k++) {
System.out.println(" " + tags[k].name() + ": " + tags[k].text());
}
}
}
}
}
private static String readOptions(String[][] options) {
String tagName = null;
for (int i = 0; i < options.length; i++) {
String[] opt = options[i];
if (opt[0].equals("-tag")) {
tagName = opt[1];
}
}
return tagName;
}
public static int optionLength(String option) {
if(option.equals("-tag")) {
return 2;
}
return 0;
}
public static boolean validOptions(String options[][],
DocErrorReporter reporter) {
boolean foundTagOption = false;
for (int i = 0; i
< options.length; i++) {
String[] opt = options[i];
if (opt[0].equals("-tag")) {
if (foundTagOption) {
reporter.printError("Only one -tag option allowed.");
return false;
} else {
foundTagOption = true;
}
}
}
if (!foundTagOption) {
reporter.printError("Usage: javadoc -tag mytag -doclet ListTags ...");
}
return foundTagOption;
}
}
$B$3$N=$@58e$N%I%C%/%l%C%H$G$O!"(JtagName $BJQ?t$O(J
$B%3%^%s%I9T%*%W%7%g%s(J -tag $B$G@_Dj$5$l$^$9!#(J $B$3$N%I%C%/%l%C%H$K$O!"%+%9%?%`%*%W%7%g%s$K(J 2 $B$rJV$9(J optionLength $B%a%=%C%I$,$"$j$^$9!#(J
returns two for our custom option. Note that an explicit call to
optionLength $B$rL@<(E*$K8F$S=P$9I,MW$O$J$$$3$H$KCm0U$7$F$/$@$5$$!#(J
$B$5$i$K!"$3$N%I%C%/%l%C%H$K$O!"%3%^%s%I9T%*%W%7%g%s$r2r@O$7$F(J -tag $B%*%W%7%g%s$rC5$9(J
readOptions $B%a%=%C%I$bDI2C$5$l$F$$$^$9!#(J $B$3$N%a%=%C%I$G$O!"(J
use of the fact that the
$B%*%W%7%g%s$N>pJs$,4^$^$l$?(J String $B7?$N(J 2 $BRootdoc.options $B%a%=%C%I$rMxMQ$7$F$$$^$9!#(J
information. $B$?$H$($P!"
javadoc -foo this that -bar other ...
RootDoc.options $B%a%=%C%I$O
options()[0][0] = "-foo"
options()[0][1] = "this"
options()[0][2] = "that"
options()[1][0] = "-bar"
options()[1][1] = "other"
$BG[Ns$N(J 2 $BHVL\$NE:$(;z$KF~$C$F$$$kMWAG?t$O!"(JoptionLength $B%a%=%C%I$K$h$jH=JL$5$l$^$9!#(J $B$3$NNc$G$O!"(JoptionLength $B$O!"(J-foo $B%*%W%7%g%s$KBP$7$F$O(J 3 $B$rJV$7!"(J-bar $B%*%W%7%g%s$KBP$7$F$O(J 2 $B$rJV$7$^$9!#(J
validOptions $B%a%=%C%I$O!"%3%^%s%I9T%?%0$N;XDj$,@5$7$$$+$I$&$+$r%A%'%C%/$9$k$?$a$N!">JN,2DG=$J%a%=%C%I$G$9!#(J validOptions $B%a%=%C%I$O!"B8:_$9$l$P<+F0E*$K8F$S=P$5$l$k$?$a!"L@<(E*$K8F$S=P$9I,MW$O$"$j$^$;$s!#(J $B$3$N%a%=%C%I$G$O!"%*%W%7%g%s$N;XDj$,@5$7$$>l9g$O(J true $B$rJV$7!"$=$&$G$J$$>l9g$O(J false $B$rJV$9$h$&$K$7$^$9!#(J $B$^$?!";XDj$N@5$7$/$J$$%3%^%s%I9T%*%W%7%g%s$,8+$D$+$C$?>l9g$K!"(JvalidOptions $B$+$iE,@Z$J%(%i!<%a%C%;!<%8$rI=<($9$k$3$H$b$G$-$^$9!#(J $B$3$N%I%C%/%l%C%H$N(J validOptions $B%a%=%C%I$G$O!"(J-tag $B%*%W%7%g%s$,(J 1 $B$D;XDj$5$l$F$$$k$+$I$&$+!"$=$7$F(J 2 $B$D0J>e;XDj$5$l$F$$$J$$$+$I$&$+$r%A%'%C%/$7$F$$$^$9!#(J