0

As far as I can see the taglet api has exactly one class in its package: Taglet, if you change Taglet.html to package-summary.html, there's nothing else in it (and there's this mildly scary message:

As of JDK version 1.5, replaced by com.sun.tools.doclets.internal.toolkit.util.

which I'm assuming that does not affect the Taglet interface itself.)

There is nothing in the interface that knows anything about the class in which the taglet resides--nothing about its context.

Is there anyway to get the name of the class in which the taglet is being "called" from? The class that has the JavaDoc block in which {@.myTaglet} exists?

As a hack, I'm thinking of forcing the user to set it with {@.thisClass my.package.AClass} at the top, before using any of my custom taglets.

Better ideas would be great.

(Here's Sun's taglet overview.)


(Also, please consider looking at my previous question, which is another taglet question: How to make inline taglets (which require com.sun) more cross-platform? Is there a non-Oracle/more-cross-platform javadoc parser?)

Community
  • 1
  • 1
aliteralmind
  • 19,847
  • 17
  • 77
  • 108

1 Answers1

0

As I was researching this question, I figured it out. This is a function in the demo UnderlineTaglet:

public String toString(Tag tag) {
    return "<u>" + tag.text() + "[" + tag + ", [" + 
       tag.holder() + "]]</u>";
}

If this taglet is in com.github.xbn.insertexample.BasicOutputProcessors

{@underline xxx}

It results in

<u>xxxy[@underline:xxxy, [com.github.xbn.insertexample.BasicOutputProcessors]]</u>

So tag.holder().toString() is the answer.

API:

aliteralmind
  • 19,847
  • 17
  • 77
  • 108