You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2011/11/03 17:41:07 UTC
svn commit: r1197211 -
/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java
Author: dblevins
Date: Thu Nov 3 16:41:07 2011
New Revision: 1197211
URL: http://svn.apache.org/viewvc?rev=1197211&view=rev
Log:
updated to generate markdown
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java?rev=1197211&r1=1197210&r2=1197211&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java Thu Nov 3 16:41:07 2011
@@ -16,6 +16,7 @@
*/
package org.apache.openejb.config.sys;
+import java.io.File;
import java.io.PrintWriter;
import java.util.Map;
import java.util.ArrayList;
@@ -24,12 +25,15 @@ import org.apache.openejb.OpenEJBExcepti
import org.apache.openejb.util.SuperProperties;
public class WikiGenerator {
+
+ private PrintWriter out;
+
public static void main(String[] args) throws Exception {
System.out.println();
System.out.println();
System.out.println();
- new WikiGenerator("org.apache.openejb").generate(new PrintWriter(System.out));
+ new WikiGenerator("org.apache.openejb", new PrintWriter(new File("/Users/dblevins/work/all/website/content/containers-and-resources.mdtext"))).generate();
System.out.println();
System.out.println();
@@ -38,35 +42,34 @@ public class WikiGenerator {
protected ServicesJar servicesJar;
- public WikiGenerator(String providerName) throws OpenEJBException {
- servicesJar = JaxbOpenejb.readServicesJar(providerName);
+ public WikiGenerator(String providerName, PrintWriter printWriter) throws OpenEJBException {
+ this(JaxbOpenejb.readServicesJar(providerName), printWriter);
}
- public WikiGenerator(ServicesJar servicesJar) {
+ public WikiGenerator(ServicesJar servicesJar, PrintWriter out) {
this.servicesJar = servicesJar;
+ this.out = out;
}
- public void generate(PrintWriter out) throws Exception {
+ public void generate() throws Exception {
// generate containers
- out.println("{anchor: containers}");
- out.println("h1. Containers");
+ out.println("# Containers");
for (ServiceProvider provider : servicesJar.getServiceProvider()) {
if ("Container".equals(provider.getService())) {
- generateService(out, provider, "container");
+ generateService(provider, "container");
}
}
out.println();
- out.println("{anchor: resources}");
- out.println("h1. Resources");
+ out.println("# Resources");
ArrayList<String> seen = new ArrayList<String>();
for (ServiceProvider provider : servicesJar.getServiceProvider()) {
if ("Resource".equals(provider.getService())) {
if (seen.containsAll(provider.getTypes())) continue;
- generateService(out, provider, "resource");
+ generateService(provider, "resource");
seen.addAll(provider.getTypes());
}
@@ -75,32 +78,45 @@ public class WikiGenerator {
out.flush();
}
- private void generateService(PrintWriter out, ServiceProvider provider, String serviceType) {
- out.println("{anchor:" + provider.getId() + "-" + serviceType + "}");
+ private void header(String... items) {
+ out.print("<tr>");
+ for (String item : items) {
+ out.print("<th>");
+ out.print(item);
+ out.print("</th>");
+ }
+ out.println("</tr>");
+ }
+
+ private void row(String... items) {
+ out.print("<tr>");
+ for (String item : items) {
+ out.print("<td>");
+ out.print(item);
+ out.print("</td>");
+ }
+ out.println("</tr>");
+ }
+
+ private void generateService(ServiceProvider provider, String serviceType) {
String type = provider.getTypes().get(0);
- out.println("h2. " + type );
+ out.println("## " + type);
+ out.println();
out.println("Declarable in openejb.xml via");
- out.println("{code:xml}");
- out.println("<"+provider.getService()+" id=\"Foo\" type=\""+type+"\">");
- out.println("</"+provider.getService()+">");
- out.println("{code}");
-
+ out.println();
+ out.println(" <" + provider.getService() + " id=\"Foo\" type=\"" + type + "\">");
+ out.println(" </" + provider.getService() + ">");
+ out.println();
out.println("Declarable in properties via");
- out.println("{panel}");
- out.println("Foo = new://"+provider.getService()+"?type="+type+"");
- out.println("{panel}");
-
-
-// out.println(" class: " + provider.getClassName());
-//
-// if (provider.getFactoryName() != null) {
-// out.println(" factory-method: " + provider.getFactoryName());
-// }
-
+ out.println();
+ out.println(" Foo = new://" + provider.getService() + "?type=" + type + "");
+ out.println();
SuperProperties properties = (SuperProperties) provider.getProperties();
if (properties.size() > 0) {
out.println("Supports the following properties");
- out.println(" || Property Name || Description ||");
+ out.println();
+ out.println("<table>");
+ header("Property Name", "Description");
for (Object key : properties.keySet()) {
if (key instanceof String) {
@@ -114,18 +130,16 @@ public class WikiGenerator {
comment = scrubText(comment);
if (value != null && value.length() > 0) {
- if (comment.length() > 0) {
- comment += "\\\\ \\\\ ";
- }
- comment += "Default value is _" + scrubText(value) + "_.|";
+ comment += "\n\nDefault value is <code>" + scrubText(value) + "</code>";
}
if (comment.length() == 0) comment = "No description.";
- out.println(" | " + name + " | " + comment + "|");
+ row(name, comment);
}
}
}
+ out.println("</table>");
} else {
out.println("No properties.");
}
@@ -134,25 +148,26 @@ public class WikiGenerator {
private String scrubText(String text) {
if (text == null) text = "";
- text = text.replaceAll("\r?\n", "\\\\\\\\ ");
- text = text.replaceAll("\\*", "\\\\*");
- text = text.replaceAll("\\_", "\\\\_");
- text = text.replaceAll("\\?", "\\\\?");
- text = text.replaceAll("\\-", "\\\\-");
- text = text.replaceAll("\\^", "\\\\^");
- text = text.replaceAll("\\~", "\\\\~");
- text = text.replaceAll("\\#", "\\\\#");
- text = text.replaceAll("\\[", "\\\\[");
- text = text.replaceAll("\\]", "\\\\]");
- text = text.replaceAll("\\{", "\\\\{");
- text = text.replaceAll("\\}", "\\\\}");
- text = text.replaceAll("\\(", "\\\\(");
- text = text.replaceAll("\\)", "\\\\)");
- text = text.replaceAll("http:", "{html}http:{html}");
- text = text.replaceAll("file:", "{html}file:{html}");
- text = text.replaceAll(" ", "{html} {html}");
- text = text.replaceAll(" ", "{html} {html}");
- text = text.replaceAll(" ", "{html} {html}");
return text;
+// text = text.replaceAll("\r?\n", "\\\\\\\\ ");
+// text = text.replaceAll("\\*", "\\\\*");
+// text = text.replaceAll("\\_", "\\\\_");
+// text = text.replaceAll("\\?", "\\\\?");
+// text = text.replaceAll("\\-", "\\\\-");
+// text = text.replaceAll("\\^", "\\\\^");
+// text = text.replaceAll("\\~", "\\\\~");
+// text = text.replaceAll("\\#", "\\\\#");
+// text = text.replaceAll("\\[", "\\\\[");
+// text = text.replaceAll("\\]", "\\\\]");
+// text = text.replaceAll("\\{", "\\\\{");
+// text = text.replaceAll("\\}", "\\\\}");
+// text = text.replaceAll("\\(", "\\\\(");
+// text = text.replaceAll("\\)", "\\\\)");
+// text = text.replaceAll("http:", "{html}http:{html}");
+// text = text.replaceAll("file:", "{html}file:{html}");
+// text = text.replaceAll(" ", "{html} {html}");
+// text = text.replaceAll(" ", "{html} {html}");
+// text = text.replaceAll(" ", "{html} {html}");
+// return text;
}
}