Create language task api and converted the current tasks.

This commit is contained in:
Willem Cazander 2013-08-30 22:40:39 +02:00
parent 57f3c20655
commit 6cd968eb17
69 changed files with 2092 additions and 1315 deletions

View file

@ -0,0 +1,62 @@
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.x4o.xml.eld.doc;
import org.x4o.xml.element.ElementException;
import org.x4o.xml.io.sax.ext.PropertyConfig;
import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.task.AbstractX4OLanguageTask;
import org.x4o.xml.lang.task.X4OLanguageTaskException;
import org.x4o.xml.lang.task.X4OLanguageTaskExecutor;
/**
* X4OWriteLanguageDoc is support class to write html documentation from the eld.
*
* @author Willem Cazander
* @version 1.0 Aug 22, 2012
*/
public class EldDocLanguageTask extends AbstractX4OLanguageTask {
public static final String TASK_ID = "eld-doc";
private static final String TASK_NAME = "ELD DOC Writer Task";
private static final String TASK_DESC = "Writes out the documentation of the language elements.";
public EldDocLanguageTask() {
super(TASK_ID,TASK_NAME,TASK_DESC,EldDocWriter.DEFAULT_PROPERTY_CONFIG);
}
/**
* Executes this language task.
*/
public X4OLanguageTaskExecutor createTaskExecutor(final PropertyConfig config) {
return new X4OLanguageTaskExecutor() {
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
try {
new EldDocWriter(language,config).writeDocumentation();
} catch (ElementException e) {
throw new X4OLanguageTaskException(config,e.getMessage(),e);
}
}
};
}
}

View file

