1

I'm writing a custom taglet for inclusion of a mathML file in a javadoc html file. I would like to store all my *.mml files in the same folder, possibly in the

{@docroot}/doc-files

folder. My question is : how can I know the value of the @docRoot string within a Taglet object (more specifically, within the toString(com.sun.javadoc.Tag tag) method ? Many thanks!

aliteralmind
  • 19,847
  • 17
  • 77
  • 108
Sebastien
  • 246
  • 1
  • 12

2 Answers2

1

I also needed to display MathML in my javadoc. I wrote a blog post about how I solved it here: http://chadretz.wordpress.com/2010/12/19/mathml-inside-javadoc-using-mathjax-and-a-custom-taglet/

More specifically to your problem though, if you look at the Taglet source code I posted there (collapsed by default), you can see where I get the top level ClassDoc of the Tag.holder() to obtain the directory depth I am at so I can traverse up. This helps if you need the relative HTML root. If you need to know the location of your MML's while the Taglet is running, I suggest you put them on the classpath and access them as resources.

Chad Retz
  • 1,241
  • 2
  • 14
  • 16
0

Starting with the getPackageDoc function from @ChadRetz's blog, I've created a utility class that contains a function that does what you wish: Given a com.sun.javadoc.Tag, it returns the relative url from its enclosing file (the file containing that tag), to the JavaDoc root directory--this is the equivalent of {@docRoot}.

The class is called ComSunJavaDocUtil, and the function name is getRelativeUrlToDocRoot.

An example taglet's toString() function:

public String toString(Tag tag) {
   return  "Relative url to DOC ROOT for this tag's enclosing file is \"" + 
      ComSunJavaDocUtil.getRelativeUrlToDocRoot(tag) + "\"";
}

This utility class is part of Codelet. Installation instructions are here. If this utility class is all you're going to use, then the only jars you need on your classpath are codelet and xbnjava...and, of course, com.sun.javadoc.

aliteralmind
  • 19,847
  • 17
  • 77
  • 108