Update of
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-plugin/src/main/java/org/xdoclet/plugin/plugin
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20773/src/main/java/org/xdoclet/plugin/plugin
Modified Files:
PluginPlugin.java PluginPlugin.vm
Log Message:
Improve docs generation
Index: PluginPlugin.vm
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-plugin/src/main/java/org/xdoclet/plugin/plugin/PluginPlugin.vm,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PluginPlugin.vm 27 Oct 2004 18:26:41 -0000 1.4
--- PluginPlugin.vm 31 May 2005 11:28:17 -0000 1.5
***************
*** 9,13 ****
##parse('plugin-header.inc.vm') -- how can i do this without making it fail
if the file does not exist?
||Property||Required||Allowed values||Default value||Description||
! #foreach ($property in $class.getBeanProperties(true))
#if (${property.mutator})
|${property.name} |${plugin.isRequired(${property.mutator})}
|${plugin.getAllowedValues(${property.mutator})}
|${plugin.getDefaultValue(${property.mutator})}
|${plugin.getDescription(${property.mutator})} |
--- 9,13 ----
##parse('plugin-header.inc.vm') -- how can i do this without making it fail
if the file does not exist?
||Property||Required||Allowed values||Default value||Description||
! #foreach ($property in $plugin.getBeanProperties($class))
#if (${property.mutator})
|${property.name} |${plugin.isRequired(${property.mutator})}
|${plugin.getAllowedValues(${property.mutator})}
|${plugin.getDefaultValue(${property.mutator})}
|${plugin.getDescription(${property.mutator})} |
Index: PluginPlugin.java
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-plugin/src/main/java/org/xdoclet/plugin/plugin/PluginPlugin.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** PluginPlugin.java 6 Feb 2005 16:39:11 -0000 1.13
--- PluginPlugin.java 31 May 2005 11:28:17 -0000 1.14
***************
*** 1,16 ****
package org.xdoclet.plugin.plugin;
! import com.thoughtworks.qdox.model.DocletTag;
! import com.thoughtworks.qdox.model.JavaClass;
! import com.thoughtworks.qdox.model.JavaMethod;
! import org.generama.defaults.QDoxPlugin;
import org.generama.Plugin;
import org.generama.VelocityTemplateEngine;
import org.generama.WriterMapper;
! import org.generama.QDoxCapableMetadataProvider;
import org.xdoclet.plugin.plugin.qtags.TagLibrary;
! import java.io.File;
! import java.io.IOException;
/**
--- 1,25 ----
+ /*
+ * Copyright (c) 2003
+ * XDoclet Team
+ * All rights reserved.
+ */
package org.xdoclet.plugin.plugin;
! import java.io.File;
! import java.io.IOException;
!
! import java.util.ArrayList;
! import java.util.Collection;
!
import org.generama.Plugin;
+ import org.generama.QDoxCapableMetadataProvider;
import org.generama.VelocityTemplateEngine;
import org.generama.WriterMapper;
!
! import org.generama.defaults.QDoxPlugin;
!
import org.xdoclet.plugin.plugin.qtags.TagLibrary;
! import com.thoughtworks.qdox.model.*;
/**
***************
*** 23,42 ****
private String basedir;
! public PluginPlugin(VelocityTemplateEngine velocityTemplateEngine,
QDoxCapableMetadataProvider metadataProvider, WriterMapper writerMapper) {
super(velocityTemplateEngine, metadataProvider, writerMapper);
setPackageregex(".");
setMultioutput(true);
new TagLibrary(metadataProvider);
-
}
! public String getDestinationFilename(Object metadata) {
try {
! String location = ((JavaClass)
metadata).getParentSource().getFile().getCanonicalPath();
! String basename = getTopLocation(location);
! String originalFilename =
getMetadataProvider().getOriginalFileName(metadata);
! String name = originalFilename.substring(0,
originalFilename.lastIndexOf('.'));
! return basename + "-" + name + ".confluence";
} catch (IOException e) {
throw new RuntimeException(e);
--- 32,79 ----
private String basedir;
+ /**
+ * Directory where plugin finds sources of Generama. It used to find all
plugins implementation
+ * that should not be generated.
+ *
+ * think: or better to place @generama.ignore to all plugins in Generama??
+ */
+ private String generamaSourcesDir;
! public PluginPlugin(VelocityTemplateEngine velocityTemplateEngine,
QDoxCapableMetadataProvider metadataProvider,
! WriterMapper writerMapper) {
super(velocityTemplateEngine, metadataProvider, writerMapper);
setPackageregex(".");
setMultioutput(true);
new TagLibrary(metadataProvider);
}
! public String getAllowedValues(JavaMethod method) {
! DocletTag tag = method.getTagByName("generama.property", true);
!
! if (tag == null) {
! return "";
! }
!
! String allowed = tag.getNamedParameter("allowed-values");
!
! if (allowed != null) {
! return allowed;
! }
!
! Type propertyType = method.getPropertyType();
!
! if (isBoolean(propertyType)) {
! return "true, false";
! }
!
! return "";
! }
!
! /**
! * @throws RuntimeException when a path can not be resolved (@see
File.getCanonicalPath)
! */
! public void setBasedir(String basedir) {
try {
! this.basedir = new File(basedir).getCanonicalPath();
} catch (IOException e) {
throw new RuntimeException(e);
***************
*** 44,100 ****
}
! public boolean shouldGenerate(Object metadata) {
! JavaClass javaClass = (JavaClass) metadata;
! return javaClass.isA(Plugin.class.getName());
}
! public String getAllowedValues(JavaMethod method) {
! DocletTag tag = method.getTagByName("generama.property", true);
! if (tag == null) return "";
! return tag.getNamedParameter("allowed-values");
}
public String getDefaultValue(JavaMethod method) {
DocletTag tag = method.getTagByName("generama.property", true);
- if (tag == null) return "";
- return tag.getNamedParameter("default");
- }
! public String isRequired(JavaMethod method) {
! DocletTag tag = method.getTagByName("generama.property", true);
! if (tag == null) return "false";
! if (tag.getNamedParameter("required") == null) return "false";
! return tag.getNamedParameter("required");
}
public String getDescription(JavaMethod method) {
String comment = method.getComment();
! if (comment == null) return "";
! return comment;
}
! /**
! * Sets the cheese.
! *
! * @generama.property required="true"
! * default="brie"
! * allowed-values="brie, stilton"
! */
! public void setCheese(String s) {
}
! /**
! * @throws RuntimeException when a path can not be resolved (@see
File.getCanonicalPath)
! */
! public void setBasedir(String basedir) {
try {
! this.basedir = new File(basedir).getCanonicalPath();
} catch (IOException e) {
! throw new RuntimeException(e);
}
}
! public String getBasedir() {
! return basedir;
}
--- 81,176 ----
}
! public String getBasedir() {
! return basedir;
}
! public Collection getBeanProperties(JavaClass clazz) {
! Collection result = new ArrayList();
! BeanProperty[] props = clazz.getBeanProperties(true);
!
! for (int i = 0; i < props.length; i++) {
! BeanProperty prop = props[i];
!
! if (prop.getMutator() != null &&
prop.getMutator().getTagByName("generama.property") != null) {
! result.add(prop);
! }
! }
!
! return result;
}
public String getDefaultValue(JavaMethod method) {
DocletTag tag = method.getTagByName("generama.property", true);
! if (tag == null) {
! return "";
! }
!
! String defaultValue = tag.getNamedParameter("default");
!
! if (defaultValue != null) {
! return defaultValue;
! }
!
! if (isBoolean(method.getPropertyType())) {
! return "false";
! }
!
! return "";
}
public String getDescription(JavaMethod method) {
String comment = method.getComment();
!
! if (comment != null) {
! return comment;
! }
!
! return "";
}
! public String getDestinationFilename(Object metadata) {
! String location = ((JavaClass)
metadata).getParentSource().getFile().getAbsolutePath();
! String basename = getTopLocation(location);
! String originalFilename =
getMetadataProvider().getOriginalFileName(metadata);
! String name = originalFilename.substring(0,
originalFilename.lastIndexOf('.'));
! return basename + "-" + name + ".confluence";
}
! public void setGeneramasourcesdir(String generamaSourcesDir) {
try {
! this.generamaSourcesDir = new
File(generamaSourcesDir).getCanonicalPath();
} catch (IOException e) {
! throw new IllegalArgumentException("Cannot resolve Generama
sources dir");
}
}
! public String isRequired(JavaMethod method) {
! DocletTag tag = method.getTagByName("generama.property", true);
!
! if (tag == null) {
! return "false";
! }
!
! String required = tag.getNamedParameter("required");
!
! if (required != null) {
! return required;
! }
!
! return "false";
! }
!
! public boolean shouldGenerate(Object metadata) {
! JavaClass javaClass = (JavaClass) metadata;
!
! //exclude generama sources
! if (generamaSourcesDir != null &&
!
javaClass.getParentSource().getFile().getAbsolutePath().startsWith(generamaSourcesDir))
{
! return false;
! }
!
! return javaClass.isA(Plugin.class.getName()) &&
!javaClass.isAbstract() &&
! javaClass.getTagByName("generama.ignore") == null;
}
***************
*** 107,116 ****
throw new IllegalStateException("basedir must be set");
}
if (!location.startsWith(basedir)) {
! throw new IllegalArgumentException("Basedir must be on top of all
scanner dirs(basedir=" + basedir + ", location=" + location + ").");
}
int startId = basedir.endsWith(File.separator) ? basedir.length() + 2
: basedir.length() + 1;
int endIdx = location.indexOf(File.separatorChar, startId);
return location.substring(startId, endIdx);
}
! }
--- 183,200 ----
throw new IllegalStateException("basedir must be set");
}
+
if (!location.startsWith(basedir)) {
! throw new IllegalArgumentException("Basedir must be on top of all
scanner dirs(basedir=" + basedir +
! ", location=" + location + ").");
}
+
int startId = basedir.endsWith(File.separator) ? basedir.length() + 2
: basedir.length() + 1;
int endIdx = location.indexOf(File.separatorChar, startId);
return location.substring(startId, endIdx);
}
!
! private boolean isBoolean(Type propertyType) {
! String type = propertyType.getValue();
! return type.equals("boolean") || type.equals("java.lang.Boolean");
! }
! }
\ No newline at end of file
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
xdoclet-plugins-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-commits