Steps for creating custom doclet

I'm a complete newbie to this whole JavaDoc Doclet stuff. I trying to create a custom Doclet I think. I want to use all the standard annotations but add 1 of my one aswell and a method so only the methods with my annotation is shown.

I have a custom Doclet from the sun tutorial but don't have it creating a html file in docs folder or have it recognising any of the standard annotations. It doesn't extend or implement anything.

Any advice on the step to take when creating a Doclet would be much appreciated.

[532 byte] By [Rebels_Mascota] at [2007-10-2 17:51:37]
# 1

Hi,

Well, I think it's impossible to give you much of advice here on how to write your own doclet...

Just imagine, Javadoc itself is not so much more than a launcher of two things: the Java compiler and the doclet. The compiler parses Java code, collects some information about it and forms the object representation of that information which is provided to the doclet via Doclet API (a structure basically very much similar to XML DOM).

Further, the doclet should use that representation and to generate by it anything you wish. You wish to generate HTML? Fine! Just understand what HTML is (buy some fat book about it) and go ahead! Want to generate PDF? Nothing is simpler: PDF specs is free on the Adobe web-site... Want to generate some UML diagrams by it? There are lots of various graphics libraries to help you with that... and so on... so on... You are free to generate anything you wish and in any way you wish!

Best,

Leonid Rudy

http://www.docflex.com

leonid_rudya at 2007-7-13 19:09:57 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

Thanks for the reply Leonid, still confused do.

I'd like to create a HTML page that will show all the standard annotations/tags but also a custom tag. From the tutorial I have:

import com.sun.javadoc.*;

public class ListClass {

public static boolean start(RootDoc root) {

String tagName = "myTag";

writeContents(root.classes(), tagName);

return htmlDoclet.start(root);

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());

}

}

}

}

}

}

Should I be extending Standard or Doclet, I tried to extend Standard but it said it couldn't find myTag.

I read a few places it's probably easier to just create the whole Doclet thing from scratch but is very time consuming and seems a bit daunting to me.

I'm probably not making much sense but I'm a bit lost with all this.

Rebels_Mascota at 2007-7-13 19:09:57 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3

I'm sure your well aware what the above does but just in case it prints out all methods that have the tag "myTag" but it only prints that tag, example of code and output

/**

* @param args

* @author someone

* @myTaggfggff

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println("\nHello12");

test test1 = new test();

}

/**

* @author someone

* @myTag myTag comments

*/

public void testMethod (){

}

/**

* @author someone

*/

public void testMethod1 (){

}

test

main

@myTag: gfggff

testMethod

@myTag: myTag comments

Rebels_Mascota at 2007-7-13 19:09:57 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4

Hi,

We would like to know how to document custom tags along with standard javadocs tags using Eclipse. Doclipse supports addition of Custom tags but does not reflect them in the Javadocs HTML. Can you please provide detailed steps to include a Custom tag like "Copyrights" for example.

Thanks

TASKa at 2007-7-13 19:09:57 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 5

It's quite simple. If you have a custom @todo tag, you would include it in the generated HTML by adding something like this option to your javadoc command:

-tag todo:a:"To Do:"

For more details:

http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#tag

-Doug

dhkramera at 2007-7-13 19:09:57 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 6
Hi,Thanks for the response. Actually we are using Eclipse to generate Javadocs and hence are unable to understand what option to set so as to get custom tags like 'Copyrights" or "Project Name" displayed in the HTML. Please help.Thanks
TASKa at 2007-7-13 19:09:57 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 7
Hi,Can someone please tell me how to include Custom tags in the Javadocs created from Eclipse. Awaiting response eagerly.Thanks
TASKa at 2007-7-13 19:09:57 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...