@ -27,6 +27,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import org.x4o.xml.eld.doc.api.ApiDocWriter;
import org.x4o.xml.eld.doc.api.DefaultPageWriterHelp;
@ -35,6 +36,7 @@ import org.x4o.xml.eld.doc.api.DefaultPageWriterTree;
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
import org.x4o.xml.eld.doc.api.dom.ApiDocConcept;
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
import org.x4o.xml.eld.doc.api.dom.ApiDocRemoteClass;
import org.x4o.xml.element.ElementNamespaceAttribute;
import org.x4o.xml.element.ElementBindingHandler;
import org.x4o.xml.element.ElementClass;
@ -44,6 +46,10 @@ import org.x4o.xml.element.ElementConfiguratorGlobal;
import org.x4o.xml.element.ElementInterface;
import org.x4o.xml.element.ElementException;
import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.io.sax.ext.ContentWriterXml;
import org.x4o.xml.io.sax.ext.PropertyConfig;
import org.x4o.xml.io.sax.ext.PropertyConfig.PropertyConfigItem;
import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageModule;
import org.x4o.xml.lang.X4OLanguageSession;
import org.xml.sax.SAXException;
@ -56,8 +62,8 @@ import org.xml.sax.SAXException;
*/
public class EldDocWriter {
// The context to write doc over.
private X4OLanguageSession context = null;
private final static String DEFAULT_NAME = "X4O ELD DOC";
private final static String DEFAULT_DESCRIPTION = "X4O Meta Language Documentation.";
// Core concepts
private static final String[] C_CONTEXT = {"language","Overview","All language modules.","The loaded language modules.."};
@ -73,12 +79,51 @@ public class EldDocWriter {
private static final String[] CC_CONFIGURATOR_G = {"configurator-global","ConfiguratorGlobal","The global configurator.","The global configurator."};
private static final String[] CC_BINDING = {"binding","Binding","The element binding.","The element binding."};
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_ELD_DOC;
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
public final static String DOC_NAME = PROPERTY_CONTEXT_PREFIX+"doc/name";
public final static String DOC_DESCRIPTION = PROPERTY_CONTEXT_PREFIX+"doc/description";
public final static String DOC_ABOUT = PROPERTY_CONTEXT_PREFIX+"doc/about";
public final static String DOC_COPYRIGHT = PROPERTY_CONTEXT_PREFIX+"doc/copyright";
public final static String DOC_PAGE_SUB_TITLE = PROPERTY_CONTEXT_PREFIX+"doc/page-sub-title";
public final static String META_KEYWORDS = PROPERTY_CONTEXT_PREFIX+"meta/keywords";
public final static String META_STYLESHEET = PROPERTY_CONTEXT_PREFIX+"meta/stylesheet";
public final static String META_STYLESHEET_THEMA = PROPERTY_CONTEXT_PREFIX+"meta/stylesheet-thema";
public final static String JAVADOC_LINK = PROPERTY_CONTEXT_PREFIX+"javadoc/link";
public final static String JAVADOC_LINK_OFFLINE = PROPERTY_CONTEXT_PREFIX+"javadoc/link-offline";
static {
DEFAULT_PROPERTY_CONFIG = new PropertyConfig(true,ContentWriterXml.DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX,
new PropertyConfigItem(true,OUTPUT_PATH,File.class),
new PropertyConfigItem(false,DOC_NAME,String.class),
new PropertyConfigItem(false,DOC_DESCRIPTION,String.class),
new PropertyConfigItem(false,DOC_ABOUT,String.class),
new PropertyConfigItem(false,DOC_COPYRIGHT,String.class),
new PropertyConfigItem(false,DOC_PAGE_SUB_TITLE,String.class),
new PropertyConfigItem(false,META_KEYWORDS,List.class),
new PropertyConfigItem(false,META_STYLESHEET,File.class),
new PropertyConfigItem(false,META_STYLESHEET_THEMA,String.class),
new PropertyConfigItem(false,JAVADOC_LINK,List.class),
new PropertyConfigItem(false,JAVADOC_LINK_OFFLINE,Map.class)
);
}
/** The config of this writer. */
private final PropertyConfig propertyConfig;
/** The language to write doc over. */
private final X4OLanguage language;
/**
* Creates an EldDocGenerator for this langauge context.
* @param context The language context to generate doc for.
* @param language The language to generate doc for.
*/
public EldDocWriter(X4OLanguageSession context) {
this.context=context;
public EldDocWriter(X4OLanguage language,PropertyConfig parentConfig) {
this.language=language;
this.propertyConfig=new PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
this.propertyConfig.copyParentProperties(parentConfig);
}
/**
@ -86,8 +131,9 @@ public class EldDocWriter {
* @param basePath The path to write to documentation to.
* @throws ElementException Is thrown when error is done.
*/
public void writeDoc(File basePath) throws ElementException {
public void writeDocumentation() throws ElementException {
try {
File basePath = propertyConfig.getPropertyFile(OUTPUT_PATH);
ApiDocWriter writer = new ApiDocWriter();
ApiDoc doc = buildLanguageDoc();
writer.write(doc, basePath);
@ -98,24 +144,47 @@ public class EldDocWriter {
}
}
/**
* Creates a fully configured ApiDco object.
* @return The ApiDoc configured to write eld documentation.
*/
private ApiDoc buildLanguageDoc() {
// Generic config
ApiDoc doc = new ApiDoc();
doc.setName("X4O ELD DOC");
doc.setDescription("X4O Meta Language Description");
doc.setDocAbout(createLanguageAbout());
doc.setDocCopyright(createLanguageCopyright());
doc.setDocPageSubTitle(createPageSubTitle());
doc.addDocKeywordAll(createLanguageKeywords());
doc.setName( propertyConfig.getPropertyStringOrValue(DOC_NAME, DEFAULT_NAME));
doc.setDescription( propertyConfig.getPropertyStringOrValue(DOC_DESCRIPTION, DEFAULT_DESCRIPTION));
doc.setDocAbout( propertyConfig.getPropertyStringOrValue(DOC_ABOUT, createLanguageAbout()));
doc.setDocCopyright( propertyConfig.getPropertyStringOrValue(DOC_COPYRIGHT, createLanguageCopyright()));
doc.setDocPageSubTitle( propertyConfig.getPropertyStringOrValue(DOC_PAGE_SUB_TITLE, createPageSubTitle()));
doc.setMetaStyleSheetThema( propertyConfig.getPropertyString(META_STYLESHEET_THEMA));
doc.setMetaStyleSheet( propertyConfig.getPropertyFile(META_STYLESHEET));
List<String> keywords = propertyConfig.getPropertyList(META_KEYWORDS);
if (keywords==null) {
keywords = createLanguageKeywords();
}
doc.addMetaKeywordAll(keywords);
doc.setNoFrameAllName("All Elements");
doc.setFrameNavPrintParent(true);
doc.setFrameNavPrintParentId(true);
doc.setGroupTypeName("summary", "Summary");
doc.setGroupTypeName("overview", "Overview");
// TODO: add config bean to task launcher
//doc.addRemoteClass(new ApiDocRemoteClass("file:///home/willemc/devv/git/x4o/x4o-driver/target/apidocs"));
//doc.addRemoteClass(new ApiDocRemoteClass("http://docs.oracle.com/javase/7/docs/api/"));
// Javadoc linking config
List<String> javadocLinkList = propertyConfig.getPropertyList(JAVADOC_LINK);
Map<String,String> javadocLinkOfflineMap = propertyConfig.getPropertyMap(JAVADOC_LINK_OFFLINE);
if (javadocLinkList!=null) {
for (String javadocUrl:javadocLinkList) {
doc.addRemoteClass(new ApiDocRemoteClass(javadocUrl));
}
}
if (javadocLinkOfflineMap!=null) {
for (Map.Entry<String,String> offlineLink:javadocLinkOfflineMap.entrySet()) {
doc.addRemoteClass(new ApiDocRemoteClass(offlineLink.getKey(),offlineLink.getValue()));
}
}
// Tree and navagation config
doc.setFrameNavConceptClass(ElementClass.class);
doc.addTreeNodePageModeClass(X4OLanguageSession.class);
@ -129,7 +198,7 @@ public class EldDocWriter {
doc.addAnnotatedClasses(EldDocWriterElementNamespace.class);
doc.addAnnotatedClasses(EldDocWriterElementInterface.class);
ApiDocConcept adcRoot = doc.addConcept(new ApiDocConcept(null,C_CONTEXT,X4OLanguageSession.class));
ApiDocConcept adcRoot = doc.addConcept(new ApiDocConcept(null,C_CONTEXT,X4OLanguage.class));
ApiDocConcept adcMod = doc.addConcept(new ApiDocConcept(adcRoot,C_MODULE,X4OLanguageModule.class));
ApiDocConcept adcIface = doc.addConcept(new ApiDocConcept(adcMod,C_INTERFACE,ElementInterface.class));
ApiDocConcept adcNs = doc.addConcept(new ApiDocConcept(adcMod,C_NAMESPACE,ElementNamespace.class));
@ -144,14 +213,16 @@ public class EldDocWriter {
adcEc.addChildConcepts(new ApiDocConcept(adcEc,CC_CONFIGURATOR,ElementConfigurator.class));
adcEc.addChildConcepts(new ApiDocConcept(adcEc,CC_ATTRIBUTE,ElementClassAttribute.class));
// Non-tree pages config
doc.addDocPage(EldDocXTreePageWriter.createDocPage());
doc.addDocPage(DefaultPageWriterTree.createDocPage());
doc.addDocPage(DefaultPageWriterIndexAll.createDocPage());
doc.addDocPage(DefaultPageWriterHelp.createDocPage());
ApiDocNode rootNode = new ApiDocNode(context,"language",getLanguageNameUpperCase()+" Language","The X4O "+getLanguageNameUpperCase()+" Language");
// Doc tree config
ApiDocNode rootNode = new ApiDocNode(language,"language",getLanguageNameUpperCase()+" Language","The X4O "+getLanguageNameUpperCase()+" Language");
doc.setRootNode(rootNode);
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { ApiDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
for (X4OLanguageModule mod:language.getLanguageModules()) { ApiDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
for (ElementBindingHandler bind:mod.getElementBindingHandlers()) { modNode.addNode(createNodeElementBindingHandler(bind)); }
for (ElementConfiguratorGlobal conf:mod.getElementConfiguratorGlobals()) { modNode.addNode(createNodeElementConfiguratorGlobal(conf)); }
for (ElementInterface iface:mod.getElementInterfaces()) { ApiDocNode ifaceNode = modNode.addNode(createNodeElementInterface(iface));
@ -196,9 +267,9 @@ public class EldDocWriter {
private String createPageSubTitle() {
StringBuffer buf = new StringBuffer(100);
buf.append(context.getLanguage().getLanguageName());
buf.append(language.getLanguageName());
buf.append(" ");// note use real space as 'html/header/title' will not always escape entities. TODO: add to html writer
buf.append(context.getLanguage().getLanguageVersion());
buf.append(language.getLanguageVersion());
buf.append(" API");
return buf.toString();
}
@ -206,9 +277,9 @@ public class EldDocWriter {
private String createLanguageAbout() {
StringBuffer buf = new StringBuffer(100);
buf.append("XML X4O Language\n");
buf.append(context.getLanguage().getLanguageName().toUpperCase());
buf.append(language.getLanguageName().toUpperCase());
buf.append("&trade;&nbsp;");
buf.append(context.getLanguage().getLanguageVersion());
buf.append(language.getLanguageVersion());
return buf.toString();
}
@ -226,15 +297,18 @@ public class EldDocWriter {
private List<String> createLanguageKeywords() {
List<String> keywords = new ArrayList<String>(10);
keywords.add(context.getLanguage().getLanguageName());
keywords.add(language.getLanguageName());
keywords.add("x4o");
keywords.add("eld");
keywords.add("xml");
keywords.add("xsd");
keywords.add("schema");
keywords.add("language");
keywords.add("documentation");
return keywords;
}
private String getLanguageNameUpperCase() {
return context.getLanguage().getLanguageName().toUpperCase();
return language.getLanguageName().toUpperCase();
}
}

View file

@ -39,7 +39,7 @@ import org.x4o.xml.element.ElementClassAttribute;
import org.x4o.xml.element.ElementConfigurator;
import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
import org.x4o.xml.lang.X4OLanguageSession;
import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageModule;
import org.xml.sax.SAXException;
@ -113,13 +113,13 @@ public class EldDocWriterElementClass extends AbstractApiDocWriter {
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
ElementNamespace ns = (ElementNamespace)event.getEventObject().getParent().getUserData();
X4OLanguageModule mod = (X4OLanguageModule)event.getEventObject().getParent().getParent().getUserData();
X4OLanguageSession context = (X4OLanguageSession)event.getEventObject().getParent().getParent().getParent().getUserData();
X4OLanguage language = (X4OLanguage)event.getEventObject().getParent().getParent().getParent().getUserData();
// TODO: this is hacky
EldDocXTreePageWriter xtree = (EldDocXTreePageWriter)event.getDoc().findDocPageById("overview-xtree").getPageWriters().get(0);
TreeNode node = xtree.new TreeNode();
node.context=context;
node.language=language;
node.module=mod;
node.namespace=ns;
node.elementClass=ec;

View file

@ -33,7 +33,7 @@ import org.x4o.xml.element.ElementBindingHandler;
import org.x4o.xml.element.ElementClassAttribute;
import org.x4o.xml.element.ElementConfigurator;
import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.lang.X4OLanguageSession;
import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageModule;
import org.xml.sax.SAXException;
@ -64,18 +64,18 @@ public class EldDocWriterLanguage extends AbstractApiDocWriter {
}
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageSession.class},nodeBodyOrders={1})
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguage.class},nodeBodyOrders={1})
public void writeLanguageSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
ApiDocContentWriter writer = event.getWriter();
ApiDocNode node = event.getEventObject();
X4OLanguageSession context = (X4OLanguageSession)node.getUserData();
X4OLanguage language = (X4OLanguage)node.getUserData();
int attrHandlers = 0;
int bindHandlers = 0;
int interFaces = 0;
int eleConfigs = 0;
int elements = 0;
int namespaces = 0;
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
for (X4OLanguageModule mod:language.getLanguageModules()) {
bindHandlers += mod.getElementBindingHandlers().size();
interFaces += mod.getElementInterfaces().size();
eleConfigs += mod.getElementConfiguratorGlobals().size();
@ -87,9 +87,9 @@ public class EldDocWriterLanguage extends AbstractApiDocWriter {
}
writer.docTableStart("Language Summary", "Language Stats Summary.",ApiDocContentCss.overviewSummary);
writer.docTableHeader("Name", "Value");
writer.docTableRow("LanguageName:", ""+context.getLanguage().getLanguageName(), null);
writer.docTableRow("LanguageVersion:",""+context.getLanguage().getLanguageVersion(),null);
writer.docTableRow("Modules:",""+context.getLanguage().getLanguageModules().size(),null);
writer.docTableRow("LanguageName:", ""+language.getLanguageName(), null);
writer.docTableRow("LanguageVersion:",""+language.getLanguageVersion(),null);
writer.docTableRow("Modules:",""+language.getLanguageModules().size(),null);
writer.docTableRow("Elements:",""+elements,null);
writer.docTableRow("ElementNamespaces:",""+namespaces,null);
writer.docTableRow("ElementNamespaceAttribute:",""+attrHandlers,null);
@ -99,19 +99,19 @@ public class EldDocWriterLanguage extends AbstractApiDocWriter {
writer.docTableEnd();
}
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageSession.class},nodeBodyOrders={2})
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguage.class},nodeBodyOrders={2})
public void writeModulesSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
printApiTable(event,"Module Summary",X4OLanguageModule.class);
}
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageSession.class},nodeBodyOrders={3})
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguage.class},nodeBodyOrders={3})
public void writeNamespaceSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
ApiDocContentWriter writer = event.getWriter();
ApiDocNode node = event.getEventObject();
X4OLanguageSession context = (X4OLanguageSession)node.getUserData();
X4OLanguage language = (X4OLanguage)node.getUserData();
writer.docTableStart("Namespace Summary", "All Language Namespaces Overview",ApiDocContentCss.overviewSummary);
writer.docTableHeader("ID", "URI");
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
for (X4OLanguageModule mod:language.getLanguageModules()) {
for (ElementNamespace ns:mod.getElementNamespaces()) {
writer.docTableRowLink("language/"+ApiDocContentWriter.toSafeUri(mod.getId())+"/"+ApiDocContentWriter.toSafeUri(ns.getId())+"/index.html",ns.getId(),ns.getUri());
}

View file

@ -39,7 +39,7 @@ import org.x4o.xml.element.ElementClass;
import org.x4o.xml.element.ElementInterface;
import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
import org.x4o.xml.lang.X4OLanguageSession;
import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageModule;
import org.xml.sax.SAXException;
@ -81,19 +81,19 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
//selectRootNode(e.getDoc()); // create
ApiDoc doc = e.getDoc();
X4OLanguageSession context = (X4OLanguageSession)doc.getRootNode().getUserData();
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
String pathPrefix = "language/";
// temp print old way
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
for (X4OLanguageModule mod:language.getLanguageModules()) {
for (ElementNamespace ns:mod.getElementNamespaces()) {
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
// found language root elements.
for (ElementClass ec:ns.getElementClasses()) {
TreeNode node = new TreeNode();
node.context=context;
node.language=language;
node.module=mod;
node.namespace=ns;
node.elementClass=ec;
@ -137,17 +137,17 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
private ApiDocNode createXTree(ApiDoc doc) throws SAXException {
X4OLanguageSession context = (X4OLanguageSession)doc.getRootNode().getUserData();
ApiDocNode root = new ApiDocNode(context,"root","Root","Language root");
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
ApiDocNode root = new ApiDocNode(language,"root","Root","Language root");
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
for (X4OLanguageModule mod:language.getLanguageModules()) {
for (ElementNamespace ns:mod.getElementNamespaces()) {
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
// found language root elements.
for (ElementClass ec:ns.getElementClasses()) {
TreeNode node = new TreeNode();
node.context=context;
node.language=language;
node.module=mod;
node.namespace=ns;
node.elementClass=ec;
@ -175,7 +175,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
class TreeNode {
X4OLanguageSession context;
X4OLanguage language;
X4OLanguageModule module;
ElementNamespace namespace;
ElementClass elementClass;
@ -189,14 +189,14 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
if (node.indent>20) {
return result; // hard fail limit
}
for (X4OLanguageModule mod:node.context.getLanguage().getLanguageModules()) {
for (X4OLanguageModule mod:node.language.getLanguageModules()) {
for (ElementNamespace ns:mod.getElementNamespaces()) {
for (ElementClass ec:ns.getElementClasses()) {
TreeNode n=null;
List<String> tags = ec.getElementParents(node.namespace.getUri());
if (tags!=null && tags.contains(node.elementClass.getId())) {
n = new TreeNode();
n.context=node.context;
n.language=node.language;
n.module=mod;
n.namespace=ns;
n.elementClass=ec;
@ -207,11 +207,11 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
continue;
}
// Check interfaces of parent , and see if child tag is there.
for (ElementInterface ei:node.context.getLanguage().findElementInterfaces(ec.getObjectClass())) {
for (ElementInterface ei:node.language.findElementInterfaces(ec.getObjectClass())) {
List<String> eiTags = ei.getElementParents(node.namespace.getUri());
if (eiTags!=null && eiTags.contains(node.elementClass.getId())) {
n = new TreeNode();
n.context=node.context;
n.language=node.language;
n.module=mod;
n.namespace=ns;
n.elementClass=ec;
@ -224,10 +224,10 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
if (node.elementClass.getObjectClass()==null) {
continue;
}
List<ElementBindingHandler> binds = node.context.getLanguage().findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
if (binds.isEmpty()==false) {
n = new TreeNode();
n.context=node.context;
n.language=node.language;
n.module=mod;
n.namespace=ns;
n.elementClass=ec;
@ -261,7 +261,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
public List<TreeNode> findParents(TreeNode node) {
List<TreeNode> result = new ArrayList<TreeNode>(10);
TreeNode n=null;
for (X4OLanguageModule mod:node.context.getLanguage().getLanguageModules()) {
for (X4OLanguageModule mod:node.language.getLanguageModules()) {
for (ElementNamespace ns:mod.getElementNamespaces()) {
List<String> tags = node.elementClass.getElementParents(ns.getUri());
@ -269,7 +269,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
for (ElementClass ec:ns.getElementClasses()) {
if (tags.contains(ec.getId())) {
n = new TreeNode();
n.context=node.context;
n.language=node.language;
n.module=mod;
n.namespace=ns;
n.elementClass=ec;
@ -283,11 +283,11 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
// Check interfaces of parent , and see if child tag is there.
if (node.elementClass.getObjectClass()!=null) {
for (ElementInterface ei:node.context.getLanguage().findElementInterfaces(node.elementClass.getObjectClass())) {
for (ElementInterface ei:node.language.findElementInterfaces(node.elementClass.getObjectClass())) {
List<String> eiTags = ei.getElementParents(ns.getUri());
if (eiTags!=null && eiTags.contains(ec.getId())) {
n = new TreeNode();
n.context=node.context;
n.language=node.language;
n.module=mod;
n.namespace=ns;
n.elementClass=ec;
@ -304,10 +304,10 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
if (node.elementClass.getObjectClass()==null) {
continue;
}
List<ElementBindingHandler> binds = node.context.getLanguage().findElementBindingHandlers(ec.getObjectClass(),node.elementClass.getObjectClass());
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(ec.getObjectClass(),node.elementClass.getObjectClass());
if (binds.isEmpty()==false) {
n = new TreeNode();
n.context=node.context;
n.language=node.language;
n.module=mod;
n.namespace=ns;
n.elementClass=ec;

View file

@ -1,146 +0,0 @@
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.x4o.xml.eld.doc;
import java.io.File;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.x4o.xml.X4ODriver;
import org.x4o.xml.X4ODriverManager;
import org.x4o.xml.element.ElementException;
import org.x4o.xml.lang.X4OLanguageSession;
/**
* X4OWriteLanguageDoc is support class to write html documentation from the eld.
*
* @author Willem Cazander
* @version 1.0 Aug 22, 2012
*/
public class X4OWriteLanguageDocExecutor {
private String languageName = null;
private String languageVersion = null;
private File basePath;
/**
* Config and executes this language task.
* @param argu The command line arguments.
*/
public static void main(String[] argu) {
X4OWriteLanguageDocExecutor languageSchema = new X4OWriteLanguageDocExecutor();
List<String> arguList = Arrays.asList(argu);
Iterator<String> arguIterator = arguList.iterator();
while (arguIterator.hasNext()) {
String arg = arguIterator.next();
if ("-path".equals(arg) || "-p".equals(arg)) {
if (arguIterator.hasNext()==false) {
System.err.println("No argument for "+arg+" given.");
System.exit(1);
return;
}
File schemaBasePath = new File(arguIterator.next());
if (schemaBasePath.exists()==false) {
System.err.println("path does not exists; "+schemaBasePath);
System.exit(1);
return;
}
languageSchema.setBasePath(schemaBasePath);
continue;
}
if ("-language".equals(arg) || "-l".equals(arg)) {
if (arguIterator.hasNext()==false) {
System.err.println("No argument for "+arg+" given.");
System.exit(1);
return;
}
String languageName = arguIterator.next();
languageSchema.setLanguageName(languageName);
continue;
}
}
try {
languageSchema.execute();
} catch (ElementException e) {
System.err.println("Error while schema writing: "+e.getMessage());
e.printStackTrace();
System.exit(1);
return;
}
}
/**
* Executes this language task.
*/
public void execute() throws ElementException {
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(getLanguageName());
X4OLanguageSession context = driver.createLanguage(getLanguageVersion()).createLanguageSession();
// Run doc writer
EldDocWriter docWriter = new EldDocWriter(context);
docWriter.writeDoc(getBasePath());
}
/**
* @return the languageVersion
*/
public String getLanguageVersion() {
return languageVersion;
}
/**
* @param languageVersion the languageVersion to set
*/
public void setLanguageVersion(String languageVersion) {
this.languageVersion = languageVersion;
}
/**
* @return the languageName
*/
public String getLanguageName() {
return languageName;
}
/**
* @param languageName the languageName to set
*/
public void setLanguageName(String languageName) {
this.languageName = languageName;
}
/**
* @return the basePath
*/
public File getBasePath() {
return basePath;
}
/**
* @param basePath the basePath to set
*/
public void setBasePath(File basePath) {
this.basePath = basePath;
}
}

View file

@ -1,14 +1,15 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL

View file

@ -1,14 +1,15 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL

View file

@ -24,6 +24,7 @@ package org.x4o.xml.eld.doc.api;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@ -390,8 +391,6 @@ public class ApiDocWriter extends AbstractApiDocWriter {
}
}
public void defaultWriteSummary(ApiDocNode node,ApiDocContentWriter writer) throws SAXException {
ApiDocConcept concept = doc.findConceptByClass(node.getUserData().getClass());
printApiTable(node, node.getNodes(), writer, concept.getName()+" Summary");
@ -531,7 +530,6 @@ public class ApiDocWriter extends AbstractApiDocWriter {
}
return result;
}
private void buildParentPath(ApiDocNode node,List<String> path) {
if (node.getParent()==null) {
@ -544,30 +542,43 @@ public class ApiDocWriter extends AbstractApiDocWriter {
private void writeStyleSheet() throws IOException {
try {
StringBuffer cssData = new StringBuffer();
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-html.css");
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-layout.css");
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-inset.css");
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-font.css");
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-color.css");
if (doc.getMetaStyleSheet()!=null) {
copyStreamToFile(new FileInputStream(doc.getMetaStyleSheet()),basePath,"resources","stylesheet.css");
return;
}
String thema = doc.getMetaStyleSheetThema();
if (thema==null) {
thema = "jdk7";
}
List<String> cssResources = new ArrayList<String>(10);
cssResources.add("org/x4o/xml/eld/doc/theme/base/api-html.css");
cssResources.add("org/x4o/xml/eld/doc/theme/base/api-layout.css");
cssResources.add("org/x4o/xml/eld/doc/theme/base/api-inset.css");
cssResources.add("org/x4o/xml/eld/doc/theme/base/api-font.css");
cssResources.add("org/x4o/xml/eld/doc/theme/base/api-color.css");
//appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css");
appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css");
String css = cssData.toString();
css = css.replaceAll("\\s+"," ");
css = css.replaceAll("\\s*:\\s*",":");
css = css.replaceAll("\\s*\\;\\s*",";");
css = css.replaceAll("\\s*\\,\\s*",",");
css = css.replaceAll("\\s*\\{\\s*","{");
css = css.replaceAll("\\s*\\}\\s*","}\n"); // add return to have multi line file.
writeFileString(css,basePath,"resources","stylesheet.css");
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/background.png",basePath,"resources","background.png");
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/tab.png",basePath,"resources","tab.png");
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png",basePath,"resources","titlebar_end.png");
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/titlebar.png",basePath,"resources","titlebar.png");
if ("jdk6".equals(thema)) {
cssResources.add("org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css");
writeStyleSheetResources(cssResources);
return;
}
if ("jdk7".equals(thema)) {
cssResources.add("org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css");
writeStyleSheetResources(cssResources);
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/background.png",basePath,"resources","background.png");
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/tab.png",basePath,"resources","tab.png");
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png",basePath,"resources","titlebar_end.png");
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/titlebar.png",basePath,"resources","titlebar.png");
return;
}
if ("jdk7-todo".equals(thema)) {
cssResources.add("org/x4o/xml/eld/doc/theme/jdk7-todo/stylesheet.css");
writeStyleSheetResources(cssResources);
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/background.png",basePath,"resources","background.png");
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/tab.png",basePath,"resources","tab.png");
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png",basePath,"resources","titlebar_end.png");
copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/titlebar.png",basePath,"resources","titlebar.png");
}
} catch (SecurityException e) {
throw new IOException(e.getMessage());
} catch (InterruptedException e) {
@ -575,6 +586,22 @@ public class ApiDocWriter extends AbstractApiDocWriter {
}
}
private void writeStyleSheetResources(List<String> resources) throws IOException, SecurityException, InterruptedException {
StringBuffer cssData = new StringBuffer();
for (String cssResource:resources) {
appendResourceToBuffer(cssData,cssResource);
}
String css = cssData.toString();
css = css.replaceAll("\\s+"," ");
css = css.replaceAll("\\s*:\\s*",":");
css = css.replaceAll("\\s*\\;\\s*",";");
css = css.replaceAll("\\s*\\,\\s*",",");
css = css.replaceAll("\\s*\\{\\s*","{");
css = css.replaceAll("\\s*\\}\\s*","}\n"); // add return to have multi line file.
writeFileString(css,basePath,"resources","stylesheet.css");
}
private void writeHeader(ApiDocContentWriter writer,String resourcePrefix,String title) throws SAXException {
writer.printTagStart(Tag.head);
writer.docCommentGenerated();
@ -889,6 +916,11 @@ public class ApiDocWriter extends AbstractApiDocWriter {
private void copyResourceToFile(String resource,File basePath,String...argu) throws SecurityException, IOException, InterruptedException {
ClassLoader cl = X4OLanguageClassLoader.getClassLoader();
InputStream inputStream = cl.getResourceAsStream(resource);
copyStreamToFile(inputStream,basePath,argu);
}
private void copyStreamToFile(InputStream inputStream,File basePath,String...argu) throws SecurityException, IOException, InterruptedException {
OutputStream outputStream = new FileOutputStream(createOutputPathFile(basePath,argu));
try {
byte[] buffer = new byte[4096];

View file

@ -22,6 +22,7 @@
*/
package org.x4o.xml.eld.doc.api.dom;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
@ -49,7 +50,9 @@ public class ApiDoc {
private List<ApiDocConcept> concepts = null;
private String docCopyright = null;
private String docAbout = null;
private List<String> docKeywords = null;
private List<String> metaKeywords = null;
private File metaStyleSheet = null;
private String metaStyleSheetThema = null;
private List<ApiDocPage> docPages = null;
private Class<?> frameNavConceptClass = null;
private Boolean frameNavOverviewPrintParent = null;
@ -77,7 +80,7 @@ public class ApiDoc {
public ApiDoc() {
nodeBodyWriters = new ArrayList<ApiDocNodeWriter>(20);
concepts = new ArrayList<ApiDocConcept>(10);
docKeywords = new ArrayList<String>(5);
metaKeywords = new ArrayList<String>(5);
docPages = new ArrayList<ApiDocPage>(5);
treeNodeClassExcludes = new ArrayList<Class<?>>(5);
treeNodePageModeClass = new ArrayList<Class<?>>(5);
@ -277,20 +280,48 @@ public class ApiDoc {
return concepts;
}
public void addDocKeyword(String keyword) {
docKeywords.add(keyword);
public void addMetaKeyword(String keyword) {
metaKeywords.add(keyword);
}
public void addDocKeywordAll(Collection<String> keywords) {
docKeywords.addAll(keywords);
public void addMetaKeywordAll(Collection<String> keywords) {
metaKeywords.addAll(keywords);
}
public boolean removeDocKeyword(String keyword) {
return docKeywords.remove(keyword);
public boolean removeMetaKeyword(String keyword) {
return metaKeywords.remove(keyword);
}
public List<String> getDocKeywords() {
return docKeywords;
return metaKeywords;
}
/**
* @return the metaStyleSheet
*/
public File getMetaStyleSheet() {
return metaStyleSheet;
}
/**
* @param metaStyleSheet the metaStyleSheet to set
*/
public void setMetaStyleSheet(File metaStyleSheet) {
this.metaStyleSheet = metaStyleSheet;
}
/**
* @return the metaStyleSheetThema
*/
public String getMetaStyleSheetThema() {
return metaStyleSheetThema;
}
/**
* @param metaStyleSheetThema the metaStyleSheetThema to set
*/
public void setMetaStyleSheetThema(String metaStyleSheetThema) {
this.metaStyleSheetThema = metaStyleSheetThema;
}
/**

View file

@ -47,15 +47,27 @@ public class ApiDocRemoteClass {
private String packageListUrl = null;
private List<String> packageList = null;
/**
* Creates the ApiDocRemoteClass.
*/
private ApiDocRemoteClass() {
packageList = new ArrayList<String>(100);
}
/**
* Creates the ApiDocRemoteClass with a javadoc url to fetch the package-list from.
* @param docUrl The remote javadoc base url.
*/
public ApiDocRemoteClass(String docUrl) {
this();
setDocUrl(docUrl);
}
/**
* Creates the ApiDocRemoteClass with a javadoc url. but fetched the package-list from the packageListUrl.
* @param docUrl The remote javadoc base url.
* @param packageListUrl The remote/local package-list url.
*/
public ApiDocRemoteClass(String docUrl,String packageListUrl) {
this(docUrl);
setPackageListUrl(packageListUrl);
@ -87,6 +99,10 @@ public class ApiDocRemoteClass {
return null;
}
/**
* Cleans the docUrl by sometimes appending postfix slash.
* @return The cleaned doc url.
*/
private String getDocUrlClean() {
String baseUrl = getDocUrl();
if (baseUrl.endsWith("/")==false) {
@ -95,6 +111,10 @@ public class ApiDocRemoteClass {
return baseUrl;
}
/**
* Fetches and parses the package-list file.
* @throws IOException If error happend.
*/
public void parseRemotePackageList() throws IOException {
packageList.clear();
String baseUrl = getDocUrlClean();
@ -106,6 +126,12 @@ public class ApiDocRemoteClass {
parseRemoteFile(conn.getInputStream(), conn.getContentEncoding());
}
/**
* Parsed the inputStream into the packagList values.
* @param in The inputStream.
* @param enc The encoding of the inputStream.
* @throws IOException When error on inputStream.
*/
private void parseRemoteFile(InputStream in,String enc) throws IOException {
if (enc==null) {
enc = "UTF-8";
@ -129,7 +155,7 @@ public class ApiDocRemoteClass {
public String getDocUrl() {
return docUrl;
}
/**
* @param docUrl the docUrl to set
*/

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2004-2013, Willem Cazander
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided
that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<drivers version="1.0"
xmlns="http://language.x4o.org/xml/ns/drivers"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://language.x4o.org/xml/ns/drivers http://language.x4o.org/xml/ns/drivers-1.0.xsd"
>
<languageTask className="org.x4o.xml.eld.doc.EldDocLanguageTask"/>
</drivers>

View file

@ -1,5 +1,25 @@
/* Color style sheet */
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
body {
background-color:#ffffff;

View file

@ -1,4 +1,26 @@
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
body {
font-family:Arial, Helvetica, sans-serif;
font-size:76%;

View file

@ -1,5 +1,25 @@
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
a:link, a:visited {
text-decoration:none;

View file

@ -1,4 +1,25 @@
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
body {
margin:0px;

View file

@ -1,4 +1,25 @@
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
.clear {
clear:both;

View file

@ -1,3 +1,25 @@
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
body {
padding:10px;

View file

@ -1,3 +1,25 @@
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
.tab {
background-image:url(titlebar.png);

View file

@ -24,11 +24,13 @@ package org.x4o.xml.eld.doc;
import java.io.File;
import org.x4o.xml.X4ODriver;
import org.x4o.xml.X4ODriverManager;
import org.x4o.xml.eld.CelDriver;
import org.x4o.xml.eld.EldDriver;
import org.x4o.xml.io.sax.ext.PropertyConfig;
import org.x4o.xml.lang.task.X4OLanguageTask;
import org.x4o.xml.test.TestDriver;
import org.x4o.xml.test.swixml.SwiXmlDriver;
import junit.framework.TestCase;
@ -40,42 +42,41 @@ import junit.framework.TestCase;
*/
public class X4OWriteLanguageDocExecutorTest extends TestCase {
private File createOutputTargetPath(String dir) throws Exception {
File tempFile = new File("target/path");
//File tempFile = File.createTempFile("junit", "test");
String absolutePath = tempFile.getAbsolutePath();
String tempPath = absolutePath.substring(0,absolutePath.lastIndexOf(File.separator)+1);
tempFile.delete();
File result = new File(tempPath+File.separator+dir);
private File createOutputPath(String dir) throws Exception {
File result = new File("target/tests"+File.separator+dir);
if (result.exists()==false) {
result.mkdir();
result.mkdirs();
}
return result;
}
public void testCelDoc() throws Exception {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
writer.setBasePath(createOutputTargetPath("junit-cel"));
writer.setLanguageName(CelDriver.LANGUAGE_NAME);
writer.execute();
public void testDoc(String language,String outputPostfix) throws Exception {
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(language);
X4OLanguageTask task = driver.getLanguageTask(EldDocLanguageTask.TASK_ID);
PropertyConfig config = task.createTaskConfig();
File outputPath = createOutputPath(outputPostfix);
config.setProperty(EldDocWriter.OUTPUT_PATH,outputPath);
task.createTaskExecutor(config).execute(driver.createLanguage());
assertTrue(outputPath.exists());
assertTrue(outputPath.list()!=null);
assertTrue(outputPath.list().length>2);
}
public void testCelDoc() throws Exception {
testDoc(CelDriver.LANGUAGE_NAME,"junit-doc-cel");
}
public void testEldDoc() throws Exception {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
writer.setBasePath(createOutputTargetPath("junit-eld"));
writer.setLanguageName(EldDriver.LANGUAGE_NAME);
writer.execute();
testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld");
}
public void testUnitDoc() throws Exception {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
writer.setBasePath(createOutputTargetPath("junit-test"));
writer.setLanguageName(TestDriver.LANGUAGE_NAME);
writer.execute();
testDoc(TestDriver.LANGUAGE_NAME,"junit-doc-test");
}
/*
public void testSwiXml2Doc() throws Exception {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld");
EldDocLanguageTask writer = new EldDocLanguageTask();
writer.setBasePath(createOutputTargetPath("junit-swixml2"));
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2);
@ -83,15 +84,12 @@ public class X4OWriteLanguageDocExecutorTest extends TestCase {
}
public void testSwiXml3Doc() throws Exception {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld");
EldDocLanguageTask writer = new EldDocLanguageTask();
writer.setBasePath(createOutputTargetPath("junit-swixml3"));
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3);
writer.execute();
}
public void testEldDocMain() throws Exception {
X4OWriteLanguageDocExecutor.main(new String[] {"-p",createOutputTargetPath("junit-test-main").getAbsolutePath(),"-l",EldDriver.LANGUAGE_NAME});
}
*/
}