views:

477

answers:

1

For JSP and some JSF tags there is a tool called TLDdoc that generates JavaDoc-style documentation for the JSP and JSF tags.

Does anybody know an equivalent for Facelets? There is a tool called facelets-doc that aims to support Facelets but either it's not finished, or the lack of documentation doesn't mention how to make it work.

I have a few facelets taglib.xml files defining tags and functions and would love to get documentation similar to what TLDdoc generates (example).

Does anyone know if TLDdoc supports Facelets? Or if facelets-doc already works (and if yes, how)? Or if another tool exists for that?

+1  A: 

I dont know any tools that do this for you, but if u can do it manually you do it like this:

myTagLib-taglib.xml

<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC
  "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
  "facelet-taglib_1_0.dtd">
<facelet-taglib>
    <namespace>http://www.asdf.com/myTagLib&lt;/namespace&gt;
    <tag>
     <tag-name>myTagName</tag-name>
     <source>myTagName.jspx</source>
    </tag>
    <tag>
     <tag-name>myTag</tag-name>
     <source>myTag.jspx</source>
    </tag>
</facelet-taglib>

Put this file in your META-INF/ directory. Now since u wanted the TLD information aswell you put the tld file in the same directory:

myTagLib-taglib.tld

<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" 
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"&gt;

<taglib xmlns="http://java.sun.com/JSP/TagLibraryDescriptor"&gt;
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>rest</short-name>
    <uri>http://www.yoursite.com/facelets-taglib-common&lt;/uri&gt;
    <display-name>My ag Library</display-name>
    <tag>
     <name>myTagName</name>
     <tag-class>common/myTagName.jspx</tag-class>
     <body-content>JSP</body-content>
     <description>
      Does magic stuff.
     </description>
     <attribute>
      <name>foo</name>
      <required>true</required>
      <rtexprvalue>false</rtexprvalue>
      <type>java.lang.Boolean</type>
      <description>
       Foobar
      </description>
     </attribute>
    </tag>
    <tag>
     <name>myTag</name>
     <tag-class>common/myTag.jspx</tag-class>
     <body-content>JSP</body-content>
     <description>
      Foobar
     </description>
    </tag></taglib>

This should be sufficient and most IDE's will pick up the TLD and use it to display autocomplete and so on if you packed it correctly.

ChrisAD
So you're saying I should have something to generate the TLD from the taglib.xml and then put the documentation there? Then I can use TLDdocs for the documentation. Seems like a way to do it, as long as I can get the two to sync, but I am not sure the TLD sitting next to the taglib.xml in the jar won't confuse the server when deploying…
FroMage
No this is the facelets standard way of doing it. Put it in the meta-inf directory. It works for me and Im running GlassFish 2.1 server
ChrisAD