You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/11/09 19:36:57 UTC
svn commit: r834171 - in
/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main:
java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/ resources/META-INF/
Author: lu4242
Date: Mon Nov 9 18:36:57 2009
New Revision: 834171
URL: http://svn.apache.org/viewvc?rev=834171&view=rev
Log:
update tagdoc index and content goal to deal with @JSFFaceletTag annotation (see MYFACES-2304)
Added:
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-facelet-tag.vm
Modified:
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocContentMojo.java
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocIndexReport.java
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-component.vm
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-converter.vm
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-tag.vm
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-validator.vm
Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocContentMojo.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocContentMojo.java?rev=834171&r1=834170&r2=834171&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocContentMojo.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocContentMojo.java Mon Nov 9 18:36:57 2009
@@ -53,6 +53,7 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ClassMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ComponentMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ConverterMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.FaceletTagMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.Model;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.TagMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ValidatorMeta;
@@ -165,6 +166,12 @@
* @parameter expression="xdoc-tag.vm"
*/
private String templateTag;
+
+ /**
+ * @since 1.0.4
+ * @parameter expression="xdoc-facelet-tag.vm"
+ */
+ private String templateFaceletTag;
static private final String _DOC_SUBDIRECTORY = "tagdoc";
@@ -270,11 +277,14 @@
Iterator converters = model.converters();
Iterator tags = model.tags();
+
+ Iterator faceletTags = model.faceletTags();
Set componentPages = new TreeSet();
Set converterPages = new TreeSet();
Set validatorPages = new TreeSet();
Set tagsPages = new TreeSet();
+ Set faceletTagsPages = new TreeSet();
int count = 0;
while (components.hasNext())
@@ -282,7 +292,7 @@
ComponentMeta component = (ComponentMeta) components.next();
if (canGenerate(component))
{
- String pageName = _generateComponentDoc(velocityEngine,baseContext,component);
+ String pageName = _generateComponentDoc(velocityEngine,baseContext,model,component);
if (pageName != null)
{
componentPages.add(pageName);
@@ -295,7 +305,7 @@
ConverterMeta converter = (ConverterMeta) converters.next();
if (canGenerate(converter))
{
- String pageName = _generateConverterDoc(velocityEngine,baseContext,converter);
+ String pageName = _generateConverterDoc(velocityEngine,baseContext,model,converter);
if (pageName != null)
{
converterPages.add(pageName);
@@ -309,7 +319,7 @@
if (canGenerate(validator))
{
- String pageName = _generateValidatorDoc(velocityEngine,baseContext,validator);
+ String pageName = _generateValidatorDoc(velocityEngine,baseContext,model,validator);
if (pageName != null)
{
validatorPages.add(pageName);
@@ -323,7 +333,7 @@
if (canGenerate(tag))
{
- String pageName = _generateTagDoc(velocityEngine,baseContext,tag);
+ String pageName = _generateTagDoc(velocityEngine,baseContext,model,tag);
if (pageName != null)
{
tagsPages.add(pageName);
@@ -331,6 +341,20 @@
}
}
}
+ while (faceletTags.hasNext())
+ {
+ FaceletTagMeta faceletTag = (FaceletTagMeta) faceletTags.next();
+
+ if (canGenerate(faceletTag))
+ {
+ String pageName = _generateFaceletTagDoc(velocityEngine,baseContext,model,faceletTag);
+ if (pageName != null)
+ {
+ faceletTagsPages.add(pageName);
+ count++;
+ }
+ }
+ }
Set otherPages = _gatherOtherTags();
@@ -370,7 +394,7 @@
}
private String _generateComponentDoc(VelocityEngine velocityEngine,
- VelocityContext baseContext, ComponentMeta component)
+ VelocityContext baseContext, Model model, ComponentMeta component)
throws Exception
{
if (component.getName() == null)
@@ -381,6 +405,11 @@
Context context = new VelocityContext(baseContext);
context.put("component", component);
+ FaceletTagMeta faceletTag = model.findFaceletTagByName(component.getName());
+ if (faceletTag != null)
+ {
+ context.put("faceletTag", faceletTag);
+ }
String baseContent = "";
@@ -463,7 +492,7 @@
}
private String _generateConverterDoc(VelocityEngine velocityEngine,
- VelocityContext baseContext, ConverterMeta converter)
+ VelocityContext baseContext, Model model, ConverterMeta converter)
throws Exception
{
if (converter.getName() == null)
@@ -475,6 +504,11 @@
Context context = new VelocityContext(baseContext);
context.put("converter", converter);
+ FaceletTagMeta faceletTag = model.findFaceletTagByName(converter.getName());
+ if (faceletTag != null)
+ {
+ context.put("faceletTag", faceletTag);
+ }
String baseContent = "";
@@ -557,7 +591,7 @@
}
private String _generateValidatorDoc(VelocityEngine velocityEngine,
- VelocityContext baseContext, ValidatorMeta validator)
+ VelocityContext baseContext, Model model, ValidatorMeta validator)
throws Exception
{
if (validator.getName() == null)
@@ -569,6 +603,11 @@
Context context = new VelocityContext(baseContext);
context.put("validator", validator);
+ FaceletTagMeta faceletTag = model.findFaceletTagByName(validator.getName());
+ if (faceletTag != null)
+ {
+ context.put("faceletTag", faceletTag);
+ }
String baseContent = "";
@@ -651,7 +690,7 @@
}
private String _generateTagDoc(VelocityEngine velocityEngine,
- VelocityContext baseContext, TagMeta tag)
+ VelocityContext baseContext, Model model, TagMeta tag)
throws Exception
{
if (tag.getName() == null)
@@ -663,6 +702,11 @@
Context context = new VelocityContext(baseContext);
context.put("tag", tag);
+ FaceletTagMeta faceletTag = model.findFaceletTagByName(tag.getName());
+ if (faceletTag != null)
+ {
+ context.put("faceletTag", faceletTag);
+ }
String baseContent = "";
@@ -744,6 +788,137 @@
return pageName;
}
+ private String _generateFaceletTagDoc(VelocityEngine velocityEngine,
+ VelocityContext baseContext, Model model, FaceletTagMeta faceletTag)
+ throws Exception
+ {
+ String name = faceletTag.getName();
+ if (name == null)
+ {
+ return null;
+ }
+
+ if (faceletTag.getComponentClass() != null)
+ {
+ ComponentMeta comp = model.findComponentByClassName(faceletTag.getComponentClass());
+ if (name.equals(comp.getName()))
+ {
+ //Exists in jsp and in facelets, but has specific facelets properties
+ return null;
+ }
+ }
+ if (faceletTag.getConverterClass() != null)
+ {
+ ConverterMeta comp = model.findConverterByClassName(faceletTag.getConverterClass());
+ if (name.equals(comp.getName()))
+ {
+ //Exists in jsp and in facelets, but has specific facelets properties
+ return null;
+ }
+ }
+ if (faceletTag.getValidatorClass() != null)
+ {
+ ValidatorMeta comp = model.findValidatorByClassName(faceletTag.getValidatorClass());
+ if (name.equals(comp.getName()))
+ {
+ //Exists in jsp and in facelets, but has specific facelets properties
+ return null;
+ }
+ }
+ if (faceletTag.getTagClass() != null)
+ {
+ TagMeta comp = model.findTagByClassName(faceletTag.getTagClass());
+ if (name.equals(comp.getName()))
+ {
+ //Exists in jsp and in facelets, but has specific facelets properties
+ return null;
+ }
+ }
+
+ String pageName = _toPageName(faceletTag.getName());
+
+ Context context = new VelocityContext(baseContext);
+ context.put("faceletTag", faceletTag);
+
+ String baseContent = "";
+
+ File xmlBaseFile = new File(baseFilesSourceDirectory,
+ _platformAgnosticPath(pageName + "-base.xml"));
+
+ if (xmlBaseFile != null && xmlBaseFile.exists())
+ {
+ if (getLog().isDebugEnabled())
+ {
+ getLog().debug("using base content file: "+xmlBaseFile.getPath());
+ }
+
+ Reader reader = null;
+ try
+ {
+ reader = new FileReader(xmlBaseFile);
+ Xpp3Dom root = Xpp3DomBuilder.build(reader);
+
+ StringWriter writer = new StringWriter();
+
+ Xpp3Dom [] children = root.getChild("body").getChildren();
+
+ for (int i = 0; i< children.length; i++)
+ {
+ Xpp3Dom dom = children[i];
+ Xpp3DomWriter.write(writer, dom);
+ }
+ baseContent = writer.toString();
+ writer.close();
+ }
+ catch (XmlPullParserException e)
+ {
+ throw new MojoExecutionException(
+ "Error parsing base file: " + e.getMessage(), e);
+ }
+ finally
+ {
+ reader.close();
+ }
+ }
+
+ baseContext.put("baseContent", baseContent);
+
+ Writer out = null;
+
+ try
+ {
+ File targetDir = new File(outputDirectory.getParentFile(),
+ _platformAgnosticPath("generated-site/xdoc/"
+ + _DOC_SUBDIRECTORY));
+
+ if ( !targetDir.exists() )
+ {
+ targetDir.mkdirs();
+ }
+ File targetFile = new File(targetDir, pageName + ".xml");
+
+ out = new OutputStreamWriter(new FileOutputStream(targetFile),
+ "UTF-8");
+
+ Template template = velocityEngine.getTemplate(getTemplateFaceletTag());
+
+ template.merge(context, out);
+
+ out.flush();
+ }
+ catch (Exception e)
+ {
+ throw new MojoExecutionException(
+ "Error merging velocity templates: " + e.getMessage(), e);
+ }
+ finally
+ {
+ IOUtil.close(out);
+ out = null;
+ }
+
+ return pageName;
+ }
static private final String _platformAgnosticPath(String path)
{
@@ -881,5 +1056,9 @@
{
return templateTag;
}
-
+
+ public String getTemplateFaceletTag()
+ {
+ return templateFaceletTag;
+ }
}
Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocIndexReport.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocIndexReport.java?rev=834171&r1=834170&r2=834171&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocIndexReport.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocIndexReport.java Mon Nov 9 18:36:57 2009
@@ -38,6 +38,7 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ClassMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ComponentMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ConverterMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.FaceletTagMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.Model;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.TagMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ValidatorMeta;
@@ -189,6 +190,8 @@
Iterator converters = model.converters();
Iterator tags = model.tags();
+
+ Iterator faceletTags = model.faceletTags();
// =-=AEW Note that only updating out-of-date components, etc. is
// permanently tricky, even if we had proper detection in place,
@@ -205,6 +208,7 @@
Set converterPages = new TreeSet();
Set validatorPages = new TreeSet();
Set tagsPages = new TreeSet();
+ Set faceletTagPages = new TreeSet();
int count = 0;
while (components.hasNext())
@@ -261,6 +265,22 @@
}
}
}
+
+ while (faceletTags.hasNext())
+ {
+ FaceletTagMeta faceletTag = (FaceletTagMeta) faceletTags.next();
+
+ if (canGenerate(faceletTag))
+ {
+ String pageName = _generateFaceletTagDoc(model, faceletTag);
+ if (pageName != null)
+ {
+ faceletTagPages.add(pageName);
+ count++;
+ }
+ }
+ }
+
Set otherPages = _gatherOtherTags();
@@ -307,6 +327,7 @@
_writeIndexSection(sink, converterPages, "Converters");
_writeIndexSection(sink, validatorPages, "Validators");
_writeIndexSection(sink, tagsPages, "JSF Tags");
+ _writeIndexSection(sink, faceletTagPages, "JSF Facelet Tags");
_writeIndexSection(sink, otherPages, "Miscellaneous");
sink.body_();
@@ -433,7 +454,58 @@
String pageName = _toPageName(tag.getName());
return pageName;
- }
+ }
+
+ private String _generateFaceletTagDoc(Model model, FaceletTagMeta tag)
+ throws IOException
+ {
+ String name = tag.getName();
+ if (name == null)
+ {
+ return null;
+ }
+
+ if (tag.getComponentClass() != null)
+ {
+ ComponentMeta comp = model.findComponentByClassName(tag.getComponentClass());
+ if (name.equals(comp.getName()))
+ {
+ //Exists in jsp and in facelets, but has specific facelets properties
+ return null;
+ }
+ }
+ if (tag.getConverterClass() != null)
+ {
+ ConverterMeta comp = model.findConverterByClassName(tag.getConverterClass());
+ if (name.equals(comp.getName()))
+ {
+ //Exists in jsp and in facelets, but has specific facelets properties
+ return null;
+ }
+ }
+ if (tag.getValidatorClass() != null)
+ {
+ ValidatorMeta comp = model.findValidatorByClassName(tag.getValidatorClass());
+ if (name.equals(comp.getName()))
+ {
+ //Exists in jsp and in facelets, but has specific facelets properties
+ return null;
+ }
+ }
+ if (tag.getTagClass() != null)
+ {
+ TagMeta comp = model.findTagByClassName(tag.getTagClass());
+ if (name.equals(comp.getName()))
+ {
+ //Exists in jsp and in facelets, but has specific facelets properties
+ return null;
+ }
+ }
+
+ String pageName = _toPageName(tag.getName());
+
+ return pageName;
+ }
static private final String _platformAgnosticPath(String path)
{
Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-component.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-component.vm?rev=834171&r1=834170&r2=834171&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-component.vm (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-component.vm Mon Nov 9 18:36:57 2009
@@ -16,6 +16,10 @@
<b>Tag class:</b> <a href="${tagdocUtils.platformAgnosticPath( $javadocPath )}.html">${component.tagClass}</a>
<br/>
#end
+#if ($faceletTag)
+ <b>Facelet Tag Handler:</b> <a href="${tagdocUtils.platformAgnosticPath( $javadocPath )}.html">${faceletTag.className}</a>
+ <br/>
+#end
<b>Component type:</b> ${component.type}
<br/>
<b>Component family:</b> ${component.family}
Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-converter.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-converter.vm?rev=834171&r1=834170&r2=834171&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-converter.vm (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-converter.vm Mon Nov 9 18:36:57 2009
@@ -16,6 +16,10 @@
<b>Tag class:</b> <a href="${tagdocUtils.platformAgnosticPath( $javadocPath )}.html">${converter.tagClass}</a>
<br/>
#end
+#if ($faceletTag)
+ <b>Facelet Tag Handler:</b> <a href="${tagdocUtils.platformAgnosticPath( $javadocPath )}.html">${faceletTag.className}</a>
+ <br/>
+#end
<b>converter id:</b> ${converter.converterId}
<br/>
${converter.longDescription}
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-facelet-tag.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-facelet-tag.vm?rev=834171&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-facelet-tag.vm (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-facelet-tag.vm Mon Nov 9 18:36:57 2009
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<document>
+ <properties>
+ <title><${faceletTag.name}></title>
+ </properties>
+ <body>
+ <section name="Summary">
+ <p>
+ <b>Facelet Tag name:</b> <${faceletTag.name}>
+ <br/>
+#set ($javadocPath = "../apidocs/" + $faceletTag.getClassName().replace('.', '/') )
+ <b>Facelet Tag class:</b> <a href="${tagdocUtils.platformAgnosticPath( $javadocPath )}.html">${faceletTag.className}</a>
+ <br/>
+${faceletTag.longDescription}
+ </p>
+ </section>
+#if ($baseContent)
+$baseContent
+#end
+#set ($attributeList = ${tagdocUtils.getSortedAttributeList($faceletTag)})
+#if ($attributeList.size() != 0)
+ <section name="Attributes">
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Type</th>
+ <th>Required</th>
+ <th>Description</th>
+ </tr>
+#foreach( $attribute in $attributeList )
+#if (!$attribute.isTagExcluded())
+ <tr>
+ <td>$attribute.name</td>
+#set ($type = ${tagdocUtils.getDisplayType($faceletTag.className,$attribute.name,$attribute.className)})
+ <td>$type</td>
+ <td>$attribute.isRequired()</td>
+#if ($attribute.longDescription)
+ <td>$attribute.longDescription</td>
+#else
+ <td></td>
+#end
+ </tr>
+#end
+#end
+</table>
+ </section>
+#end
+ </body>
+</document>
\ No newline at end of file
Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-tag.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-tag.vm?rev=834171&r1=834170&r2=834171&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-tag.vm (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-tag.vm Mon Nov 9 18:36:57 2009
@@ -11,6 +11,10 @@
#set ($javadocPath = "../apidocs/" + $tag.getClassName().replace('.', '/') )
<b>Tag class:</b> <a href="${tagdocUtils.platformAgnosticPath( $javadocPath )}.html">${tag.className}</a>
<br/>
+#if ($faceletTag)
+ <b>Facelet Tag Handler:</b> <a href="${tagdocUtils.platformAgnosticPath( $javadocPath )}.html">${faceletTag.className}</a>
+ <br/>
+#end
${tag.longDescription}
</p>
</section>
Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-validator.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-validator.vm?rev=834171&r1=834170&r2=834171&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-validator.vm (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-validator.vm Mon Nov 9 18:36:57 2009
@@ -16,6 +16,10 @@
<b>Tag class:</b> <a href="${tagdocUtils.platformAgnosticPath( $javadocPath )}.html">${validator.tagClass}</a>
<br/>
#end
+#if ($faceletTag)
+ <b>Facelet Tag Handler:</b> <a href="${tagdocUtils.platformAgnosticPath( $javadocPath )}.html">${faceletTag.className}</a>
+ <br/>
+#end
<b>validator id:</b> ${validator.validatorId}
<br/>
${validator.longDescription}