Created sax content writers and created generic api doc model for
documentation. Improved writer support with attribute write order and new-lining after long attribute values.
This commit is contained in:
parent
92644fd148
commit
8d71b63a6f
82 changed files with 5637 additions and 2620 deletions
271
x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java
Normal file
271
x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
* 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.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
|
||||
import org.x4o.xml.eld.doc.api.ApiDocNodeWriterBean;
|
||||
import org.x4o.xml.eld.doc.api.ApiDocNodeWriterMethod;
|
||||
import org.x4o.xml.eld.doc.api.ApiDocWriter;
|
||||
import org.x4o.xml.eld.doc.api.DefaultPageWriterHelp;
|
||||
import org.x4o.xml.eld.doc.api.DefaultPageWriterIndexAll;
|
||||
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.ApiDocNodeBody;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||
import org.x4o.xml.element.ElementAttributeHandler;
|
||||
import org.x4o.xml.element.ElementBindingHandler;
|
||||
import org.x4o.xml.element.ElementClass;
|
||||
import org.x4o.xml.element.ElementConfigurator;
|
||||
import org.x4o.xml.element.ElementInterface;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
import org.x4o.xml.element.ElementNamespaceContext;
|
||||
import org.x4o.xml.lang.X4OLanguageModule;
|
||||
import org.x4o.xml.lang.X4OLanguageContext;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* EldDocWriter writes the x4o eld documentation.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 26, 2010
|
||||
*/
|
||||
public class EldDocWriter {
|
||||
|
||||
private X4OLanguageContext context = null;
|
||||
private static final String[] C_CONTEXT = {"language","Overview","All language modules.","The loaded language modules.."};
|
||||
private static final String[] C_MODULE = {"module","Module","The Language Modules.","The language is build by the modules and provides the namespaces."};
|
||||
private static final String[] C_NAMESPACE = {"namespace","Namespace","The Language Namespace.","The language namespace holds all the xml elements."};
|
||||
private static final String[] C_ELEMENT = {"element","Element","The Language Element.","The xml language element description."};
|
||||
|
||||
/**
|
||||
* Creates an EldDocGenerator for this langauge context.
|
||||
* @param context The language context to generate doc for.
|
||||
*/
|
||||
public EldDocWriter(X4OLanguageContext context) {
|
||||
this.context=context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the language documentation to the base path.
|
||||
* @param basePath The path to write to documentation to.
|
||||
* @throws ElementException Is thrown when error is done.
|
||||
*/
|
||||
public void writeDoc(File basePath) throws ElementException {
|
||||
try {
|
||||
ApiDocWriter writer = new ApiDocWriter();
|
||||
ApiDoc doc = buildLanguageDoc();
|
||||
doc.checkModel();
|
||||
writer.write(doc, basePath);
|
||||
} catch (SAXException e) {
|
||||
throw new ElementException(e);
|
||||
} catch (IOException e) {
|
||||
throw new ElementException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private ApiDoc buildLanguageDoc() {
|
||||
ApiDoc doc = new ApiDoc();
|
||||
doc.setName("X4O ELD DOC");
|
||||
doc.setDescription("X4O Meta Language Description");
|
||||
doc.setDocAbout(createLanguageAbout());
|
||||
doc.setDocCopyright(createLanguageCopyright());
|
||||
doc.addDocKeywordAll(createLanguageKeywords());
|
||||
doc.setFrameNavPrintParent(true);
|
||||
doc.setFrameNavPrintParentId(true);
|
||||
|
||||
doc.setFrameNavConceptClass(ElementClass.class);
|
||||
ApiDocNodeWriterBean.addAnnotatedNodeContentWriters(doc,new EldDocWriterLanguage());
|
||||
ApiDocNodeWriterBean.addAnnotatedNodeContentWriters(doc,new EldDocWriterElementClass());
|
||||
ApiDocNodeWriterBean.addAnnotatedNodeContentWriters(doc,this);
|
||||
|
||||
ApiDocConcept adc1 = doc.addConcept(new ApiDocConcept(null,C_CONTEXT,X4OLanguageContext.class));
|
||||
ApiDocConcept adc2 = doc.addConcept(new ApiDocConcept(adc1,C_MODULE,X4OLanguageModule.class,
|
||||
ElementAttributeHandler.class,ElementConfigurator.class,ElementInterface.class,ElementBindingHandler.class));
|
||||
ApiDocConcept adc3 = doc.addConcept(new ApiDocConcept(adc2,C_NAMESPACE,ElementNamespaceContext.class));
|
||||
doc.addConcept(new ApiDocConcept(adc3,C_ELEMENT,ElementClass.class));
|
||||
|
||||
doc.addDocPage(EldDocXTreePageWriter.createDocPage());
|
||||
doc.addDocPage(DefaultPageWriterTree.createDocPage());
|
||||
doc.addDocPage(DefaultPageWriterIndexAll.createDocPage());
|
||||
doc.addDocPage(DefaultPageWriterHelp.createDocPage());
|
||||
|
||||
ApiDocNode rootNode = new ApiDocNode(context,"language","Language","The X4O Language");
|
||||
doc.setRootNode(rootNode);
|
||||
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { ApiDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
|
||||
for (ElementBindingHandler bind:mod.getElementBindingHandlers()) { modNode.addNode(createNodeElementBindingHandler(bind)); }
|
||||
for (ElementAttributeHandler attr:mod.getElementAttributeHandlers()) { modNode.addNode(createNodeElementAttributeHandler(attr)); }
|
||||
for (ElementConfigurator conf:mod.getElementConfiguratorGlobals()) { modNode.addNode(createNodeElementConfigurator(conf)); }
|
||||
for (ElementInterface iface:mod.getElementInterfaces()) { ApiDocNode ifaceNode = modNode.addNode(createNodeElementInterface(iface));
|
||||
for (ElementBindingHandler bind:iface.getElementBindingHandlers()) { ifaceNode.addNode(createNodeElementBindingHandler(bind)); }
|
||||
for (ElementConfigurator conf:iface.getElementConfigurators()) { ifaceNode.addNode(createNodeElementConfigurator(conf)); } }
|
||||
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { ApiDocNode nsNode = modNode.addNode(createNodeElementNamespaceContext(ns));
|
||||
for (ElementClass ec:ns.getElementClasses()) { ApiDocNode ecNode = nsNode.addNode(createNodeElementClass(ec));
|
||||
for (ElementConfigurator conf:ec.getElementConfigurators()) { ecNode.addNode(createNodeElementConfigurator(conf)); } } }
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
private ApiDocNode createNodeElementBindingHandler(ElementBindingHandler bind) {
|
||||
return new ApiDocNode(bind,bind.getId(),bind.getId(),bind.getDescription());
|
||||
}
|
||||
private ApiDocNode createNodeElementAttributeHandler(ElementAttributeHandler attr) {
|
||||
return new ApiDocNode(attr,attr.getId(),attr.getId(),attr.getDescription());
|
||||
}
|
||||
private ApiDocNode createNodeElementConfigurator(ElementConfigurator conf) {
|
||||
return new ApiDocNode(conf,conf.getId(),conf.getId(),conf.getDescription());
|
||||
}
|
||||
private ApiDocNode createNodeLanguageModule(X4OLanguageModule mod) {
|
||||
return new ApiDocNode(mod,mod.getId(),mod.getId(),mod.getDescription());
|
||||
}
|
||||
private ApiDocNode createNodeElementInterface(ElementInterface iface) {
|
||||
return new ApiDocNode(iface,iface.getId(),iface.getId(),iface.getDescription());
|
||||
}
|
||||
private ApiDocNode createNodeElementNamespaceContext(ElementNamespaceContext ns) {
|
||||
return new ApiDocNode(ns,ns.getId(),ns.getUri(),ns.getDescription());
|
||||
}
|
||||
private ApiDocNode createNodeElementClass(ElementClass ec) {
|
||||
return new ApiDocNode(ec,ec.getId(),ec.getId(),ec.getDescription());
|
||||
}
|
||||
|
||||
private String createLanguageAbout() {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
buf.append("XML X4O Language\n");
|
||||
buf.append(context.getLanguage().getLanguageName().toUpperCase());
|
||||
buf.append("™ ");
|
||||
buf.append(context.getLanguage().getLanguageVersion());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private String createLanguageCopyright() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
buf.append("Copyright © ");
|
||||
buf.append(calendar.get(Calendar.YEAR));
|
||||
buf.append(" ");
|
||||
buf.append(context.getLanguage().getLanguageName().toUpperCase());
|
||||
buf.append(" ");
|
||||
buf.append("All Rights Reserved.");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private List<String> createLanguageKeywords() {
|
||||
List<String> keywords = new ArrayList<String>(10);
|
||||
keywords.add(context.getLanguage().getLanguageName());
|
||||
keywords.add("x4o");
|
||||
keywords.add("xml");
|
||||
keywords.add("language");
|
||||
keywords.add("documentation");
|
||||
return keywords;
|
||||
}
|
||||
|
||||
private void printBeanProperties(ApiDocContentWriter writer,Object bean) throws SAXException {
|
||||
writer.docTableStart("Bean Properties", "Bean properties overview.");
|
||||
writer.docTableHeader("Name", "Value");
|
||||
for (Method m:bean.getClass().getMethods()) {
|
||||
if (m.getName().startsWith("get")) {
|
||||
String n = m.getName().substring(3);
|
||||
if (m.getParameterTypes().length!=0) {
|
||||
continue; // set without parameters
|
||||
}
|
||||
if (n.length()<2) {
|
||||
continue;
|
||||
}
|
||||
n = n.substring(0,1).toLowerCase()+n.substring(1,n.length());
|
||||
Object value = null;
|
||||
try {
|
||||
value = m.invoke(bean, new Object[] {});
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
writer.docTableRow(n,printValue(value));
|
||||
}
|
||||
}
|
||||
writer.docTableEnd();
|
||||
}
|
||||
|
||||
private String printValue(Object value) {
|
||||
if (value==null) {
|
||||
return "null";
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String)value;
|
||||
}
|
||||
if (value instanceof Class) {
|
||||
return "class "+((Class<?>)value).getName();
|
||||
}
|
||||
if (value instanceof List) {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
buf.append("[L: ");
|
||||
List<?> l = (List<?>)value;
|
||||
if (l.isEmpty()) {
|
||||
buf.append("Empty");
|
||||
}
|
||||
for (Object o:l) {
|
||||
buf.append(""+o);
|
||||
buf.append(" ");
|
||||
}
|
||||
buf.append("]");
|
||||
return buf.toString();
|
||||
}
|
||||
if (value instanceof Object[]) {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
buf.append("[A: ");
|
||||
Object[] l = (Object[])value;
|
||||
if (l.length==0) {
|
||||
buf.append("Empty");
|
||||
}
|
||||
for (Object o:l) {
|
||||
buf.append(""+o);
|
||||
buf.append(" ");
|
||||
}
|
||||
buf.append("]");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementBindingHandler.class})
|
||||
public void writeElementBindingHandlerBeanProperties(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
printBeanProperties(event.getWriter(),event.getEvent().getUserData());
|
||||
}
|
||||
|
||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementConfigurator.class})
|
||||
public void writeElementConfiguratorBeanProperties(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
printBeanProperties(event.getWriter(),event.getEvent().getUserData());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
/*
|
||||
* 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.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.xml.eld.doc.EldDocXTreePageWriter.TreeNode;
|
||||
import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
|
||||
import org.x4o.xml.eld.doc.api.ApiDocNodeWriterMethod;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||
import org.x4o.xml.element.ElementClass;
|
||||
import org.x4o.xml.element.ElementClassAttribute;
|
||||
import org.x4o.xml.element.ElementNamespaceContext;
|
||||
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||
import org.x4o.xml.lang.X4OLanguageContext;
|
||||
import org.x4o.xml.lang.X4OLanguageModule;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* EldDocWriterElementClass writer all content parts for the ElementClass.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 29, 2013
|
||||
*/
|
||||
public class EldDocWriterElementClass {
|
||||
|
||||
private String printList(List<String> list) {
|
||||
StringBuffer buf = new StringBuffer(40);
|
||||
buf.append("[L: ");
|
||||
if (list.isEmpty()) {
|
||||
buf.append("Empty.");
|
||||
}
|
||||
for (String s:list) {
|
||||
buf.append(s);
|
||||
buf.append(' ');
|
||||
}
|
||||
buf.append("]");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class})
|
||||
public void writeElementX4OSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ApiDocContentWriter writer = event.getWriter();
|
||||
ElementClass ec = (ElementClass)event.getEvent().getUserData();
|
||||
writer.docTableStart("Element X4O Properties", "Element X4O Property Overview");
|
||||
writer.docTableHeader("Name", "Value");
|
||||
writer.docTableRow("id",""+ec.getId());
|
||||
writer.docTableRow("objectClass",""+ec.getObjectClass());
|
||||
writer.docTableRow("elementClass",""+ec.getElementClass());
|
||||
writer.docTableRow("autoAttributes",""+ec.getAutoAttributes());
|
||||
writer.docTableRow("skipPhases",printList(ec.getSkipPhases()));
|
||||
writer.docTableRow("schemaContentBase",""+ec.getSchemaContentBase());
|
||||
writer.docTableRow("schemaContentComplex",""+ec.getSchemaContentComplex());
|
||||
writer.docTableRow("schemaContentMixed",""+ec.getSchemaContentMixed());
|
||||
writer.docTableEnd();
|
||||
}
|
||||
|
||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class})
|
||||
public void writeElementX4OAttributeSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ApiDocContentWriter writer = event.getWriter();
|
||||
ElementClass ec = (ElementClass)event.getEvent().getUserData();
|
||||
writer.docTableStart("Element X4O Attributes", "All Element X4O Attributes Overview");
|
||||
writer.docTableHeader("URI", "Name");
|
||||
for (ElementClassAttribute attr:ec.getElementClassAttributes()) {
|
||||
writer.docTableRow(attr.getId(),attr.getDescription());
|
||||
}
|
||||
writer.docTableEnd();
|
||||
}
|
||||
|
||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class})
|
||||
public void writeElementObjectPropertiesSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ApiDocContentWriter writer = event.getWriter();
|
||||
ElementClass ec = (ElementClass)event.getEvent().getUserData();
|
||||
Class<?> beanClass = ec.getElementClass();
|
||||
if (beanClass==null) {
|
||||
return;
|
||||
}
|
||||
writer.docTableStart("Class Properties", "Bean class properties overview.");
|
||||
writer.docTableHeader("Name", "Value");
|
||||
for (Method m:beanClass.getMethods()) {
|
||||
if (m.getName().startsWith("set")) {
|
||||
String n = m.getName().substring(3);
|
||||
if (m.getParameterTypes().length==0) {
|
||||
continue; // set without parameters
|
||||
}
|
||||
if (n.length()<2) {
|
||||
continue;
|
||||
}
|
||||
n = n.substring(0,1).toLowerCase()+n.substring(1,n.length());
|
||||
Class<?> type = m.getParameterTypes()[0]; // TODO make full list for auto attribute type resolving.
|
||||
writer.docTableRow(n,""+type);
|
||||
}
|
||||
}
|
||||
writer.docTableEnd();
|
||||
}
|
||||
|
||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_LINKS,targetClasses={ElementClass.class})
|
||||
public void writeElementRelationLinks(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ApiDocContentWriter writer = event.getWriter();
|
||||
ElementClass ec = (ElementClass)event.getEvent().getUserData();
|
||||
ElementNamespaceContext ns = (ElementNamespaceContext)event.getEvent().getParent().getUserData();
|
||||
X4OLanguageModule mod = (X4OLanguageModule)event.getEvent().getParent().getParent().getUserData();
|
||||
X4OLanguageContext context = (X4OLanguageContext)event.getEvent().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.module=mod;
|
||||
node.namespace=ns;
|
||||
node.elementClass=ec;
|
||||
|
||||
String pathPrefix = "../../../../language/";
|
||||
|
||||
List<TreeNode> parents = xtree.findParents(node);
|
||||
writer.printTagStart(Tag.dl);
|
||||
writer.printTagCharacters(Tag.dt,"Element Parents:");
|
||||
writer.printTagStart(Tag.dd);
|
||||
if (parents.isEmpty()) {
|
||||
writer.characters("No parent.");
|
||||
}
|
||||
for (int i=0;i<parents.size();i++) {
|
||||
TreeNode n = parents.get(i);
|
||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
||||
if (i<parents.size()-1) {
|
||||
writer.charactersRaw(", ");
|
||||
}
|
||||
}
|
||||
writer.printTagEnd(Tag.dd);
|
||||
writer.printTagEnd(Tag.dl);
|
||||
|
||||
List<TreeNode> childs = xtree.findChilderen(node);
|
||||
writer.printTagStart(Tag.dl);
|
||||
writer.printTagCharacters(Tag.dt,"Element Childeren:");
|
||||
writer.printTagStart(Tag.dd);
|
||||
if (childs.isEmpty()) {
|
||||
writer.characters("No childeren.");
|
||||
}
|
||||
for (int i=0;i<childs.size();i++) {
|
||||
TreeNode n = childs.get(i);
|
||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
||||
if (i<childs.size()-1) {
|
||||
writer.charactersRaw(", ");
|
||||
}
|
||||
}
|
||||
writer.printTagEnd(Tag.dd);
|
||||
writer.printTagEnd(Tag.dl);
|
||||
}
|
||||
|
||||
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespaceContext namespace,ElementClass ec) {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
if (pathPrefix!=null) {
|
||||
buf.append(pathPrefix);
|
||||
}
|
||||
buf.append(ApiDocContentWriter.toSafeUri(mod.getId()));
|
||||
buf.append("/");
|
||||
buf.append(ApiDocContentWriter.toSafeUri(namespace.getId()));
|
||||
buf.append("/");
|
||||
buf.append(ApiDocContentWriter.toSafeUri(ec.getId()));
|
||||
buf.append("/index.html");
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* 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.eld.doc.api.ApiDocContentWriter;
|
||||
import org.x4o.xml.eld.doc.api.ApiDocNodeWriterMethod;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||
import org.x4o.xml.element.ElementNamespaceContext;
|
||||
import org.x4o.xml.lang.X4OLanguageContext;
|
||||
import org.x4o.xml.lang.X4OLanguageModule;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* EldDocWriterLanguage writer all content parts for the x4o language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 29, 2013
|
||||
*/
|
||||
public class EldDocWriterLanguage {
|
||||
|
||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class})
|
||||
public void writeLanguageSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ApiDocContentWriter writer = event.getWriter();
|
||||
ApiDocNode node = event.getEvent();
|
||||
X4OLanguageContext context = (X4OLanguageContext)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()) {
|
||||
attrHandlers += mod.getElementAttributeHandlers().size();
|
||||
bindHandlers += mod.getElementBindingHandlers().size();
|
||||
interFaces += mod.getElementInterfaces().size();
|
||||
eleConfigs += mod.getElementConfiguratorGlobals().size();
|
||||
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||
namespaces++;
|
||||
elements += ns.getElementClasses().size();
|
||||
}
|
||||
}
|
||||
writer.docTableStart("Language Summary", "Language Stats Summary.");
|
||||
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("Namespaces:",""+namespaces,null);
|
||||
writer.docTableRow("Elements:",""+elements,null);
|
||||
writer.docTableRow("ElementInterfaces:",""+interFaces,null);
|
||||
writer.docTableRow("ElementAttributeHandlers:",""+attrHandlers,null);
|
||||
writer.docTableRow("ElementBindingHandlers:",""+bindHandlers,null);
|
||||
writer.docTableRow("ElementConfigurators:",""+eleConfigs,null);
|
||||
writer.docTableEnd();
|
||||
}
|
||||
|
||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class})
|
||||
public void writeModulesSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ApiDocContentWriter writer = event.getWriter();
|
||||
ApiDocNode node = event.getEvent();
|
||||
writer.docTableStart("Modules Summary", "All modules.");
|
||||
writer.docTableHeader("Name", "Description");
|
||||
for (ApiDocNode child:node.getNodes()) {
|
||||
String link = ApiDocContentWriter.toSafeUri(child.getId())+"/index.html";
|
||||
if (node.getParent()==null) {
|
||||
link = ApiDocContentWriter.toSafeUri(node.getId())+"/"+link; // root node
|
||||
}
|
||||
writer.docTableRowHref(link,child.getName(),child.getDescription(),null);
|
||||
}
|
||||
writer.docTableEnd();
|
||||
}
|
||||
|
||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class})
|
||||
public void writeNamespaceSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ApiDocContentWriter writer = event.getWriter();
|
||||
ApiDocNode node = event.getEvent();
|
||||
X4OLanguageContext context = (X4OLanguageContext)node.getUserData();
|
||||
writer.docTableStart("Namespace Summary", "All Language Namespaces Overview");
|
||||
writer.docTableHeader("ID", "URI");
|
||||
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
|
||||
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||
writer.docTableRowHref("language/"+ApiDocContentWriter.toSafeUri(mod.getId())+"/"+ApiDocContentWriter.toSafeUri(ns.getId())+"/index.html",ns.getId(),ns.getUri(),null);
|
||||
}
|
||||
}
|
||||
writer.docTableEnd();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,332 @@
|
|||
/*
|
||||
* 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.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
|
||||
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.ApiDocNode;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||
import org.x4o.xml.element.ElementBindingHandler;
|
||||
import org.x4o.xml.element.ElementClass;
|
||||
import org.x4o.xml.element.ElementInterface;
|
||||
import org.x4o.xml.element.ElementNamespaceContext;
|
||||
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||
import org.x4o.xml.lang.X4OLanguageContext;
|
||||
import org.x4o.xml.lang.X4OLanguageModule;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* EldDocXTreePageWriter for dom overview of tree but as seperate page.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 29, 2013
|
||||
*/
|
||||
public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiDocPageWriter {
|
||||
|
||||
public static ApiDocPage createDocPage() {
|
||||
return new ApiDocPage("overview-xtree","XTree","XTree of dom elements.",new EldDocXTreePageWriter());
|
||||
}
|
||||
|
||||
// TODO: rm this old tree code;
|
||||
private void walkTree(TreeNode node,ApiDocContentWriter writer,String pathPrefix) throws SAXException {
|
||||
String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||
|
||||
writer.printTagStart(Tag.ul);
|
||||
writer.printTagStart(Tag.li,"",null,"circle");
|
||||
writer.characters(node.namespace.getId());
|
||||
writer.characters(":");
|
||||
writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong");
|
||||
writer.printTagEnd(Tag.li);
|
||||
|
||||
List<TreeNode> childs = findChilderen(node);
|
||||
for (TreeNode child:childs) {
|
||||
walkTree(child,writer,pathPrefix);
|
||||
}
|
||||
writer.printTagEnd(Tag.ul);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: remove this
|
||||
* @see org.x4o.xml.eld.doc.api.DefaultPageWriterTree#writePageContent(org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent)
|
||||
*/
|
||||
@Override
|
||||
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
|
||||
//selectRootNode(e.getDoc()); // create
|
||||
ApiDoc doc = e.getDoc();
|
||||
X4OLanguageContext context = (X4OLanguageContext)doc.getRootNode().getUserData();
|
||||
|
||||
String pathPrefix = "language/";
|
||||
|
||||
// temp print old way
|
||||
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
||||
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
|
||||
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
|
||||
// found language root elements.
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
TreeNode node = new TreeNode();
|
||||
node.context=context;
|
||||
node.module=mod;
|
||||
node.namespace=ns;
|
||||
node.elementClass=ec;
|
||||
rootNodes.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(rootNodes,new TreeNodeComparator());
|
||||
for (TreeNode rootNode:rootNodes) {
|
||||
walkTree(rootNode,e.getWriter(),pathPrefix);
|
||||
}
|
||||
}
|
||||
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespaceContext namespace,ElementClass ec) {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
if (pathPrefix!=null) {
|
||||
buf.append(pathPrefix);
|
||||
}
|
||||
buf.append(ApiDocContentWriter.toSafeUri(mod.getId()));
|
||||
buf.append("/");
|
||||
buf.append(ApiDocContentWriter.toSafeUri(namespace.getId()));
|
||||
buf.append("/");
|
||||
buf.append(ApiDocContentWriter.toSafeUri(ec.getId()));
|
||||
buf.append("/index.html");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overrided to select the dom view of the tree.
|
||||
* @see org.x4o.xml.eld.doc.api.DefaultPageWriterTree#selectRootNode(org.x4o.xml.eld.doc.api.dom.ApiDoc)
|
||||
*/
|
||||
@Override
|
||||
protected ApiDocNode selectRootNode(ApiDoc doc) {
|
||||
try {
|
||||
return createXTree(doc);
|
||||
} catch (SAXException e) {
|
||||
throw new IllegalStateException("Could not create XTree for: "+doc.getName()+" error: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
private ApiDocNode createXTree(ApiDoc doc) throws SAXException {
|
||||
|
||||
X4OLanguageContext context = (X4OLanguageContext)doc.getRootNode().getUserData();
|
||||
ApiDocNode root = new ApiDocNode(context,"root","Root","Language root");
|
||||
|
||||
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
||||
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
|
||||
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
|
||||
// found language root elements.
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
TreeNode node = new TreeNode();
|
||||
node.context=context;
|
||||
node.module=mod;
|
||||
node.namespace=ns;
|
||||
node.elementClass=ec;
|
||||
rootNodes.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(rootNodes,new TreeNodeComparator());
|
||||
for (TreeNode rootNode:rootNodes) {
|
||||
walkTree(rootNode,"../");
|
||||
}
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private void walkTree(TreeNode node,String pathPrefix) throws SAXException {
|
||||
//String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||
List<TreeNode> childs = findChilderen(node);
|
||||
for (TreeNode child:childs) {
|
||||
walkTree(child,pathPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TreeNode {
|
||||
X4OLanguageContext context;
|
||||
X4OLanguageModule module;
|
||||
ElementNamespaceContext namespace;
|
||||
ElementClass elementClass;
|
||||
TreeNode parent;
|
||||
int indent = 0;
|
||||
}
|
||||
|
||||
public List<TreeNode> findChilderen(TreeNode node) {
|
||||
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
||||
|
||||
if (node.indent>20) {
|
||||
return result; // hard fail limit
|
||||
}
|
||||
for (X4OLanguageModule mod:node.context.getLanguage().getLanguageModules()) {
|
||||
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||
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.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
} else {
|
||||
if (ec.getObjectClass()==null) {
|
||||
continue;
|
||||
}
|
||||
// Check interfaces of parent , and see if child tag is there.
|
||||
for (ElementInterface ei:node.context.getLanguage().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.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.elementClass.getObjectClass()==null) {
|
||||
continue;
|
||||
}
|
||||
List<ElementBindingHandler> binds = node.context.getLanguage().findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
|
||||
if (binds.isEmpty()==false) {
|
||||
n = new TreeNode();
|
||||
n.context=node.context;
|
||||
n.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
}
|
||||
}
|
||||
if (n!=null && isInTree(node,n)==false) {
|
||||
result.add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(result,new TreeNodeComparator());
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isInTree(TreeNode node,TreeNode checkNode) {
|
||||
|
||||
if ( node.namespace.getUri().equals(checkNode.namespace.getUri()) &&
|
||||
node.elementClass.getId().equals(checkNode.elementClass.getId())
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (node.parent!=null) {
|
||||
return isInTree(node.parent,checkNode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<TreeNode> findParents(TreeNode node) {
|
||||
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
||||
TreeNode n=null;
|
||||
for (X4OLanguageModule mod:node.context.getLanguage().getLanguageModules()) {
|
||||
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
|
||||
|
||||
List<String> tags = node.elementClass.getElementParents(ns.getUri());
|
||||
if (tags!=null) {
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
if (tags.contains(ec.getId())) {
|
||||
n = new TreeNode();
|
||||
n.context=node.context;
|
||||
n.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
result.add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ElementClass ec:ns.getElementClasses()) {
|
||||
|
||||
// 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())) {
|
||||
List<String> eiTags = ei.getElementParents(ns.getUri());
|
||||
if (eiTags!=null && eiTags.contains(ec.getId())) {
|
||||
n = new TreeNode();
|
||||
n.context=node.context;
|
||||
n.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
result.add(n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ec.getObjectClass()==null) {
|
||||
continue;
|
||||
}
|
||||
if (node.elementClass.getObjectClass()==null) {
|
||||
continue;
|
||||
}
|
||||
List<ElementBindingHandler> binds = node.context.getLanguage().findElementBindingHandlers(ec.getObjectClass(),node.elementClass.getObjectClass());
|
||||
if (binds.isEmpty()==false) {
|
||||
n = new TreeNode();
|
||||
n.context=node.context;
|
||||
n.module=mod;
|
||||
n.namespace=ns;
|
||||
n.elementClass=ec;
|
||||
n.indent=node.indent+1;
|
||||
n.parent=node;
|
||||
if (isInTree(node,n)==false) {
|
||||
result.add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(result,new TreeNodeComparator());
|
||||
return result;
|
||||
}
|
||||
|
||||
class TreeNodeComparator implements Comparator<TreeNode> {
|
||||
public int compare(TreeNode o1,TreeNode o2) {
|
||||
return o1.elementClass.getId().compareTo(o2.elementClass.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* 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.X4OLanguageContext;
|
||||
|
||||
/**
|
||||
* 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());
|
||||
X4OLanguageContext context = driver.createLanguageContext(getLanguageVersion());
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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.api;
|
||||
|
||||
/**
|
||||
* ApiDocContentCss defines the css style names used in api docs.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 20, 2013
|
||||
*/
|
||||
public enum ApiDocContentCss {
|
||||
|
||||
indexHeader,
|
||||
indexContainer,
|
||||
|
||||
bar,
|
||||
block,
|
||||
blockList,
|
||||
strong,
|
||||
|
||||
topNav,
|
||||
bottomNav,
|
||||
navList,
|
||||
navBarCell1Rev,
|
||||
subNav,
|
||||
subNavList,
|
||||
|
||||
subTitle,
|
||||
tabEnd,
|
||||
|
||||
aboutLanguage,
|
||||
legalCopy,
|
||||
|
||||
inheritance,
|
||||
header,
|
||||
description,
|
||||
summary,
|
||||
details,
|
||||
docSummary,
|
||||
contentContainer,
|
||||
packageSummary,
|
||||
|
||||
colOne,
|
||||
colFirst,
|
||||
colLast,
|
||||
|
||||
altColor,
|
||||
rowColor,
|
||||
|
||||
// frame names maybe can be used to create frame-less html5 JS version
|
||||
frameNavOverview,
|
||||
frameNavDetail,
|
||||
frameContent
|
||||
}
|
||||
|
|
@ -0,0 +1,506 @@
|
|||
/*
|
||||
* 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.api;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.x4o.xml.io.sax.ext.ContentWriterHtml;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
/**
|
||||
* ContentWriterHtml Writes eld/java documentation in html.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 30, 2013
|
||||
*/
|
||||
public class ApiDocContentWriter extends ContentWriterHtml {
|
||||
|
||||
private boolean isAltRow = true;
|
||||
|
||||
public ApiDocContentWriter(Writer out,String encoding,String charNewLine,String charTab) {
|
||||
super(out,encoding,charNewLine,charTab);
|
||||
}
|
||||
|
||||
public void docCommentGenerated() throws SAXException {
|
||||
comment("Generated by "+ApiDocContentWriter.class.getSimpleName()+" on "+new Date());
|
||||
}
|
||||
|
||||
public void docHtmlStart(NavBarConfig conf,String title,List<String> keywords) throws SAXException {
|
||||
printDocType(DocType.HTML_4_TRANSITIONAL);
|
||||
comment("NewPage");
|
||||
printHtmlStart("en");
|
||||
|
||||
// ====== Write head
|
||||
printTagStart(Tag.head);
|
||||
docCommentGenerated();
|
||||
printHeadMetaContentType();
|
||||
printHeadTitle(title);
|
||||
printHeadMetaDate();
|
||||
for (String keyword:keywords) {
|
||||
printHeadMeta("keywords",keyword);
|
||||
}
|
||||
printHeadLinkCss(conf.pathPrefix+"resources/stylesheet.css");
|
||||
printTagEnd(Tag.head);
|
||||
|
||||
// ======= Write body
|
||||
printTagStart(Tag.body);
|
||||
|
||||
StringBuffer script = new StringBuffer();
|
||||
script.append("\n");
|
||||
script.append("\tif (location.href.indexOf('is-external=true') == -1) {\n");
|
||||
script.append("\t\tparent.document.title=\"");script.append(title);script.append("\";\n");
|
||||
script.append("\t}\n");
|
||||
printScriptInline(script.toString());
|
||||
printScriptNoDiv();
|
||||
|
||||
docNavBar(conf,true);
|
||||
}
|
||||
|
||||
public void docHtmlEnd(NavBarConfig conf,String copyright) throws SAXException {
|
||||
docNavBar(conf,false);
|
||||
printTagStart(Tag.p,ApiDocContentCss.legalCopy);
|
||||
printTagStart(Tag.small);
|
||||
charactersRaw(copyright);
|
||||
printTagEnd(Tag.small);
|
||||
printTagEnd(Tag.p);
|
||||
if (conf.statsJS!=null) {
|
||||
printScriptInline(conf.statsJS);
|
||||
}
|
||||
printTagEnd(Tag.body);
|
||||
printHtmlEnd();
|
||||
}
|
||||
|
||||
class NavBarConfig {
|
||||
String navSelected = null;
|
||||
List<String> navList = new ArrayList<String>(10);
|
||||
Map<String,String> navLinks = new HashMap<String,String>(10);
|
||||
Map<String,String> navNames = new HashMap<String,String>(10);
|
||||
String pathPrefix;
|
||||
String prev;
|
||||
String next;
|
||||
String frame;
|
||||
String aboutLanguage;
|
||||
String statsJS;
|
||||
boolean linkDetails = false;
|
||||
boolean linkFields = false;
|
||||
boolean linkConstructors = false;
|
||||
boolean linkMethods = false;
|
||||
String linkFieldName = "Field";
|
||||
String linkConstructorName = "Constr";
|
||||
String linkMethodName = "Method";
|
||||
String noFrameAllName;
|
||||
String noFrameAllLink;
|
||||
String noFrameAllTopJS =
|
||||
"\nallClassesLink = document.getElementById(\"allclasses_navbar_top\");\n"+
|
||||
"if(window==top) {\n\tallClassesLink.style.display = \"block\";\n} else {\n\tallClassesLink.style.display = \"none\";\n}\n";
|
||||
String noFrameAllBottomJS =
|
||||
"\nallClassesLink = document.getElementById(\"allclasses_navbar_bottom\");\n"+
|
||||
"if(window==top) {\n\tallClassesLink.style.display = \"block\";\n} else {\n\tallClassesLink.style.display = \"none\";\n}\n";
|
||||
|
||||
public NavBarConfig() {}
|
||||
public NavBarConfig(String pathPrefix,String prev,String next,String frame,String aboutLanguage) {
|
||||
this.pathPrefix=pathPrefix;
|
||||
this.prev=prev;
|
||||
this.next=next;
|
||||
this.frame=frame;
|
||||
this.aboutLanguage=aboutLanguage;
|
||||
}
|
||||
public void addNavItem(String id,String navLink,String navName) {
|
||||
navList.add(id);
|
||||
if (navLink!=null) {
|
||||
navLinks.put(id, navLink);
|
||||
}
|
||||
navNames.put(id, navName);
|
||||
}
|
||||
}
|
||||
|
||||
private void docNavBar(NavBarConfig conf,boolean isTop) throws SAXException {
|
||||
String pathPrefix = conf.pathPrefix;
|
||||
String barComment = "TOP";
|
||||
String barCssDiv = "topNav";
|
||||
String barId = "navbar_top";
|
||||
if (isTop==false) {
|
||||
barComment = "BOTTOM";
|
||||
barCssDiv = "bottomNav";
|
||||
barId = "navbar_bottom";
|
||||
}
|
||||
comment("========= START OF "+barComment+" NAVBAR =======");
|
||||
|
||||
printTagStart(Tag.div,barCssDiv);
|
||||
printHrefNamed(barId); // Print named link navigation
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "href", "", "", "#skip-"+barId);
|
||||
atts.addAttribute ("", "title", "", "", "Skip navigation links");
|
||||
startElement("", "a", "", atts);
|
||||
endElement("", "a", "");
|
||||
printHrefNamed(barId+"_firstrow");
|
||||
|
||||
atts = new AttributesImpl();// Print nav bar
|
||||
atts.addAttribute ("", "class", "", "", "navList");
|
||||
atts.addAttribute ("", "title", "", "", "Navigation");
|
||||
startElement("", "ul", "", atts);
|
||||
|
||||
for (String navKey:conf.navList) {
|
||||
String navName = conf.navNames.get(navKey);
|
||||
String navLink = conf.navLinks.get(navKey);
|
||||
String selectedCss = null;
|
||||
if (navKey.equals(conf.navSelected)) {
|
||||
selectedCss = "navBarCell1Rev";
|
||||
navLink = null; // disables link
|
||||
}
|
||||
if (navLink==null) {
|
||||
printTagCharacters(Tag.li, navName, selectedCss);
|
||||
} else {
|
||||
docNavBarListItemHref(pathPrefix+navLink,navName,selectedCss);
|
||||
}
|
||||
}
|
||||
endElement("", "ul", "");
|
||||
|
||||
printTagStart(Tag.div,ApiDocContentCss.aboutLanguage); // Print about language
|
||||
printTagStart(Tag.em);
|
||||
printTagStart(Tag.strong);
|
||||
for (int i=0;i<conf.aboutLanguage.length();i++) {
|
||||
char c = conf.aboutLanguage.charAt(i);
|
||||
if (c=='\n') {
|
||||
printTagStartEnd(Tag.br);
|
||||
} else {
|
||||
characters(c);// TODO: use buffer so char entities are not escaped.
|
||||
}
|
||||
}
|
||||
printTagEnd(Tag.strong);
|
||||
printTagEnd(Tag.em);
|
||||
printTagEnd(Tag.div);
|
||||
printTagEnd(Tag.div); // end barCssDiv
|
||||
|
||||
printTagStart(Tag.div,ApiDocContentCss.subNav);
|
||||
printTagStart(Tag.ul,ApiDocContentCss.navList);
|
||||
if (conf.prev==null) {
|
||||
printTagCharacters(Tag.li, "Prev");
|
||||
} else {
|
||||
docNavBarListItemHref(pathPrefix+conf.prev,"Prev",null,"strong",null);
|
||||
}
|
||||
if (conf.next==null) {
|
||||
printTagCharacters(Tag.li, "Next");
|
||||
} else {
|
||||
docNavBarListItemHref(pathPrefix+conf.next,"Next",null,"strong",null);
|
||||
}
|
||||
printTagEnd(Tag.ul);
|
||||
if (conf.frame!=null) {
|
||||
printTagStart(Tag.ul,ApiDocContentCss.navList);
|
||||
printTagStart(Tag.li);
|
||||
printHrefTarget(pathPrefix+"index.html?"+conf.frame, "Frames", "_top");
|
||||
printTagEnd(Tag.li);
|
||||
printTagStart(Tag.li);
|
||||
printHrefTarget(pathPrefix+conf.frame, "No Frames", "_top");
|
||||
printTagEnd(Tag.li);
|
||||
printTagEnd(Tag.ul);
|
||||
}
|
||||
if (conf.noFrameAllName!=null && conf.noFrameAllLink!=null) {
|
||||
printTagStart(Tag.ul,ApiDocContentCss.navList,"allclasses_"+barId);
|
||||
docNavBarListItemHref(pathPrefix+conf.noFrameAllLink,conf.noFrameAllName,null,null,null);
|
||||
printTagEnd(Tag.ul);
|
||||
printTagStart(Tag.div);
|
||||
if (isTop) {
|
||||
printScriptInline(conf.noFrameAllTopJS);
|
||||
} else {
|
||||
printScriptInline(conf.noFrameAllBottomJS);
|
||||
}
|
||||
printTagEnd(Tag.div);
|
||||
}
|
||||
String tabSpace = " | ";
|
||||
boolean printLink = conf.linkConstructors || conf.linkFields || conf.linkMethods;
|
||||
if (printLink) {
|
||||
printTagStart(Tag.div);
|
||||
printTagStart(Tag.ul,ApiDocContentCss.subNavList);
|
||||
printTagStart(Tag.li);charactersRaw("Summary: ");printTagEnd(Tag.li);
|
||||
//printTagText(Tag.li,"Nested | "); // TODO: Nested
|
||||
if (conf.linkFields) {
|
||||
docNavBarListItemHref("#field_summary",conf.linkFieldName,null,null,tabSpace);
|
||||
} else {
|
||||
printTagCharacters(Tag.li,conf.linkFieldName);charactersRaw(tabSpace);
|
||||
}
|
||||
|
||||
if (conf.linkConstructors) {
|
||||
docNavBarListItemHref("#constructor_summary",conf.linkConstructorName,null,null,tabSpace);
|
||||
} else {
|
||||
printTagCharacters(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace);
|
||||
}
|
||||
if (conf.linkMethods) {
|
||||
docNavBarListItemHref("#method_summary",conf.linkMethodName,null);
|
||||
} else {
|
||||
printTagCharacters(Tag.li,conf.linkMethodName);
|
||||
}
|
||||
printTagEnd(Tag.ul);
|
||||
if (conf.linkDetails){
|
||||
printTagStart(Tag.ul,ApiDocContentCss.subNavList);
|
||||
printTagStart(Tag.li);charactersRaw("Detail: ");printTagEnd(Tag.li);
|
||||
//printTagText(Tag.li,"Nested | ");
|
||||
if (conf.linkFields) {
|
||||
docNavBarListItemHref("#field_detail",conf.linkFieldName,null,null,tabSpace);
|
||||
} else {
|
||||
printTagCharacters(Tag.li,conf.linkFieldName);charactersRaw(tabSpace);
|
||||
}
|
||||
if (conf.linkConstructors) {
|
||||
docNavBarListItemHref("#constructor_detail",conf.linkConstructorName,null,null,tabSpace);
|
||||
} else {
|
||||
printTagCharacters(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace);
|
||||
}
|
||||
if (conf.linkMethods) {
|
||||
docNavBarListItemHref("#method_detail",conf.linkMethodName,null);
|
||||
} else {
|
||||
printTagCharacters(Tag.li,conf.linkMethodName);
|
||||
}
|
||||
printTagEnd(Tag.ul);
|
||||
}
|
||||
printTagEnd(Tag.div);
|
||||
}
|
||||
|
||||
printHrefNamed("skip-"+barId);
|
||||
printTagEnd(Tag.div);
|
||||
comment("========= END OF "+barComment+" NAVBAR =======");
|
||||
}
|
||||
|
||||
private void docNavBarListItemHref(String href,String title,String cssClass) throws SAXException {
|
||||
docNavBarListItemHref(href, title, cssClass, null, null);
|
||||
}
|
||||
private void docNavBarListItemHref(String href,String title,String cssClass,String spanCss,String linkSpace) throws SAXException {
|
||||
printTagStart(Tag.li,cssClass);
|
||||
printHref(href,title,title,spanCss);
|
||||
charactersRaw(linkSpace);
|
||||
printTagEnd(Tag.li);
|
||||
}
|
||||
|
||||
public void docPagePackageTitle(String title,String summary) throws SAXException {
|
||||
printTagStart(Tag.div,ApiDocContentCss.header);
|
||||
printTagCharacters(Tag.h1, title,"title");
|
||||
printTagStart(Tag.div,ApiDocContentCss.docSummary);
|
||||
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
|
||||
printTagEnd(Tag.div);
|
||||
printTagStart(Tag.p);
|
||||
charactersRaw("See: ");
|
||||
printHref("#package_description", "Description");
|
||||
printTagEnd(Tag.p);
|
||||
printTagEnd(Tag.div);
|
||||
}
|
||||
|
||||
public void docPagePackageDescription(String title,String summary,String description) throws SAXException {
|
||||
printHrefNamed("package_description");
|
||||
printTagCharacters(Tag.h2, title);
|
||||
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
|
||||
characters(description);
|
||||
}
|
||||
|
||||
public void docPageClassStart(String title,String subTitle) throws SAXException {
|
||||
comment("======== START OF CLASS DATA ========");
|
||||
printTagStart(Tag.div,ApiDocContentCss.header);
|
||||
if (subTitle!=null) {
|
||||
printTagStart(Tag.div,ApiDocContentCss.subTitle);
|
||||
characters(subTitle);
|
||||
printTagEnd(Tag.div);
|
||||
}
|
||||
printTagCharacters(Tag.h2, title, "title");
|
||||
printTagEnd(Tag.div);
|
||||
}
|
||||
|
||||
public void docPageClassEnd() throws SAXException {
|
||||
comment("======== END OF CLASS DATA ========");
|
||||
}
|
||||
|
||||
public void docPageContentStart() throws SAXException {
|
||||
printTagStart(Tag.div,ApiDocContentCss.contentContainer);
|
||||
}
|
||||
|
||||
public void docPageContentEnd() throws SAXException {
|
||||
printTagEnd(Tag.div);
|
||||
}
|
||||
|
||||
public void docPageBlockStart(String title,String namedLink,String comment) throws SAXException {
|
||||
if (comment!=null) {
|
||||
comment(comment);
|
||||
}
|
||||
docPageBlockStart();
|
||||
printHrefNamed(namedLink);
|
||||
printTagCharacters(Tag.h3, title);
|
||||
}
|
||||
|
||||
public void docPageBlockStart() throws SAXException {
|
||||
printTagStart(Tag.ul,ApiDocContentCss.blockList);
|
||||
printTagStart(Tag.li,ApiDocContentCss.blockList);
|
||||
}
|
||||
|
||||
public void docPageBlockEnd() throws SAXException {
|
||||
printTagEnd(Tag.li);
|
||||
printTagEnd(Tag.ul);
|
||||
}
|
||||
|
||||
public void docPageBlockNext() throws SAXException {
|
||||
printTagEnd(Tag.li);
|
||||
printTagStart(Tag.li,ApiDocContentCss.blockList);
|
||||
}
|
||||
|
||||
public void docTableStart(String tableTitle,String tableDescription) throws SAXException {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "class", "", "", "packageSummary");
|
||||
atts.addAttribute ("", "border", "", "", "0");
|
||||
atts.addAttribute ("", "cellpadding", "", "", "3");
|
||||
atts.addAttribute ("", "cellspacing", "", "", "0");
|
||||
if (tableDescription!=null) {
|
||||
atts.addAttribute ("", "summary", "", "", tableDescription);
|
||||
}
|
||||
startElement("", "table", "", atts);
|
||||
|
||||
printTagStart(Tag.caption);
|
||||
printTagStart(Tag.span);characters(tableTitle);printTagEnd(Tag.span);
|
||||
printTagStart(Tag.span,ApiDocContentCss.tabEnd);charactersRaw(" ");printTagEnd(Tag.span);
|
||||
printTagEnd(Tag.caption);
|
||||
}
|
||||
|
||||
public void docTableEnd() throws SAXException {
|
||||
printTagEnd(Tag.table);
|
||||
isAltRow = true;
|
||||
}
|
||||
|
||||
public void docTableHeader(String titleFirst,String titleLast) throws SAXException {
|
||||
printTagStart(Tag.tr);
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
if (titleLast==null) {
|
||||
atts.addAttribute ("", "class", "", "", "colOne");
|
||||
} else {
|
||||
atts.addAttribute ("", "class", "", "", "colFirst");
|
||||
}
|
||||
atts.addAttribute ("", "scope", "", "", "col");
|
||||
startElement("", "th", "", atts);
|
||||
characters(titleFirst);
|
||||
endElement("", "th", "");
|
||||
if (titleLast==null) {
|
||||
printTagEnd(Tag.tr);
|
||||
return;
|
||||
}
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "class", "", "", "colLast");
|
||||
atts.addAttribute ("", "scope", "", "", "col");
|
||||
startElement("", "th", "", atts);
|
||||
characters(titleLast);
|
||||
printTagEnd(Tag.th);
|
||||
printTagEnd(Tag.tr);
|
||||
}
|
||||
|
||||
public void docTableRow(String dataFirst,String dataLast) throws SAXException {
|
||||
docTableRow(dataFirst,dataLast,null);
|
||||
}
|
||||
|
||||
public void docTableRow(String dataFirst,String dataLast,String dataBlock) throws SAXException {
|
||||
docTableRowHref(null,dataFirst,dataLast,dataBlock);
|
||||
}
|
||||
|
||||
public void docTableRowHref(String dataFirstHref,String dataFirst,String dataLast,String dataBlock) throws SAXException {
|
||||
if (isAltRow) {
|
||||
printTagStart(Tag.tr,ApiDocContentCss.altColor);
|
||||
} else {
|
||||
printTagStart(Tag.tr,ApiDocContentCss.rowColor);
|
||||
}
|
||||
isAltRow = !isAltRow;
|
||||
if (dataLast==null) {
|
||||
printTagStart(Tag.td,ApiDocContentCss.colOne);
|
||||
} else {
|
||||
printTagStart(Tag.td,ApiDocContentCss.colFirst);
|
||||
}
|
||||
printTagStart(Tag.code);
|
||||
if (dataFirstHref==null) {
|
||||
characters(dataFirst);
|
||||
} else {
|
||||
printHref(dataFirstHref, dataFirst, dataFirst);
|
||||
}
|
||||
printTagEnd(Tag.code);
|
||||
printTagEnd(Tag.td);
|
||||
|
||||
if (dataLast==null) {
|
||||
printTagEnd(Tag.tr);
|
||||
return;
|
||||
}
|
||||
|
||||
printTagStart(Tag.td,ApiDocContentCss.colLast);
|
||||
printTagStart(Tag.code);characters(dataLast);printTagEnd(Tag.code);
|
||||
if (dataBlock!=null) {
|
||||
printTagStart(Tag.div,ApiDocContentCss.block);characters(dataBlock);printTagEnd(Tag.div);
|
||||
}
|
||||
printTagEnd(Tag.td);
|
||||
|
||||
printTagEnd(Tag.tr);
|
||||
}
|
||||
|
||||
|
||||
static public String toSafeUri(List<String> paths) {
|
||||
return toSafeUri(paths.toArray(new String[]{}));
|
||||
}
|
||||
|
||||
static public String toSafeUri(String...paths) {
|
||||
StringBuffer result = new StringBuffer(100);
|
||||
for (int i=0;i<paths.length;i++) {
|
||||
String path=paths[i];
|
||||
result.append(toSafeUri(path));
|
||||
if (i<(paths.length-1)) {
|
||||
result.append('/');
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
static public String toSafeUri(String uri) {
|
||||
StringBuilder buf = new StringBuilder(20);
|
||||
for (char c:uri.toLowerCase().toCharArray()) {
|
||||
if (Character.isLetter(c)) {
|
||||
buf.append(c);
|
||||
}
|
||||
if (Character.isDigit(c)) {
|
||||
buf.append(c);
|
||||
}
|
||||
if ('.'==c) {
|
||||
buf.append(c);
|
||||
}
|
||||
if ('-'==c) {
|
||||
buf.append(c);
|
||||
}
|
||||
if ('_'==c) {
|
||||
buf.append(c);
|
||||
}
|
||||
}
|
||||
String prefix = buf.toString();
|
||||
if (prefix.startsWith("http")) {
|
||||
prefix = prefix.substring(4);
|
||||
}
|
||||
if (prefix.startsWith("uri")) {
|
||||
prefix = prefix.substring(3);
|
||||
}
|
||||
if (prefix.startsWith("url")) {
|
||||
prefix = prefix.substring(3);
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
* 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.api;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeWriter;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* ApiDocNodeWriterBean wraps the ApiDocNodeWriterEvent to a single method of a bean.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 1, 2013
|
||||
*/
|
||||
public class ApiDocNodeWriterBean implements ApiDocNodeWriter {
|
||||
|
||||
private ApiDocNodeBody nodeBody = null;
|
||||
private Integer nodeBodyOrder = null;
|
||||
private Object bean = null;
|
||||
private String method = null;
|
||||
private List<Class<?>> targetClasses = null;
|
||||
private String contentGroup = null;
|
||||
private String contentGroupType = null;
|
||||
|
||||
public ApiDocNodeWriterBean() {
|
||||
targetClasses = new ArrayList<Class<?>>(5);
|
||||
}
|
||||
|
||||
public ApiDocNodeWriterBean(ApiDocNodeBody nodeBody,Object bean,String method,Class<?>...classes) {
|
||||
this();
|
||||
this.nodeBody=nodeBody;
|
||||
this.bean=bean;
|
||||
this.method=method;
|
||||
if (classes!=null && classes.length>0) {
|
||||
targetClasses.addAll(Arrays.asList(classes));
|
||||
}
|
||||
}
|
||||
|
||||
public static void addAnnotatedNodeContentWriters(ApiDoc doc,Object bean) {
|
||||
if (doc==null) {
|
||||
throw new NullPointerException("Can't add to null ApiDoc.");
|
||||
}
|
||||
if (bean==null) {
|
||||
throw new NullPointerException("Can't scan null bean.");
|
||||
}
|
||||
for (Method method:bean.getClass().getMethods()) {
|
||||
ApiDocNodeWriterMethod ammo = method.getAnnotation(ApiDocNodeWriterMethod.class);
|
||||
if (ammo==null) {
|
||||
continue;
|
||||
}
|
||||
ApiDocNodeWriterBean methodWriter = new ApiDocNodeWriterBean(ammo.nodeBody(), bean, method.getName(), ammo.targetClasses());
|
||||
if (ammo.nodeBodyOrder()!=-1) {
|
||||
methodWriter.setNodeBodyOrder(ammo.nodeBodyOrder());
|
||||
}
|
||||
if (!ammo.contentGroup().isEmpty()) {
|
||||
methodWriter.setContentGroup(ammo.contentGroup());
|
||||
}
|
||||
if (!ammo.contentGroupType().isEmpty()) {
|
||||
methodWriter.setContentGroupType(ammo.contentGroupType());
|
||||
}
|
||||
doc.addNodeBodyWriter(methodWriter);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeNodeContent(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
Class<?> beanClass = bean.getClass();
|
||||
try {
|
||||
Method methodBean = beanClass.getMethod(method, new Class[]{ApiDocWriteEvent.class});
|
||||
methodBean.invoke(bean, new Object[]{event});
|
||||
} catch (Exception e) {
|
||||
throw new SAXException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void addtargetClass(Class<?> targetClass) {
|
||||
targetClasses.add(targetClass);
|
||||
}
|
||||
|
||||
public void removetargetClass(Class<?> targetClass) {
|
||||
targetClasses.remove(targetClasses);
|
||||
}
|
||||
|
||||
public List<Class<?>> getTargetClasses() {
|
||||
return targetClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nodeBody
|
||||
*/
|
||||
public ApiDocNodeBody getNodeBody() {
|
||||
return nodeBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeBody the nodeBody to set
|
||||
*/
|
||||
public void setNodeBody(ApiDocNodeBody nodeBody) {
|
||||
this.nodeBody = nodeBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bean
|
||||
*/
|
||||
public Object getBean() {
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bean the bean to set
|
||||
*/
|
||||
public void setBean(Object bean) {
|
||||
this.bean = bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the method
|
||||
*/
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param method the method to set
|
||||
*/
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nodeBodyOrder
|
||||
*/
|
||||
public Integer getNodeBodyOrder() {
|
||||
return nodeBodyOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeBodyOrder the nodeBodyOrder to set
|
||||
*/
|
||||
public void setNodeBodyOrder(Integer nodeBodyOrder) {
|
||||
this.nodeBodyOrder = nodeBodyOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the contentGroup
|
||||
*/
|
||||
public String getContentGroup() {
|
||||
return contentGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentGroup the contentGroup to set
|
||||
*/
|
||||
public void setContentGroup(String contentGroup) {
|
||||
this.contentGroup = contentGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the contentGroupType
|
||||
*/
|
||||
public String getContentGroupType() {
|
||||
return contentGroupType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentGroupType the contentGroupType to set
|
||||
*/
|
||||
public void setContentGroupType(String contentGroupType) {
|
||||
this.contentGroupType = contentGroupType;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net 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.api;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
|
||||
|
||||
/**
|
||||
* ApiDocNodeBodyWriterMethod wraps api doc file writer events to a method.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 19, 2013
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
public @interface ApiDocNodeWriterMethod {
|
||||
|
||||
Class<?>[] targetClasses();
|
||||
|
||||
ApiDocNodeBody nodeBody();
|
||||
|
||||
int nodeBodyOrder() default -1;
|
||||
|
||||
String contentGroup() default "";
|
||||
|
||||
String contentGroupType() default "";
|
||||
}
|
||||
|
|
@ -0,0 +1,810 @@
|
|||
/*
|
||||
* 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.api;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.xml.eld.doc.api.ApiDocContentWriter.NavBarConfig;
|
||||
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.ApiDocNodeBody;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocNodeWriter;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||
import org.x4o.xml.io.XMLConstants;
|
||||
import org.x4o.xml.io.sax.ext.ContentWriterHtml.DocType;
|
||||
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
/**
|
||||
* ApiDocWriter creates all output files for the ApiDoc.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 1, 2013
|
||||
*/
|
||||
public class ApiDocWriter {
|
||||
|
||||
private ApiDoc doc = null;
|
||||
private File basePath = null;
|
||||
|
||||
/**
|
||||
* Writes full api doc tree files to the base path.
|
||||
* @param doc The ApiDoc to writer.
|
||||
* @param basePath The bath path to write into.
|
||||
* @throws IOException When file exception happens.
|
||||
* @throws SAXException when xml exception happens.
|
||||
*/
|
||||
public void write(ApiDoc doc,File basePath) throws IOException,SAXException {
|
||||
if (doc==null) {
|
||||
throw new NullPointerException("Can't write with null ApiDoc.");
|
||||
}
|
||||
if (basePath==null) {
|
||||
throw new NullPointerException("Can't write with null basePath.");
|
||||
}
|
||||
this.doc=doc;
|
||||
this.basePath=basePath;
|
||||
|
||||
// Write root and resource files
|
||||
writeStyleSheet();
|
||||
writeIndex();
|
||||
writeOverviewFrame();
|
||||
writeAllFrameNav(true);
|
||||
writeAllFrameNav(false);
|
||||
|
||||
// Write pages
|
||||
for (ApiDocPage page:doc.getDocPages()) {
|
||||
writePage(page);
|
||||
}
|
||||
|
||||
// Write api doc tree
|
||||
writeNode(doc.getRootNode());
|
||||
}
|
||||
|
||||
private void writeNode(ApiDocNode node) throws SAXException {
|
||||
ApiDocConcept concept = findConceptByClass(node.getUserData().getClass());
|
||||
if (concept==null) {
|
||||
//System.out.println("----- no concept found for: "+node.getId()+" data: "+node.getUserData());
|
||||
return;
|
||||
}
|
||||
List<String> path = new ArrayList<String>(10);
|
||||
buildParentPath(node,path);
|
||||
if (path.size()==1) {
|
||||
path.remove(path.size()-1);
|
||||
path.add("overview-"+node.getId()+".html");
|
||||
} else {
|
||||
path.add("index.html");
|
||||
}
|
||||
String pathPrefix = "";
|
||||
for (int i=1;i<path.size();i++) {
|
||||
pathPrefix += "../";
|
||||
}
|
||||
File outputFile = createOutputPathFile(basePath,path.toArray(new String[]{}));
|
||||
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||
NavBarConfig config = createNavBarConfig(pathPrefix, outputFile, writer);
|
||||
|
||||
config.navSelected=concept.getId();
|
||||
configActiveNavConceptLinks(config,node,concept,"/..");
|
||||
configNextPrevLinks(config,node);
|
||||
|
||||
ApiDocWriteEvent<ApiDocNode> bodyEvent = new ApiDocWriteEvent<ApiDocNode>(doc,writer,node);
|
||||
String title = node.getId();
|
||||
String titleSub = null;
|
||||
if (node.getParent()!=null) {
|
||||
titleSub = node.getParent().getId()+":"+node.getId();
|
||||
}
|
||||
|
||||
// Write node file
|
||||
writer.docHtmlStart(config,title, doc.getDocKeywords());
|
||||
writer.docPageClassStart(title, titleSub);
|
||||
writer.docPageContentStart();
|
||||
writeNodeTreePath(bodyEvent);
|
||||
writeNodeDescription(bodyEvent);
|
||||
writeNodeSummary(bodyEvent);
|
||||
writeNodeDetails(bodyEvent);
|
||||
writer.docPageContentEnd();
|
||||
writer.docPageClassEnd();
|
||||
writer.docHtmlEnd(config,doc.getDocCopyright());
|
||||
writer.closeWriterSafe();
|
||||
|
||||
// Writer other files
|
||||
writeAllFrameNavNode(node);
|
||||
for (ApiDocNode child:node.getNodes()) {
|
||||
writeNode(child);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeNodeTreePath(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
List<ApiDocNodeWriter> bodyWriterTreePath = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.TREE_PATH);
|
||||
if (bodyWriterTreePath.isEmpty()) {
|
||||
defaultWriteTreePath(event.getEvent(),event.getWriter());
|
||||
}
|
||||
for (int i=0;i<bodyWriterTreePath.size();i++) {
|
||||
ApiDocNodeWriter nodeWriter = bodyWriterTreePath.get(i);
|
||||
nodeWriter.writeNodeContent(event);
|
||||
}
|
||||
}
|
||||
|
||||
private void defaultWriteNodeDescription(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
event.getWriter().characters(event.getEvent().getDescription());
|
||||
}
|
||||
|
||||
private void writeNodeDescription(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ApiDocContentWriter writer = event.getWriter();
|
||||
List<ApiDocNodeWriter> bodyWriterDescriptionLinks = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.DESCRIPTION_LINKS);
|
||||
List<ApiDocNodeWriter> bodyWriterDescriptionNode = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.DESCRIPTION_NODE);
|
||||
writer.printTagStart(Tag.div, ApiDocContentCss.description);
|
||||
writer.docPageBlockStart();
|
||||
if (bodyWriterDescriptionLinks.isEmpty()) {
|
||||
//defaultWriteTreePath(node,writer);
|
||||
}
|
||||
for (int i=0;i<bodyWriterDescriptionLinks.size();i++) {
|
||||
ApiDocNodeWriter nodeWriter = bodyWriterDescriptionLinks.get(i);
|
||||
nodeWriter.writeNodeContent(event);
|
||||
}
|
||||
writer.printTagStartEnd(Tag.hr);
|
||||
writer.printTagStartEnd(Tag.br); // mmm
|
||||
if (bodyWriterDescriptionNode.isEmpty()) {
|
||||
defaultWriteNodeDescription(event);
|
||||
}
|
||||
for (int i=0;i<bodyWriterDescriptionNode.size();i++) {
|
||||
ApiDocNodeWriter nodeWriter = bodyWriterDescriptionNode.get(i);
|
||||
nodeWriter.writeNodeContent(event);
|
||||
}
|
||||
writer.docPageBlockEnd();
|
||||
writer.printTagEnd(Tag.div); // description
|
||||
}
|
||||
|
||||
private void writeNodeSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ApiDocContentWriter writer = event.getWriter();
|
||||
List<ApiDocNodeWriter> bodyWriterSummary = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.SUMMARY);
|
||||
writer.printTagStart(Tag.div, ApiDocContentCss.summary);
|
||||
writer.docPageBlockStart();
|
||||
if (bodyWriterSummary.isEmpty()) {
|
||||
writer.docPageBlockStart();
|
||||
defaultWriteSummary(event.getEvent(),writer);
|
||||
writer.docPageBlockEnd();
|
||||
}
|
||||
for (int i=0;i<bodyWriterSummary.size();i++) {
|
||||
writer.docPageBlockStart();
|
||||
writer.printTagCharacters(Tag.h3, "Summary");
|
||||
ApiDocNodeWriter nodeWriter = bodyWriterSummary.get(i);
|
||||
nodeWriter.writeNodeContent(event);
|
||||
writer.docPageBlockEnd();
|
||||
}
|
||||
writer.docPageBlockEnd();
|
||||
writer.printTagEnd(Tag.div); // Summary
|
||||
}
|
||||
|
||||
private void writeNodeDetails(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||
ApiDocContentWriter writer = event.getWriter();
|
||||
List<ApiDocNodeWriter> bodyWriterDetail = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.DETAIL);
|
||||
if (bodyWriterDetail.isEmpty()) {
|
||||
return;// no default ..
|
||||
}
|
||||
writer.printTagStart(Tag.div, ApiDocContentCss.details);
|
||||
writer.docPageBlockStart();
|
||||
//if (bodyWriterDetail.isEmpty()) {
|
||||
// writer.docPageBlockStart();
|
||||
// defaultWriteDetailNode(node,writer);
|
||||
// writer.docPageBlockEnd();
|
||||
//}
|
||||
for (int i=0;i<bodyWriterDetail.size();i++) {
|
||||
writer.docPageBlockStart();
|
||||
writer.printTagCharacters(Tag.h3, "Detail");
|
||||
ApiDocNodeWriter nodeWriter = bodyWriterDetail.get(i);
|
||||
nodeWriter.writeNodeContent(event);
|
||||
writer.docPageBlockEnd();
|
||||
}
|
||||
writer.docPageBlockEnd();
|
||||
writer.printTagEnd(Tag.div); // details
|
||||
|
||||
}
|
||||
|
||||
private void configActiveNavConceptLinks(NavBarConfig conf,ApiDocNode node,ApiDocConcept concept,String prefix) {
|
||||
List<String> pathClean = new ArrayList<String>(10);
|
||||
buildParentPath(node,pathClean);
|
||||
|
||||
if (concept.getParent()!=null && !concept.getParent().getId().equals(doc.getRootNode().getId())) {
|
||||
ApiDocConcept conceptParent = concept.getParent();
|
||||
conf.navLinks.put(conceptParent.getId(), ApiDocContentWriter.toSafeUri(pathClean)+prefix+"/index.html");
|
||||
configActiveNavConceptLinks(conf,node,concept.getParent(),prefix+"/..");
|
||||
}
|
||||
}
|
||||
private void configNextPrevLinks(NavBarConfig conf,ApiDocNode node) {
|
||||
if (node.getParent()==null) {
|
||||
return;
|
||||
}
|
||||
List<ApiDocNode> pn = node.getParent().getNodes();
|
||||
int pnSize = pn.size();
|
||||
int nodeIdx = pn.indexOf(node);
|
||||
if (nodeIdx>0) {
|
||||
List<String> pathClean = new ArrayList<String>(10);
|
||||
ApiDocNode prevNode = pn.get(nodeIdx-1);
|
||||
if (node.getUserData().getClass().equals(prevNode.getUserData().getClass())) {
|
||||
buildParentPath(prevNode,pathClean);
|
||||
conf.prev = ApiDocContentWriter.toSafeUri(pathClean)+"/index.html";
|
||||
}
|
||||
}
|
||||
if ((nodeIdx+1)<pnSize) {
|
||||
List<String> pathClean = new ArrayList<String>(10);
|
||||
ApiDocNode nextNode = pn.get(nodeIdx+1);
|
||||
if (node.getUserData().getClass().equals(nextNode.getUserData().getClass())) {
|
||||
buildParentPath(nextNode,pathClean);
|
||||
conf.next = ApiDocContentWriter.toSafeUri(pathClean)+"/index.html";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void defaultWriteSummary(ApiDocNode node,ApiDocContentWriter writer) throws SAXException {
|
||||
ApiDocConcept concept = findConceptByClass(node.getUserData().getClass());
|
||||
writer.docTableStart(concept.getName()+" Summary", "All childeren in "+concept.getName());
|
||||
writer.docTableHeader("Name", "Description");
|
||||
for (ApiDocNode child:node.getNodes()) {
|
||||
String link = ApiDocContentWriter.toSafeUri(child.getId())+"/index.html";
|
||||
if (node.getParent()==null) {
|
||||
link = ApiDocContentWriter.toSafeUri(node.getId())+"/"+link; // root node
|
||||
}
|
||||
writer.docTableRowHref(link,child.getName(),child.getDescription(),null);
|
||||
}
|
||||
writer.docTableEnd();
|
||||
}
|
||||
|
||||
public void defaultWriteTreePath(ApiDocNode node,ApiDocContentWriter writer) throws SAXException {
|
||||
if (node.getParent()==null) {
|
||||
return; // no tree for root
|
||||
}
|
||||
List<ApiDocNode> rootPath = new ArrayList<ApiDocNode>(8);
|
||||
defaultWriteTreePathBuildPath(node,rootPath);
|
||||
defaultWriteTreePathWalker(rootPath.iterator(),writer,rootPath.size());
|
||||
}
|
||||
|
||||
private void defaultWriteTreePathWalker(Iterator<ApiDocNode> nodes,ApiDocContentWriter writer,int linkPrefixCount) throws SAXException {
|
||||
if (nodes.hasNext()==false) {
|
||||
return;
|
||||
}
|
||||
ApiDocNode node = nodes.next();
|
||||
writer.printTagStart(Tag.ul, ApiDocContentCss.inheritance);
|
||||
String nodeTitle = node.getId();
|
||||
if (nodes.hasNext()==false) {
|
||||
writer.printTagStart(Tag.li);
|
||||
writer.characters(nodeTitle);
|
||||
writer.printTagEnd(Tag.li);
|
||||
} else {
|
||||
writer.printTagStart(Tag.li);
|
||||
StringBuffer buf = new StringBuffer(20);
|
||||
for (int i=1;i<linkPrefixCount;i++) {
|
||||
buf.append("../");
|
||||
}
|
||||
String linkHref = buf+"index.html";
|
||||
if (doc.getRootNode().equals(node)) {
|
||||
ApiDocConcept concept = findConceptByClass(node.getUserData().getClass());
|
||||
linkHref = buf+"../overview-"+concept.getId()+".html";
|
||||
}
|
||||
writer.printHref(linkHref, node.getDescription(), nodeTitle);
|
||||
writer.printTagEnd(Tag.li);
|
||||
|
||||
writer.printTagStart(Tag.li);
|
||||
defaultWriteTreePathWalker(nodes,writer,(linkPrefixCount-1));
|
||||
writer.printTagEnd(Tag.li);
|
||||
}
|
||||
writer.printTagEnd(Tag.ul);
|
||||
}
|
||||
|
||||
private void defaultWriteTreePathBuildPath(ApiDocNode node,List<ApiDocNode> result) {
|
||||
if (node.getParent()!=null) {
|
||||
defaultWriteTreePathBuildPath(node.getParent(),result);
|
||||
}
|
||||
result.add(node);
|
||||
}
|
||||
|
||||
private ApiDocContentWriter createContentWriter(File outputFile) throws SAXException {
|
||||
String encoding = XMLConstants.XML_DEFAULT_ENCODING;
|
||||
try {
|
||||
Writer out = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||
String charNewLine = XMLConstants.CHAR_NEWLINE+"";
|
||||
String charTab = " ";
|
||||
ApiDocContentWriter result = new ApiDocContentWriter(out,encoding,charNewLine,charTab);
|
||||
return result;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new SAXException(e);
|
||||
} catch (SecurityException e) {
|
||||
throw new SAXException(e);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new SAXException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected NavBarConfig createNavBarConfig(String pathPrefix,File frame,ApiDocContentWriter writer) throws SAXException {
|
||||
return createNavBarConfig(pathPrefix, null, null, frame, writer);
|
||||
}
|
||||
|
||||
protected NavBarConfig createNavBarConfig(String pathPrefix,String prev,String next,File frame,ApiDocContentWriter writer) throws SAXException {
|
||||
String framePath = null;
|
||||
try {
|
||||
String rootPath = new File(frame.getParentFile().getPath()+File.separatorChar+pathPrefix).getCanonicalPath();
|
||||
framePath = frame.getPath().substring(rootPath.length()+1);
|
||||
} catch (IOException e) {
|
||||
throw new SAXException(e);
|
||||
}
|
||||
NavBarConfig conf = writer.new NavBarConfig(pathPrefix,prev,next,framePath,doc.getDocAbout());
|
||||
conf.noFrameAllLink="allelements-noframe.html";
|
||||
conf.noFrameAllName="All Elements";
|
||||
conf.linkConstructorName="Tag";
|
||||
conf.linkFieldName="Attributes";
|
||||
conf.linkMethodName="Config";
|
||||
|
||||
for (ApiDocConcept concept:doc.getConcepts()) {
|
||||
String navLink = "overview-"+concept.getId()+".html";
|
||||
if (concept.getParent()!=null) {
|
||||
navLink = null;
|
||||
}
|
||||
conf.addNavItem(concept.getId(), navLink, concept.getName());
|
||||
}
|
||||
for (ApiDocPage page:doc.getDocPages()) {
|
||||
String navLink = page.getId()+".html";
|
||||
conf.addNavItem(page.getId(), navLink, page.getName());
|
||||
}
|
||||
return conf;
|
||||
}
|
||||
|
||||
private List<ApiDocNodeWriter> findNodeBodyWriters(ApiDocNode node,ApiDocNodeBody nodeBody) {
|
||||
List<ApiDocNodeWriter> result = new ArrayList<ApiDocNodeWriter>();
|
||||
Class<?> objClass = node.getUserData().getClass();
|
||||
for (ApiDocNodeWriter writer:doc.getNodeBodyWriters()) {
|
||||
if (!nodeBody.equals(writer.getNodeBody())) {
|
||||
continue;
|
||||
}
|
||||
for (Class<?> c:writer.getTargetClasses()) {
|
||||
if (c.isAssignableFrom(objClass)) {
|
||||
result.add(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private ApiDocConcept findConceptByClass(Class<?> objClass) {
|
||||
for (ApiDocConcept concept:doc.getConcepts()) {
|
||||
if (concept.getConceptClass().isAssignableFrom(objClass)) {
|
||||
return concept;
|
||||
}
|
||||
for (Class<?> c:concept.getConceptChildClasses()) {
|
||||
if (c.isAssignableFrom(objClass)) {
|
||||
return concept;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void buildParentPath(ApiDocNode node,List<String> path) {
|
||||
if (node.getParent()==null) {
|
||||
path.add(node.getId());
|
||||
return;
|
||||
}
|
||||
buildParentPath(node.getParent(),path);
|
||||
path.add(node.getId());
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
//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");
|
||||
} catch (SecurityException e) {
|
||||
throw new IOException(e.getMessage());
|
||||
} catch (InterruptedException e) {
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void writeHeader(ApiDocContentWriter writer,String resourcePrefix,String title) throws SAXException {
|
||||
writer.printTagStart(Tag.head);
|
||||
writer.docCommentGenerated();
|
||||
writer.printHeadMetaContentType();
|
||||
writer.printHeadTitle(title);
|
||||
writer.printHeadMetaDate();
|
||||
writer.printHeadLinkCss(resourcePrefix+"resources/stylesheet.css");
|
||||
writer.printTagEnd(Tag.head);
|
||||
}
|
||||
|
||||
private static final String FRAME_JS = "\n"+
|
||||
"targetPage = \"\" + window.location.search;\n"+
|
||||
"if (targetPage != \"\" && targetPage != \"undefined\")\n"+
|
||||
"\t { targetPage = targetPage.substring(1); }\n"+
|
||||
"if (targetPage.indexOf(\":\") != -1)\n"+
|
||||
"\t { targetPage = \"undefined\"; }\n"+
|
||||
"function loadFrames() {\n"+
|
||||
"\tif (targetPage != \"\" && targetPage != \"undefined\")\n"+
|
||||
"\t\t { top."+ApiDocContentCss.frameContent.name()+".location = top.targetPage; }\n"+
|
||||
"}\n";
|
||||
|
||||
public void writeIndex() throws SAXException {
|
||||
File outputFile = createOutputPathFile(basePath,"index.html");
|
||||
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||
try {
|
||||
writer.printDocType(DocType.HTML_4_FRAMESET);
|
||||
writer.comment("NewPage");
|
||||
writer.printHtmlStart("en");
|
||||
writeHeader(writer,"",doc.getName());
|
||||
writer.printScriptInline(FRAME_JS);
|
||||
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "cols", "", "", "20%,80%");
|
||||
atts.addAttribute ("", "title", "", "", "Documentation frame");
|
||||
atts.addAttribute ("", "onload", "", "", "top.loadFrames()");
|
||||
writer.printTagStart(Tag.frameset, atts);
|
||||
|
||||
ApiDocConcept rootConcept = findConceptByClass(doc.getFrameNavConceptClass());
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "rows", "", "", "30%,70%");
|
||||
atts.addAttribute ("", "title", "", "", "Left frames");
|
||||
atts.addAttribute ("", "onload", "", "", "top.loadFrames()");
|
||||
writer.printTagStart(Tag.frameset, atts);
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "src", "", "", "overview-frame.html");
|
||||
atts.addAttribute ("", "title", "", "", "All Namspaces");
|
||||
atts.addAttribute ("", "name", "", "", ApiDocContentCss.frameNavOverview.name());
|
||||
writer.printTagStart(Tag.frame, atts);
|
||||
writer.printTagEnd(Tag.frame);
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "src", "", "", "all"+rootConcept.getId()+"-frame.html");
|
||||
atts.addAttribute ("", "title", "", "", "All Elements");
|
||||
atts.addAttribute ("", "name", "", "", ApiDocContentCss.frameNavDetail.name());
|
||||
writer.printTagStart(Tag.frame, atts);
|
||||
writer.printTagEnd(Tag.frame);
|
||||
writer.printTagEnd(Tag.frameset);
|
||||
|
||||
String rootLink = "overview-"+ApiDocContentWriter.toSafeUri(doc.getRootNode().getId())+".html";
|
||||
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "src", "", "", rootLink);
|
||||
atts.addAttribute ("", "title", "", "", "All Language Components");
|
||||
atts.addAttribute ("", "name", "", "", ApiDocContentCss.frameContent.name());
|
||||
atts.addAttribute ("", "scrolling", "", "", "yes");
|
||||
writer.printTagStart(Tag.frame, atts);
|
||||
writer.printTagEnd(Tag.frame);
|
||||
|
||||
writer.printTagStart(Tag.noframes);
|
||||
writer.printScriptNoDiv();
|
||||
writer.printTagCharacters(Tag.h2, "Frame Alert");
|
||||
writer.printTagStart(Tag.p);
|
||||
writer.characters("This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to ");
|
||||
writer.printHref(rootLink, "Non-frame version");
|
||||
writer.characters(".");
|
||||
writer.printTagEnd(Tag.p);
|
||||
writer.printTagEnd(Tag.noframes);
|
||||
|
||||
writer.printTagEnd(Tag.frameset);
|
||||
writer.printHtmlEnd();
|
||||
} finally {
|
||||
writer.closeWriterSafe();
|
||||
}
|
||||
}
|
||||
|
||||
private void findNodeByUserDataClass(ApiDocNode node,Class<?> userDataClass,List<ApiDocNode> result) {
|
||||
if (userDataClass.isAssignableFrom(node.getUserData().getClass())) {
|
||||
result.add(node);
|
||||
}
|
||||
for (ApiDocNode child:node.getNodes()) {
|
||||
findNodeByUserDataClass((ApiDocNode)child,userDataClass,result);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeOverviewFrame() throws SAXException {
|
||||
ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
|
||||
ApiDocConcept conceptParent = concept.getParent();
|
||||
List<ApiDocNode> nodes = new ArrayList<ApiDocNode>(50);
|
||||
findNodeByUserDataClass(doc.getRootNode(),conceptParent.getConceptClass(),nodes);
|
||||
|
||||
File outputFile = createOutputPathFile(basePath,"overview-frame.html");
|
||||
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||
try {
|
||||
String conceptPlural = concept.getName()+"s";
|
||||
String conceptParentPlural = conceptParent.getName()+"s";
|
||||
|
||||
writer.printDocType(DocType.HTML_4_TRANSITIONAL);
|
||||
writer.comment("NewPage");
|
||||
writer.printHtmlStart("en");
|
||||
writeHeader(writer,"","All "+conceptPlural+" of "+doc.getName());
|
||||
writer.printTagStart(Tag.body);
|
||||
|
||||
writer.printTagStart(Tag.div,ApiDocContentCss.indexHeader);
|
||||
writer.printHrefTarget("all"+concept.getId()+"-frame.html", "All "+conceptPlural,ApiDocContentCss.frameNavDetail.name());
|
||||
writer.printTagEnd(Tag.div);
|
||||
|
||||
writer.printTagStart(Tag.div,ApiDocContentCss.indexContainer);
|
||||
writer.printTagCharacters(Tag.h2, conceptParentPlural);
|
||||
writer.printTagStart(Tag.ul);
|
||||
for (ApiDocNode node:nodes) {
|
||||
String linkName = node.getName();
|
||||
if (doc.getFrameNavOverviewPrintParent()) {
|
||||
if (doc.getFrameNavPrintParentId()) {
|
||||
linkName = node.getParent().getId()+":"+node.getName();
|
||||
} else {
|
||||
linkName = node.getParent().getName()+":"+node.getName();
|
||||
}
|
||||
}
|
||||
writer.printTagStart(Tag.li);
|
||||
writer.printHrefTarget(doc.getRootNode().getId()+"/"+ApiDocContentWriter.toSafeUri(node.getParent().getId())+"/"+node.getId()+"/"+node.getId()+"-frame.html", linkName,ApiDocContentCss.frameNavDetail.name());
|
||||
writer.printTagEnd(Tag.li);
|
||||
}
|
||||
writer.printTagEnd(Tag.ul);
|
||||
writer.printTagEnd(Tag.div);
|
||||
|
||||
writer.printTagEnd(Tag.body);
|
||||
writer.printHtmlEnd();
|
||||
} finally {
|
||||
writer.closeWriterSafe();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeAllFrameNav(boolean isFrame) throws SAXException {
|
||||
ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
|
||||
if (isFrame) {
|
||||
writeAllFrameNav("",true,null,"all"+concept.getId()+"-frame.html");
|
||||
} else {
|
||||
writeAllFrameNav("",false,null,"all"+concept.getId()+"-noframe.html");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeAllFrameNavNode(ApiDocNode node) throws SAXException {
|
||||
ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
|
||||
ApiDocConcept conceptParent = concept.getParent();
|
||||
if (!conceptParent.getConceptClass().isAssignableFrom(node.getUserData().getClass())) {
|
||||
return; // only frame nav nodes.
|
||||
}
|
||||
List<String> path = new ArrayList<String>(10);
|
||||
buildParentPath(node,path);
|
||||
String pathS = "";
|
||||
for (int i=0;i<path.size();i++) {
|
||||
pathS = "../"+pathS;
|
||||
}
|
||||
path.add(node.getId()+"-frame.html");
|
||||
writeAllFrameNav(pathS,true,node,path.toArray(new String[]{}));
|
||||
}
|
||||
|
||||
private void writeAllFrameNav(String pathPrefix,boolean isFrame,ApiDocNode searchNode,String...fileName) throws SAXException {
|
||||
ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
|
||||
//ApiDocConcept conceptParent = concept.getParent();
|
||||
List<ApiDocNode> nodes = new ArrayList<ApiDocNode>(50);
|
||||
findNodeByUserDataClass(doc.getRootNode(),concept.getConceptClass(),nodes);
|
||||
|
||||
File outputFile = createOutputPathFile(basePath,fileName);
|
||||
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||
try {
|
||||
String conceptPlural = concept.getName()+"s";
|
||||
//String conceptParentPlural = conceptParent.getName()+"s";
|
||||
|
||||
writer.printDocType(DocType.HTML_4_TRANSITIONAL);
|
||||
writer.comment("NewPage");
|
||||
writer.printHtmlStart("en");
|
||||
writeHeader(writer,pathPrefix,"All "+conceptPlural+" of "+doc.getName());
|
||||
writer.printTagStart(Tag.body);
|
||||
if (searchNode==null) {
|
||||
writer.printTagCharacters(Tag.h1, "All "+conceptPlural, "bar");
|
||||
} else {
|
||||
writer.printTagStart(Tag.h1,ApiDocContentCss.bar);
|
||||
writer.printHrefTarget("index.html", searchNode.getId(),ApiDocContentCss.frameContent.name());
|
||||
writer.printTagEnd(Tag.h1);
|
||||
}
|
||||
|
||||
writer.printTagStart(Tag.div,ApiDocContentCss.indexContainer);
|
||||
writer.printTagStart(Tag.ul);
|
||||
|
||||
boolean printParent = new Boolean(true).equals(doc.getFrameNavPrintParent());
|
||||
boolean printParentParent = new Boolean(true).equals(doc.getFrameNavPrintParentParent());
|
||||
|
||||
for (ApiDocNode node:nodes) {
|
||||
List<String> nodePath = new ArrayList<String>(10);
|
||||
buildParentPath(node,nodePath);
|
||||
if (searchNode!=null) {
|
||||
// TODO: compare full tree paths.
|
||||
if (!node.getParent().getId().equals(searchNode.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (searchNode.getParent()!=null && !node.getParent().getParent().getId().equals(searchNode.getParent().getId())) {
|
||||
continue;
|
||||
}
|
||||
if (searchNode.getParent().getParent()!=null && !node.getParent().getParent().getParent().getId().equals(searchNode.getParent().getParent().getId())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
String linkName = node.getName();
|
||||
String linkUrl = ApiDocContentWriter.toSafeUri(nodePath)+"/index.html";
|
||||
if (searchNode!=null) {
|
||||
linkUrl = ApiDocContentWriter.toSafeUri(node.getId(),"index.html");
|
||||
}
|
||||
if (printParent) {
|
||||
if (printParentParent) {
|
||||
if (doc.getFrameNavPrintParentId()) {
|
||||
linkName = node.getParent().getParent().getId()+":"+linkName;
|
||||
} else {
|
||||
linkName = node.getParent().getParent().getName()+":"+linkName;
|
||||
}
|
||||
} else {
|
||||
if (doc.getFrameNavPrintParentId()) {
|
||||
linkName = node.getParent().getId()+":"+linkName;
|
||||
} else {
|
||||
linkName = node.getParent().getName()+":"+linkName;
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.printTagStart(Tag.li);
|
||||
if (isFrame) {
|
||||
writer.printHrefTarget(linkUrl, linkName,ApiDocContentCss.frameContent.name());
|
||||
} else {
|
||||
writer.printHref(linkUrl, linkName);
|
||||
}
|
||||
writer.printTagEnd(Tag.li);
|
||||
}
|
||||
|
||||
writer.printTagEnd(Tag.ul);
|
||||
writer.printTagEnd(Tag.div);
|
||||
|
||||
writer.printTagEnd(Tag.body);
|
||||
writer.printHtmlEnd();
|
||||
} finally {
|
||||
writer.closeWriterSafe();
|
||||
}
|
||||
}
|
||||
|
||||
private void writePage(ApiDocPage page) throws SAXException {
|
||||
File outputFile = createOutputPathFile(basePath,page.getId()+".html");
|
||||
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||
String pathPrefix = "";
|
||||
try {
|
||||
NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, writer);
|
||||
conf.navSelected=page.getId();
|
||||
String title = page.getName();
|
||||
writer.docHtmlStart(conf,title, doc.getDocKeywords());
|
||||
writer.docPageClassStart(title, page.getDescription());
|
||||
|
||||
ApiDocWriteEvent<ApiDocPage> e = new ApiDocWriteEvent<ApiDocPage>(doc,writer,page);
|
||||
|
||||
//writer.docPageContentStart();
|
||||
for (ApiDocPageWriter pageWriter:page.getPageWriters()) {
|
||||
pageWriter.writePageContent(e);
|
||||
}
|
||||
//writer.docPageContentEnd();
|
||||
|
||||
writer.docPageClassEnd();
|
||||
writer.docHtmlEnd(conf, doc.getDocCopyright());
|
||||
} finally {
|
||||
writer.closeWriterSafe();
|
||||
}
|
||||
}
|
||||
|
||||
private void appendResourceToBuffer(StringBuffer buffer,String resource) throws IOException {
|
||||
ClassLoader cl = X4OLanguageClassLoader.getClassLoader();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
InputStream inputStream = cl.getResourceAsStream(resource);
|
||||
reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
for (int c = reader.read(); c != -1; c = reader.read()) {
|
||||
buffer.append((char)c);
|
||||
}
|
||||
} finally {
|
||||
if (reader!=null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFileString(String text,File basePath,String...argu) throws SecurityException, IOException, InterruptedException {
|
||||
OutputStream outputStream = new FileOutputStream(createOutputPathFile(basePath,argu));
|
||||
try {
|
||||
for (int i=0;i<text.length();i++) {
|
||||
char c = text.charAt(i);
|
||||
outputStream.write(c);
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void copyResourceToFile(String resource,File basePath,String...argu) throws SecurityException, IOException, InterruptedException {
|
||||
ClassLoader cl = X4OLanguageClassLoader.getClassLoader();
|
||||
InputStream inputStream = cl.getResourceAsStream(resource);
|
||||
OutputStream outputStream = new FileOutputStream(createOutputPathFile(basePath,argu));
|
||||
try {
|
||||
byte[] buffer = new byte[4096];
|
||||
int len = inputStream.read(buffer);
|
||||
while (len != -1) {
|
||||
outputStream.write(buffer, 0, len);
|
||||
len = inputStream.read(buffer);
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
inputStream.close();
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
private File createOutputPathFile(File basePath,String...argu) {
|
||||
StringBuffer buf = new StringBuffer(200);
|
||||
buf.append(basePath.getAbsolutePath());
|
||||
buf.append(File.separatorChar);
|
||||
for (int i=0;i<argu.length-1;i++) {
|
||||
buf.append(ApiDocContentWriter.toSafeUri(argu[i]));
|
||||
buf.append(File.separatorChar);
|
||||
}
|
||||
File outputPath = new File(buf.toString());
|
||||
if (outputPath.exists()==false) {
|
||||
//System.out.println("Creating path: "+outputPath);
|
||||
outputPath.mkdirs();
|
||||
}
|
||||
buf.append(File.separatorChar);
|
||||
buf.append(ApiDocContentWriter.toSafeUri(argu[argu.length-1]));
|
||||
File outputFile = new File(buf.toString());
|
||||
if (outputFile.exists()) {
|
||||
outputFile.delete();
|
||||
}
|
||||
//System.out.println("Creating file: "+outputFile);
|
||||
return outputFile;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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.api;
|
||||
|
||||
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.ApiDocPage;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* DefaultPageWriterHelp creates the help page content.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 22, 2013
|
||||
*/
|
||||
public class DefaultPageWriterHelp implements ApiDocPageWriter {
|
||||
|
||||
public static ApiDocPage createDocPage() {
|
||||
return new ApiDocPage("doc-help","Help","This help file applies to the API documentation generated using the standard format.",new DefaultPageWriterHelp());
|
||||
}
|
||||
|
||||
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
|
||||
ApiDoc doc = e.getDoc();
|
||||
//ApiDocPage page = e.getEvent();
|
||||
ApiDocContentWriter writer = e.getWriter();
|
||||
|
||||
writer.printTagStart(Tag.div,"header");
|
||||
writer.printTagCharacters(Tag.h1, "How This API Document Is Organized", "title");
|
||||
writer.printTagStart(Tag.div,"subTitle");
|
||||
writer.characters("This ApiDoc document has pages corresponding to the items in the navigation bar, described as follows.");
|
||||
writer.printTagEnd(Tag.div);
|
||||
writer.printTagEnd(Tag.div);
|
||||
|
||||
writer.docPageContentStart();
|
||||
writer.docPageBlockStart();
|
||||
for (ApiDocConcept concept:doc.getConcepts()) {
|
||||
writer.printTagCharacters(Tag.h2, concept.getName());
|
||||
writer.printTagStart(Tag.p);
|
||||
writer.charactersRaw(concept.getDescriptionHelp());
|
||||
writer.printTagEnd(Tag.p);
|
||||
writer.docPageBlockNext();
|
||||
}
|
||||
for (ApiDocPage docPage:doc.getDocPages()) {
|
||||
writer.printTagCharacters(Tag.h2, docPage.getName());
|
||||
writer.printTagStart(Tag.p);
|
||||
writer.charactersRaw(docPage.getDescription());
|
||||
writer.printTagEnd(Tag.p);
|
||||
writer.docPageBlockNext();
|
||||
}
|
||||
writer.docPageBlockEnd();
|
||||
writer.docPageContentEnd();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* 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.api;
|
||||
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* DefaultPageWriterIndexAll creates the index-all page content.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 22, 2013
|
||||
*/
|
||||
public class DefaultPageWriterIndexAll implements ApiDocPageWriter {
|
||||
|
||||
public static ApiDocPage createDocPage() {
|
||||
return new ApiDocPage("index-all","Index","Index of all api ketwords.",new DefaultPageWriterIndexAll());
|
||||
}
|
||||
|
||||
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
|
||||
// ApiDoc doc = e.getDoc();
|
||||
// ApiDocPage page = e.getEvent();
|
||||
ApiDocContentWriter writer = e.getWriter();
|
||||
writer.docPageContentStart();
|
||||
for (char i='A';i<='Z';i++) {
|
||||
writer.printHref("#_"+i+"_", ""+i);
|
||||
writer.charactersRaw(" ");
|
||||
}
|
||||
for (char i='A';i<='Z';i++) {
|
||||
writer.printHrefNamed("_"+i+"_");
|
||||
writer.printTagCharacters(Tag.h2, ""+i);
|
||||
writer.characters("TODO");
|
||||
}
|
||||
writer.docPageContentEnd();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* 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.api;
|
||||
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||
import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
|
||||
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* DefaultPageWriterTree creates the default tree overview page content.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 22, 2013
|
||||
*/
|
||||
public class DefaultPageWriterTree implements ApiDocPageWriter {
|
||||
|
||||
public static ApiDocPage createDocPage() {
|
||||
return new ApiDocPage("overview-tree","Tree","Tree of api concepts.",new DefaultPageWriterTree());
|
||||
}
|
||||
|
||||
protected ApiDocNode selectRootNode(ApiDoc doc) {
|
||||
ApiDocNode rootNode = doc.getRootNodeTreePage();
|
||||
if (rootNode==null) {
|
||||
rootNode = doc.getRootNode();
|
||||
}
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
|
||||
ApiDoc doc = e.getDoc();
|
||||
ApiDocPage page = e.getEvent();
|
||||
ApiDocContentWriter writer = e.getWriter();
|
||||
//writer.docPagePackageTitle(title, "Overview Tree");
|
||||
writer.docPageContentStart();
|
||||
writeTree(doc,selectRootNode(doc),writer,"");
|
||||
writer.docPagePackageDescription(page.getName(), "Tree","All Language elements as tree.");
|
||||
writer.docPageContentEnd();
|
||||
}
|
||||
|
||||
private void writeTree(ApiDoc doc, ApiDocNode node,ApiDocContentWriter writer,String pathPrefix) throws SAXException {
|
||||
|
||||
for (Class<?> excludeClass:doc.getTreeNodeClassExcludes()) {
|
||||
if (excludeClass.isAssignableFrom(node.getUserData().getClass())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String href = ApiDocContentWriter.toSafeUri("todo");// toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||
|
||||
writer.printTagStart(Tag.ul);
|
||||
writer.printTagStart(Tag.li,"",null,"circle");
|
||||
if (node.getParent()!=null) {
|
||||
writer.characters(node.getParent().getId());
|
||||
writer.characters(":");
|
||||
}
|
||||
writer.printHref(href, node.getName(), node.getName(), "strong");
|
||||
writer.printTagEnd(Tag.li);
|
||||
|
||||
for (ApiDocNode child:node.getNodes()) {
|
||||
writeTree(doc,child,writer,pathPrefix);
|
||||
}
|
||||
writer.printTagEnd(Tag.ul);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,350 @@
|
|||
/*
|
||||
* 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.api.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ApiDoc holds all config and data to write a full api doc structure.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2013
|
||||
*/
|
||||
public class ApiDoc {
|
||||
|
||||
private String name = null;
|
||||
private String description = null;
|
||||
private ApiDocNode rootNode = null;
|
||||
private ApiDocNode rootNodeTreePage = null;
|
||||
private List<ApiDocNodeWriter> nodeBodyWriters = null;
|
||||
private List<ApiDocConcept> concepts = null;
|
||||
private String docCopyright = null;
|
||||
private String docAbout = null;
|
||||
private List<String> docKeywords = null;
|
||||
private List<ApiDocPage> docPages = null;
|
||||
private Class<?> frameNavConceptClass = null;
|
||||
private Boolean frameNavOverviewPrintParent = null;
|
||||
private Boolean frameNavPrintParentId = null;
|
||||
private Boolean frameNavPrintParent = null;
|
||||
private Boolean frameNavPrintParentParent = null;
|
||||
private List<Class<?>> treeNodeClassExcludes = null;
|
||||
|
||||
public ApiDoc() {
|
||||
nodeBodyWriters = new ArrayList<ApiDocNodeWriter>(20);
|
||||
concepts = new ArrayList<ApiDocConcept>(10);
|
||||
docKeywords = new ArrayList<String>(5);
|
||||
docPages = new ArrayList<ApiDocPage>(5);
|
||||
treeNodeClassExcludes = new ArrayList<Class<?>>(5);
|
||||
}
|
||||
|
||||
public ApiDoc(ApiDocNode rootNode) {
|
||||
this();
|
||||
setRootNode(rootNode);
|
||||
}
|
||||
|
||||
public void checkModel() throws NullPointerException,IllegalArgumentException {
|
||||
checkNull(name,"name");
|
||||
checkNull(description,"description");
|
||||
checkNull(docAbout,"docAbout");
|
||||
checkNull(docCopyright,"docCopyright");
|
||||
checkNull(rootNode,"rootNode");
|
||||
checkNull(frameNavConceptClass,"frameNavConceptClass");
|
||||
if (concepts.isEmpty()) {
|
||||
throw new IllegalStateException("Can't work with empty concepts");
|
||||
}
|
||||
if (nodeBodyWriters.isEmpty()) {
|
||||
throw new IllegalStateException("Can't work with empty nodeBodyWriters");
|
||||
}
|
||||
if (frameNavOverviewPrintParent==null) {
|
||||
frameNavOverviewPrintParent=false;
|
||||
}
|
||||
if (frameNavPrintParent==null) {
|
||||
frameNavPrintParent=false;
|
||||
}
|
||||
if (frameNavPrintParentParent==null) {
|
||||
frameNavPrintParentParent=false;
|
||||
}
|
||||
if (frameNavPrintParentId==null) {
|
||||
frameNavPrintParentId=false;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNull(Object obj,String objName) {
|
||||
if (obj==null) {
|
||||
throw new NullPointerException("Can't work with null "+objName);
|
||||
}
|
||||
}
|
||||
|
||||
public ApiDocNodeWriter addNodeBodyWriter(ApiDocNodeWriter writer) {
|
||||
nodeBodyWriters.add(writer);
|
||||
return writer;
|
||||
}
|
||||
|
||||
public boolean removeNodeBodyWriter(ApiDocNodeWriter writer) {
|
||||
return nodeBodyWriters.remove(writer);
|
||||
}
|
||||
|
||||
public List<ApiDocNodeWriter> getNodeBodyWriters() {
|
||||
return nodeBodyWriters;
|
||||
}
|
||||
|
||||
public ApiDocConcept addConcept(ApiDocConcept concept) {
|
||||
concepts.add(concept);
|
||||
return concept;
|
||||
}
|
||||
|
||||
public boolean removeConcept(ApiDocConcept concept) {
|
||||
return concepts.remove(concept);
|
||||
}
|
||||
|
||||
public List<ApiDocConcept> getConcepts() {
|
||||
return concepts;
|
||||
}
|
||||
|
||||
public void addDocKeyword(String keyword) {
|
||||
docKeywords.add(keyword);
|
||||
}
|
||||
|
||||
public void addDocKeywordAll(Collection<String> keywords) {
|
||||
docKeywords.addAll(keywords);
|
||||
}
|
||||
|
||||
public boolean removeDocKeyword(String keyword) {
|
||||
return docKeywords.remove(keyword);
|
||||
}
|
||||
|
||||
public List<String> getDocKeywords() {
|
||||
return docKeywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the docCopyright
|
||||
*/
|
||||
public String getDocCopyright() {
|
||||
return docCopyright;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param docCopyright the docCopyright to set
|
||||
*/
|
||||
public void setDocCopyright(String docCopyright) {
|
||||
this.docCopyright = docCopyright;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates default copyright message for owner.
|
||||
* @param owner The owner of the copyright.
|
||||
*/
|
||||
public void createDocCopyright(String owner) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
buf.append("Copyright © ");
|
||||
buf.append(calendar.get(Calendar.YEAR));
|
||||
buf.append(" ");
|
||||
buf.append(owner.toUpperCase());
|
||||
buf.append(" ");
|
||||
buf.append("All Rights Reserved.");
|
||||
setDocCopyright(buf.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the docAbout
|
||||
*/
|
||||
public String getDocAbout() {
|
||||
return docAbout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param docAbout the docAbout to set
|
||||
*/
|
||||
public void setDocAbout(String docAbout) {
|
||||
this.docAbout = docAbout;
|
||||
}
|
||||
|
||||
public ApiDocPage addDocPage(ApiDocPage page) {
|
||||
docPages.add(page);
|
||||
return page;
|
||||
}
|
||||
|
||||
public boolean removeDocPage(ApiDocPage page) {
|
||||
return docPages.remove(page);
|
||||
}
|
||||
|
||||
public List<ApiDocPage> getDocPages() {
|
||||
return docPages;
|
||||
}
|
||||
|
||||
public ApiDocPage findDocPageById(String docPageId) {
|
||||
if (docPageId==null) {
|
||||
throw new NullPointerException("Can't search for null id.");
|
||||
}
|
||||
for (ApiDocPage page:docPages) {
|
||||
if (page.getId().equals(docPageId)) {
|
||||
return page;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Class<?> addTreeNodeClassExclude(Class<?> excludeClass) {
|
||||
treeNodeClassExcludes.add(excludeClass);
|
||||
return excludeClass;
|
||||
}
|
||||
|
||||
public boolean removeTreeNodeClassExclude(Class<?> excludeClass) {
|
||||
return treeNodeClassExcludes.remove(excludeClass);
|
||||
}
|
||||
|
||||
public List<Class<?>> getTreeNodeClassExcludes() {
|
||||
return treeNodeClassExcludes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rootNodeTreePage
|
||||
*/
|
||||
public ApiDocNode getRootNodeTreePage() {
|
||||
return rootNodeTreePage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rootNodeTreePage the rootNodeTreePage to set
|
||||
*/
|
||||
public void setRootNodeTreePage(ApiDocNode rootNodeTreePage) {
|
||||
this.rootNodeTreePage = rootNodeTreePage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rootNode
|
||||
*/
|
||||
public ApiDocNode getRootNode() {
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rootNode the rootNode to set
|
||||
*/
|
||||
public void setRootNode(ApiDocNode rootNode) {
|
||||
this.rootNode = rootNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the frameNavConceptClass
|
||||
*/
|
||||
public Class<?> getFrameNavConceptClass() {
|
||||
return frameNavConceptClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param frameNavConceptClass the frameNavConceptClass to set
|
||||
*/
|
||||
public void setFrameNavConceptClass(Class<?> frameNavConceptClass) {
|
||||
this.frameNavConceptClass = frameNavConceptClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the frameNavPrintParent
|
||||
*/
|
||||
public Boolean getFrameNavPrintParent() {
|
||||
return frameNavPrintParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param frameNavPrintParent the frameNavPrintParent to set
|
||||
*/
|
||||
public void setFrameNavPrintParent(Boolean frameNavPrintParent) {
|
||||
this.frameNavPrintParent = frameNavPrintParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the frameNavPrintParentParent
|
||||
*/
|
||||
public Boolean getFrameNavPrintParentParent() {
|
||||
return frameNavPrintParentParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param frameNavPrintParentParent the frameNavPrintParentParent to set
|
||||
*/
|
||||
public void setFrameNavPrintParentParent(Boolean frameNavPrintParentParent) {
|
||||
this.frameNavPrintParentParent = frameNavPrintParentParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the frameNavOverviewPrintParent
|
||||
*/
|
||||
public Boolean getFrameNavOverviewPrintParent() {
|
||||
return frameNavOverviewPrintParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param frameNavOverviewPrintParent the frameNavOverviewPrintParent to set
|
||||
*/
|
||||
public void setFrameNavOverviewPrintParent(Boolean frameNavOverviewPrintParent) {
|
||||
this.frameNavOverviewPrintParent = frameNavOverviewPrintParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the frameNavPrintParentId
|
||||
*/
|
||||
public Boolean getFrameNavPrintParentId() {
|
||||
return frameNavPrintParentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param frameNavPrintParentId the frameNavPrintParentId to set
|
||||
*/
|
||||
public void setFrameNavPrintParentId(Boolean frameNavPrintParentId) {
|
||||
this.frameNavPrintParentId = frameNavPrintParentId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* 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.api.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ApiDocConcept defines the prime concepts which for which we write documents.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2013
|
||||
*/
|
||||
public class ApiDocConcept {
|
||||
|
||||
private String id = null;
|
||||
private String name = null;
|
||||
private String descriptionName = null;
|
||||
private String descriptionHelp = null;
|
||||
private ApiDocConcept parent = null;
|
||||
private Class<?> conceptClass = null;
|
||||
private List<Class<?>> conceptChildClasses = null;
|
||||
|
||||
public ApiDocConcept() {
|
||||
conceptChildClasses = new ArrayList<Class<?>>(5);
|
||||
}
|
||||
|
||||
public ApiDocConcept(ApiDocConcept parent,String id,Class<?> conceptClass) {
|
||||
this();
|
||||
setId(id);
|
||||
setConceptClass(conceptClass);
|
||||
setParent(parent);
|
||||
}
|
||||
|
||||
public ApiDocConcept(ApiDocConcept parent,String[] text,Class<?> conceptClass,Class<?>...classes) {
|
||||
this(parent,text[0],text[1],text[2],text[3],conceptClass,classes);
|
||||
}
|
||||
|
||||
public ApiDocConcept(ApiDocConcept parent,String id,String name,String descriptionName,String descriptionHelp,Class<?> conceptClass,Class<?>...classes) {
|
||||
this(parent,id,conceptClass);
|
||||
setName(name);
|
||||
setDescriptionName(descriptionName);
|
||||
setDescriptionHelp(descriptionHelp);
|
||||
for (Class<?> cl:classes) {
|
||||
addConceptChildClass(cl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the descriptionName
|
||||
*/
|
||||
public String getDescriptionName() {
|
||||
return descriptionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param descriptionName the descriptionName to set
|
||||
*/
|
||||
public void setDescriptionName(String descriptionName) {
|
||||
this.descriptionName = descriptionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the descriptionHelp
|
||||
*/
|
||||
public String getDescriptionHelp() {
|
||||
return descriptionHelp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param descriptionHelp the descriptionHelp to set
|
||||
*/
|
||||
public void setDescriptionHelp(String descriptionHelp) {
|
||||
this.descriptionHelp = descriptionHelp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the conceptClass
|
||||
*/
|
||||
public Class<?> getConceptClass() {
|
||||
return conceptClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param conceptClass the conceptClass to set
|
||||
*/
|
||||
public void setConceptClass(Class<?> conceptClass) {
|
||||
this.conceptClass = conceptClass;
|
||||
}
|
||||
|
||||
public void addConceptChildClass(Class<?> targetClass) {
|
||||
conceptChildClasses.add(targetClass);
|
||||
}
|
||||
|
||||
public void removeConceptChildClass(Class<?> targetClass) {
|
||||
conceptChildClasses.remove(conceptChildClasses);
|
||||
}
|
||||
|
||||
public List<Class<?>> getConceptChildClasses() {
|
||||
return conceptChildClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parent
|
||||
*/
|
||||
public ApiDocConcept getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent the parent to set
|
||||
*/
|
||||
public void setParent(ApiDocConcept parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* 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.api.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* ApiDocNode defines the concept impl data tree nodes for which we write documents.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2013
|
||||
*/
|
||||
public class ApiDocNode {
|
||||
|
||||
private Object userData = null;
|
||||
private String id = null;
|
||||
private String name = null;
|
||||
private String description = null;
|
||||
private ApiDocNode parent = null;
|
||||
private List<ApiDocNode> nodes = null;
|
||||
private Map<String,String> contentGroupTypes = null;
|
||||
|
||||
public ApiDocNode() {
|
||||
nodes = new ArrayList<ApiDocNode>(30);
|
||||
contentGroupTypes = new HashMap<String,String>(3);
|
||||
}
|
||||
|
||||
public ApiDocNode(Object userData,String id,String name,String description) {
|
||||
this();
|
||||
setUserData(userData);
|
||||
setId(id);
|
||||
setName(name);
|
||||
if (description==null) {
|
||||
description = name;
|
||||
}
|
||||
setDescription(description);
|
||||
}
|
||||
|
||||
public ApiDocNode addNode(ApiDocNode node) {
|
||||
node.setParent(this);
|
||||
nodes.add(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
public boolean removeNode(ApiDocNode node) {
|
||||
return nodes.remove(node);
|
||||
}
|
||||
|
||||
public List<ApiDocNode> getNodes() {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public void addContentGroupType(String id,String name) {
|
||||
contentGroupTypes.put(id, name);
|
||||
}
|
||||
|
||||
public void removeContentGroupType(String id) {
|
||||
contentGroupTypes.remove(id);
|
||||
}
|
||||
|
||||
public String getContentGroupTypeName(String id) {
|
||||
return contentGroupTypes.get(id);
|
||||
}
|
||||
|
||||
public Set<String> getContentGroupTypeKeys() {
|
||||
return contentGroupTypes.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userData
|
||||
*/
|
||||
public Object getUserData() {
|
||||
return userData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userData the userData to set
|
||||
*/
|
||||
public void setUserData(Object userData) {
|
||||
this.userData = userData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parent
|
||||
*/
|
||||
public ApiDocNode getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent the parent to set
|
||||
*/
|
||||
public void setParent(ApiDocNode parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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.api.dom;
|
||||
|
||||
/**
|
||||
* ApiDocNodeBody are the parts from which the content body is created.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2013
|
||||
*/
|
||||
public enum ApiDocNodeBody {
|
||||
|
||||
TREE_PATH,
|
||||
DESCRIPTION_LINKS,
|
||||
DESCRIPTION_NODE,
|
||||
SUMMARY,
|
||||
DETAIL
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.api.dom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* ApiDocNodeWriter are the parts from which the content body is created.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2013
|
||||
*/
|
||||
public interface ApiDocNodeWriter {
|
||||
|
||||
ApiDocNodeBody getNodeBody();
|
||||
List<Class<?>> getTargetClasses();
|
||||
|
||||
void writeNodeContent(ApiDocWriteEvent<ApiDocNode> e) throws SAXException;
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* 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.api.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ApiDocPage defines seperate pages for the documentation.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2013
|
||||
*/
|
||||
public class ApiDocPage {
|
||||
|
||||
private String id = null;
|
||||
private String name = null;
|
||||
private String description = null;
|
||||
private List<ApiDocPageWriter> pageWriters = null;
|
||||
|
||||
public ApiDocPage() {
|
||||
pageWriters = new ArrayList<ApiDocPageWriter>(30);
|
||||
}
|
||||
|
||||
public ApiDocPage(String id,String name,String description,ApiDocPageWriter...writers) {
|
||||
this();
|
||||
setId(id);
|
||||
setName(name);
|
||||
setDescription(description);
|
||||
for (ApiDocPageWriter writer:writers) {
|
||||
addPageWriter(writer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the page writers.
|
||||
*/
|
||||
public List<ApiDocPageWriter> getPageWriters() {
|
||||
return pageWriters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param writer the writer to add.
|
||||
*/
|
||||
public void addPageWriter(ApiDocPageWriter writer) {
|
||||
pageWriters.add(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param writer the writer to add.
|
||||
*/
|
||||
public void removePageWriter(ApiDocPageWriter writer) {
|
||||
pageWriters.remove(writer);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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.api.dom;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* ApiDocPageWriter writes a page content part.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2013
|
||||
*/
|
||||
public interface ApiDocPageWriter {
|
||||
|
||||
void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException;
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* 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.api.dom;
|
||||
|
||||
import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
|
||||
|
||||
/**
|
||||
* ApiDocWriteEvent holds the needed objects to process write events of content parts.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2013
|
||||
*/
|
||||
public class ApiDocWriteEvent<T> {
|
||||
|
||||
private ApiDoc doc = null;
|
||||
private T event = null;
|
||||
private ApiDocContentWriter writer = null;
|
||||
|
||||
/**
|
||||
* Creates an ApiDocNodeBodyEvent.
|
||||
* @param doc The ApiDoc we are writing.
|
||||
* @param writer The content writer to write to.
|
||||
* @param event The event we are firing this event for.
|
||||
*/
|
||||
public ApiDocWriteEvent(ApiDoc doc,ApiDocContentWriter writer,T event) {
|
||||
this.doc=doc;
|
||||
this.writer=writer;
|
||||
this.event=event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the doc
|
||||
*/
|
||||
public ApiDoc getDoc() {
|
||||
return doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the event
|
||||
*/
|
||||
public T getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the writer
|
||||
*/
|
||||
public ApiDocContentWriter getWriter() {
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Api Doc Dom classes.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @since 1.0 May 12,2013
|
||||
*/
|
||||
package org.x4o.xml.eld.doc.api.dom;
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Api Doc Writer classes.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @since 1.0 May 12,2013
|
||||
*/
|
||||
package org.x4o.xml.eld.doc.api;
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The X4O ELD documentation classes.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @since 1.0 Aug 26, 2010
|
||||
*/
|
||||
|
||||
package org.x4o.xml.eld.doc;
|
||||
127
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-color.css
vendored
Normal file
127
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-color.css
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
|
||||
/* Color style sheet */
|
||||
|
||||
body {
|
||||
background-color:#ffffff;
|
||||
color:#353833;
|
||||
}
|
||||
a:link, a:visited {
|
||||
color:#4c6b87;
|
||||
}
|
||||
a:hover, a:focus {
|
||||
color:#bb7a2a;
|
||||
}
|
||||
a:active {
|
||||
color:#4c6b87;
|
||||
}
|
||||
a[name] {
|
||||
color:#353833;
|
||||
}
|
||||
a[name]:hover {
|
||||
color:#353833;
|
||||
}
|
||||
.bar a, .bar a:link, .bar a:visited, .bar a:active {
|
||||
color:#FFFFFF;
|
||||
}
|
||||
.bar a:hover, .bar a:focus {
|
||||
color:#bb7a2a;
|
||||
}
|
||||
.tab {
|
||||
background-color:#0066FF;
|
||||
color:#ffffff;
|
||||
}
|
||||
.bar {
|
||||
color:#FFFFFF;
|
||||
}
|
||||
.topNav {
|
||||
color:#FFFFFF;
|
||||
}
|
||||
.bottomNav {
|
||||
color:#FFFFFF;
|
||||
}
|
||||
.subNav {
|
||||
background-color:#dee3e9;
|
||||
border-bottom:1px solid #9eadc0;
|
||||
}
|
||||
.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
|
||||
color:#FFFFFF;
|
||||
}
|
||||
.topNav a:hover, .bottomNav a:hover {
|
||||
color:#bb7a2a;
|
||||
}
|
||||
.navBarCell1Rev {
|
||||
color:#FFFFFF;
|
||||
border:1px solid #c9aa44;
|
||||
}
|
||||
.title {
|
||||
color:#2c4557;
|
||||
}
|
||||
div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
|
||||
background-color:#dee3e9;
|
||||
border-top:1px solid #9eadc0;
|
||||
border-bottom:1px solid #9eadc0;
|
||||
}
|
||||
ul.blockList ul.blockList ul.blockList li.blockList h3 {
|
||||
background-color:#dee3e9;
|
||||
border-top:1px solid #9eadc0;
|
||||
border-bottom:1px solid #9eadc0;
|
||||
}
|
||||
.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
|
||||
color:#4E4E4E;
|
||||
}
|
||||
ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
|
||||
border:1px solid #9eadc0;
|
||||
background-color:#f9f9f9;
|
||||
}
|
||||
ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
|
||||
background-color:#ffffff;
|
||||
border:1px solid #9eadc0;
|
||||
border-top:none;
|
||||
}
|
||||
ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
|
||||
border:none;
|
||||
border-bottom:1px solid #9eadc0;
|
||||
}
|
||||
ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
|
||||
border-bottom:none;
|
||||
}
|
||||
.contentContainer table, .classUseContainer table, .constantValuesContainer table {
|
||||
border-bottom:1px solid #9eadc0;
|
||||
}
|
||||
.contentContainer .description table, .contentContainer .details table {
|
||||
border-bottom:none;
|
||||
}
|
||||
.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
|
||||
color:#FFFFFF;
|
||||
}
|
||||
caption a:link, caption a:hover, caption a:active, caption a:visited {
|
||||
color:#FFFFFF;
|
||||
}
|
||||
.tableSubHeadingColor {
|
||||
background-color: #EEEEFF;
|
||||
}
|
||||
.altColor {
|
||||
background-color:#eeeeef;
|
||||
}
|
||||
.rowColor {
|
||||
background-color:#ffffff;
|
||||
}
|
||||
th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
|
||||
background:#dee3e9;
|
||||
border-top:1px solid #9eadc0;
|
||||
border-bottom:1px solid #9eadc0;
|
||||
}
|
||||
td.colFirst, th.colFirst {
|
||||
border-left:1px solid #9eadc0;
|
||||
}
|
||||
td.colLast, th.colLast {
|
||||
border-right:1px solid #9eadc0;
|
||||
}
|
||||
td.colOne, th.colOne {
|
||||
border-right:1px solid #9eadc0;
|
||||
border-left:1px solid #9eadc0;
|
||||
}
|
||||
.sourceLineNo {
|
||||
color:green;
|
||||
}
|
||||
|
||||
92
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-font.css
vendored
Normal file
92
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-font.css
vendored
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
|
||||
body {
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
font-size:76%;
|
||||
}
|
||||
pre {
|
||||
font-size:1.3em;
|
||||
}
|
||||
h1 {
|
||||
font-size:1.8em;
|
||||
}
|
||||
h2 {
|
||||
font-size:1.5em;
|
||||
}
|
||||
h3 {
|
||||
font-size:1.4em;
|
||||
}
|
||||
h4 {
|
||||
font-size:1.3em;
|
||||
}
|
||||
h5 {
|
||||
font-size:1.2em;
|
||||
}
|
||||
h6 {
|
||||
font-size:1.1em;
|
||||
}
|
||||
code, tt {
|
||||
font-size:1.2em;
|
||||
}
|
||||
dt code {
|
||||
font-size:1.2em;
|
||||
}
|
||||
table tr td dt code {
|
||||
font-size:1.2em;
|
||||
vertical-align:top;
|
||||
}
|
||||
sup {
|
||||
font-size:0.6em;
|
||||
}
|
||||
.aboutLanguage {
|
||||
font-size:0.8em;
|
||||
}
|
||||
.tab {
|
||||
font-weight:bold;
|
||||
}
|
||||
.bar {
|
||||
font-size:1.0em;
|
||||
}
|
||||
ul.subNavList li{
|
||||
font-size:90%;
|
||||
}
|
||||
.indexHeader h1 {
|
||||
font-size:1.3em;
|
||||
}
|
||||
.header ul li, .footer ul li {
|
||||
font-size:1.2em;
|
||||
}
|
||||
.indexContainer {
|
||||
font-size:1.0em;
|
||||
}
|
||||
.indexContainer h2 {
|
||||
font-size:1.1em;
|
||||
}
|
||||
.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
|
||||
font-size:1.1em;
|
||||
font-weight:bold;
|
||||
}
|
||||
.serializedFormContainer dl.nameValue dt {
|
||||
font-size:1.1em;
|
||||
font-weight:bold;
|
||||
}
|
||||
.serializedFormContainer dl.nameValue dd {
|
||||
font-size:1.1em;
|
||||
}
|
||||
ul.horizontal li {
|
||||
font-size:0.9em;
|
||||
}
|
||||
.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
|
||||
font-weight:bold;
|
||||
}
|
||||
td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover {
|
||||
font-weight:bold;
|
||||
}
|
||||
h1.hidden {
|
||||
font-size:0.9em;
|
||||
}
|
||||
.strong {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
|
||||
|
||||
53
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-html.css
vendored
Normal file
53
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-html.css
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
|
||||
|
||||
a:link, a:visited {
|
||||
text-decoration:none;
|
||||
}
|
||||
a:hover, a:focus {
|
||||
text-decoration:none;
|
||||
}
|
||||
a:active {
|
||||
text-decoration:none;
|
||||
}
|
||||
a[name] {
|
||||
}
|
||||
a[name]:hover {
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-type:disc;
|
||||
}
|
||||
.bar a, .bar a:link, .bar a:visited, .bar a:active {
|
||||
text-decoration:none;
|
||||
}
|
||||
ul.navList li{
|
||||
list-style:none;
|
||||
}
|
||||
ul.subNavList li{
|
||||
list-style:none;
|
||||
}
|
||||
.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
|
||||
text-decoration:none;
|
||||
}
|
||||
.topNav a:hover, .bottomNav a:hover {
|
||||
text-decoration:none;
|
||||
}
|
||||
.header ul li, .footer ul li {
|
||||
list-style:none;
|
||||
}
|
||||
.indexContainer ul li {
|
||||
list-style:none;
|
||||
}
|
||||
ul.inheritance li {
|
||||
list-style:none;
|
||||
}
|
||||
ul.blockList li.blockList, ul.blockListLast li.blockList {
|
||||
list-style:none;
|
||||
}
|
||||
ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
|
||||
list-style:none;
|
||||
}
|
||||
|
||||
|
||||
183
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-inset.css
vendored
Normal file
183
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-inset.css
vendored
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
|
||||
|
||||
body {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
.aboutLanguage {
|
||||
padding:0px 21px;
|
||||
margin-top:-7px;
|
||||
}
|
||||
.legalCopy {
|
||||
margin-left:0.5em;
|
||||
}
|
||||
.tab {
|
||||
padding:8px;
|
||||
}
|
||||
.bar {
|
||||
padding:0.8em 0.5em 0.4em 0.8em;
|
||||
margin:0px;
|
||||
}
|
||||
.topNav {
|
||||
padding:0px;
|
||||
padding-top:10px;
|
||||
}
|
||||
.bottomNav {
|
||||
margin-top:10px;
|
||||
padding:0px;
|
||||
padding-top:10px;
|
||||
}
|
||||
.subNav div {
|
||||
padding:0px 0px 5px 6px;
|
||||
}
|
||||
ul.navList, ul.subNavList {
|
||||
margin:0px 25px 0px 0px;
|
||||
padding:0px;
|
||||
}
|
||||
ul.navList li{
|
||||
padding:3px 6px;
|
||||
}
|
||||
.navBarCell1Rev {
|
||||
margin: auto 5px;
|
||||
}
|
||||
.header, .footer {
|
||||
margin:0px 20px;
|
||||
padding:5px 0px 0px 0px;
|
||||
}
|
||||
.indexHeader {
|
||||
margin:10px;
|
||||
}
|
||||
.title {
|
||||
margin:10px 0px;
|
||||
}
|
||||
.subTitle {
|
||||
margin:5px 0px 0px 0px;
|
||||
}
|
||||
.header ul {
|
||||
margin:0px 0px 25px 0px;
|
||||
padding:0px;
|
||||
}
|
||||
.footer ul {
|
||||
margin:20px 0 5px 0;
|
||||
}
|
||||
div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
|
||||
margin:0px 0px 6px -8px;
|
||||
padding:2px 5px;
|
||||
}
|
||||
ul.blockList ul.blockList ul.blockList li.blockList h3 {
|
||||
margin:0px 0px 6px -8px;
|
||||
padding:2px 5px;
|
||||
}
|
||||
ul.blockList ul.blockList li.blockList h3 {
|
||||
padding:0px;
|
||||
margin:15px 0px;
|
||||
}
|
||||
ul.blockList li.blockList h2 {
|
||||
padding:0px 0px 20px 0px;
|
||||
}
|
||||
.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
|
||||
padding:10px 20px;
|
||||
}
|
||||
.indexContainer {
|
||||
margin:10px;
|
||||
}
|
||||
.indexContainer h2 {
|
||||
padding:0px 0px 3px 0px;
|
||||
}
|
||||
.indexContainer ul {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
|
||||
margin:10px 0px 0px 0px;
|
||||
}
|
||||
.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd {
|
||||
margin:10px 0px 10px 20px;
|
||||
}
|
||||
.serializedFormContainer dl.nameValue dt {
|
||||
margin-left:1px;
|
||||
}
|
||||
.serializedFormContainer dl.nameValue dd {
|
||||
margin:0px 0px 0px 1px;
|
||||
}
|
||||
ul.inheritance {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
ul.inheritance li ul.inheritance {
|
||||
margin-left:15px;
|
||||
padding-left:15px;
|
||||
padding-top:1px;
|
||||
}
|
||||
ul.blockList, ul.blockListLast {
|
||||
margin:10px 0px 10px 0px;
|
||||
padding:0px;
|
||||
}
|
||||
ul.blockList li.blockList, ul.blockListLast li.blockList {
|
||||
margin-bottom:25px;
|
||||
}
|
||||
ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
|
||||
padding:0px 20px 5px 10px;
|
||||
}
|
||||
ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
|
||||
padding:0px 0px 5px 8px;
|
||||
}
|
||||
ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
|
||||
margin-left:0px;
|
||||
padding-left:0px;
|
||||
padding-bottom:15px;
|
||||
}
|
||||
ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
|
||||
padding-bottom:0;
|
||||
}
|
||||
table tr td dl, table tr td dl dt, table tr td dl dd {
|
||||
margin-top:0px;
|
||||
margin-bottom:1px;
|
||||
}
|
||||
.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{
|
||||
padding-right:20px;
|
||||
}
|
||||
.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast,
|
||||
.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast,
|
||||
.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne,
|
||||
.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne {
|
||||
padding-right:3px;
|
||||
}
|
||||
.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
}
|
||||
.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
|
||||
padding-top:8px;
|
||||
padding-left:8px;
|
||||
}
|
||||
ul.blockList ul.blockList li.blockList table {
|
||||
margin:0px 0px 12px 0px;
|
||||
}
|
||||
.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td {
|
||||
padding:3px 3px 3px 7px;
|
||||
}
|
||||
th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
|
||||
padding:3px 3px 3px 7px;
|
||||
}
|
||||
table.overviewSummary {
|
||||
padding:0px;
|
||||
margin-left:0px;
|
||||
}
|
||||
.description pre {
|
||||
margin-top:0px;
|
||||
}
|
||||
.deprecatedContent {
|
||||
margin:0px;
|
||||
padding:10px 0px;
|
||||
}
|
||||
.docSummary {
|
||||
padding:0px;
|
||||
}
|
||||
.sourceLineNo {
|
||||
padding:0px 30px 0px 0px;
|
||||
}
|
||||
.block {
|
||||
margin:3px 0px 0px 0px;
|
||||
}
|
||||
|
||||
131
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-layout.css
vendored
Normal file
131
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-layout.css
vendored
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
|
||||
|
||||
.clear {
|
||||
clear:both;
|
||||
height:0px;
|
||||
overflow:hidden;
|
||||
}
|
||||
.aboutLanguage {
|
||||
float:right;
|
||||
z-index:200;
|
||||
}
|
||||
|
||||
.tab {
|
||||
width:5em;
|
||||
}
|
||||
.bar {
|
||||
height:auto;
|
||||
}
|
||||
.topNav {
|
||||
float:left;
|
||||
width:100%;
|
||||
clear:right;
|
||||
height:2.8em;
|
||||
overflow:hidden;
|
||||
}
|
||||
.bottomNav {
|
||||
float:left;
|
||||
width:100%;
|
||||
clear:right;
|
||||
height:2.8em;
|
||||
overflow:hidden;
|
||||
}
|
||||
.subNav {
|
||||
float:left;
|
||||
width:100%;
|
||||
overflow:hidden;
|
||||
}
|
||||
.subNav div {
|
||||
clear:left;
|
||||
float:left;
|
||||
}
|
||||
ul.navList, ul.subNavList {
|
||||
float:left;
|
||||
}
|
||||
ul.navList li, ul.subNavList li {
|
||||
float:left;
|
||||
}
|
||||
.header, .footer {
|
||||
clear:both;
|
||||
}
|
||||
.indexHeader {
|
||||
position:relative;
|
||||
}
|
||||
.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
|
||||
clear:both;
|
||||
position:relative;
|
||||
}
|
||||
.indexContainer {
|
||||
position:relative;
|
||||
}
|
||||
.serializedFormContainer dl.nameValue dt {
|
||||
display:inline;
|
||||
}
|
||||
.serializedFormContainer dl.nameValue dd {
|
||||
display:inline;
|
||||
}
|
||||
ul.horizontal li {
|
||||
display:inline;
|
||||
}
|
||||
ul.inheritance li {
|
||||
display:inline;
|
||||
}
|
||||
.contentContainer table, .classUseContainer table, .constantValuesContainer table {
|
||||
width:100%;
|
||||
}
|
||||
.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table {
|
||||
width:100%;
|
||||
}
|
||||
.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{
|
||||
vertical-align:top;
|
||||
}
|
||||
.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
|
||||
position:relative;
|
||||
text-align:left;
|
||||
clear:none;
|
||||
overflow:hidden;
|
||||
}
|
||||
.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
|
||||
white-space:nowrap;
|
||||
display:block;
|
||||
float:left;
|
||||
height:18px;
|
||||
}
|
||||
.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
|
||||
width:10px;
|
||||
position:relative;
|
||||
float:left;
|
||||
}
|
||||
ul.blockList ul.blockList li.blockList table {
|
||||
width:100%;
|
||||
}
|
||||
.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td {
|
||||
text-align:left;
|
||||
}
|
||||
th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
|
||||
text-align:left;
|
||||
}
|
||||
td.colFirst, th.colFirst {
|
||||
white-space:nowrap;
|
||||
}
|
||||
table.overviewSummary td.colFirst, table.overviewSummary th.colFirst,
|
||||
table.overviewSummary td.colOne, table.overviewSummary th.colOne {
|
||||
width:25%;
|
||||
vertical-align:middle;
|
||||
}
|
||||
table.packageSummary td.colFirst, table.overviewSummary th.colFirst {
|
||||
width:25%;
|
||||
vertical-align:middle;
|
||||
}
|
||||
h1.hidden {
|
||||
visibility:hidden;
|
||||
overflow:hidden;
|
||||
}
|
||||
.block {
|
||||
display:block;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
106
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css
vendored
Normal file
106
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
|
||||
body {
|
||||
padding:10px;
|
||||
font-family:none;
|
||||
}
|
||||
|
||||
.topNav,
|
||||
.bottomNav {
|
||||
height:auto;
|
||||
}
|
||||
|
||||
.tab {
|
||||
background-color:#00CCFF;
|
||||
}
|
||||
|
||||
.bar,
|
||||
.topNav,
|
||||
.bottomNav {
|
||||
background-color: #EEEEFF;
|
||||
border-top: 2px solid #000;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
|
||||
.subNav {
|
||||
background-color: #FFF;
|
||||
border-bottom: 2px solid #000;
|
||||
font-size:0.8em;
|
||||
}
|
||||
|
||||
.topNav a:link,
|
||||
.topNav a:active,
|
||||
.topNav a:visited,
|
||||
.bottomNav a:link,
|
||||
.bottomNav a:active,
|
||||
.bottomNav a:visited {
|
||||
color:#000;
|
||||
text-decoration: underline;
|
||||
font-weight:bold;
|
||||
font-size:1.2em;
|
||||
}
|
||||
|
||||
.aboutLanguage {
|
||||
position:absolute;
|
||||
right:10px;
|
||||
text-align:right;
|
||||
width:250px;
|
||||
font-size: 0.9em;
|
||||
color:#000;
|
||||
margin:0px;
|
||||
background-color: #FFF;
|
||||
padding:1px;
|
||||
}
|
||||
|
||||
li {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.topNav ul li,
|
||||
.bottomNav ul li {
|
||||
margin-top:3px;
|
||||
}
|
||||
|
||||
.navBarCell1Rev {
|
||||
color:#FFF;
|
||||
background-color:#00008B;
|
||||
font-weight:bold;
|
||||
border:none;
|
||||
margin-top:3px;
|
||||
margin-bottom:3px;
|
||||
}
|
||||
|
||||
.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
|
||||
background-color: #EEEEFF;
|
||||
}
|
||||
|
||||
.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
|
||||
background-color: #EEEEFF;
|
||||
}
|
||||
|
||||
th.colFirst,
|
||||
th.colLast,
|
||||
th.colOne,
|
||||
.constantValuesContainer th {
|
||||
background-color:#CCCCFF;
|
||||
border-top: 1px solid #000;
|
||||
border-bottom: 1px solid #000;
|
||||
}
|
||||
|
||||
.altColor {
|
||||
background-color: #FFF;
|
||||
}
|
||||
|
||||
.contentContainer table tbody tr td,
|
||||
.classUseContainer table tbody tr td,
|
||||
.constantValuesContainer table tbody tr td {
|
||||
border-bottom: 1px solid #000;
|
||||
}
|
||||
|
||||
td.colFirst,
|
||||
th.colFirst {
|
||||
border-right: 1px solid #000;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BIN
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/background.png
vendored
Normal file
BIN
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/background.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
22
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css
vendored
Normal file
22
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
.tab {
|
||||
background-image:url(titlebar.png);
|
||||
background-position:left top;
|
||||
background-repeat:no-repeat;
|
||||
}
|
||||
.bar,.topNav,.bottomNav {
|
||||
background-image:url(background.png);
|
||||
background-repeat:repeat-x;
|
||||
}
|
||||
.navBarCell1Rev {
|
||||
background-image:url(tab.png);
|
||||
}
|
||||
.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
|
||||
background-image:url(titlebar.png);
|
||||
}
|
||||
.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
|
||||
background-image:url(titlebar_end.png);
|
||||
background-repeat:no-repeat;
|
||||
background-position:top right;
|
||||
}
|
||||
|
||||
BIN
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/tab.png
vendored
Normal file
BIN
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/tab.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 333 B |
BIN
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar.png
vendored
Normal file
BIN
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png
vendored
Normal file
BIN
x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 683 B |
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* 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 org.x4o.xml.eld.CelDriver;
|
||||
import org.x4o.xml.eld.EldDriver;
|
||||
import org.x4o.xml.test.TestDriver;
|
||||
import org.x4o.xml.test.swixml.SwiXmlDriver;
|
||||
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Test for eld doc generation
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 26, 2010
|
||||
*/
|
||||
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);
|
||||
if (result.exists()==false) {
|
||||
result.mkdir();
|
||||
}
|
||||
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 testEldDoc() throws Exception {
|
||||
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
||||
writer.setBasePath(createOutputTargetPath("junit-eld"));
|
||||
writer.setLanguageName(EldDriver.LANGUAGE_NAME);
|
||||
writer.execute();
|
||||
}
|
||||
|
||||
public void testUnitDoc() throws Exception {
|
||||
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
||||
writer.setBasePath(createOutputTargetPath("junit-test"));
|
||||
writer.setLanguageName(TestDriver.LANGUAGE_NAME);
|
||||
writer.execute();
|
||||
}
|
||||
|
||||
public void testSwiXml2Doc() throws Exception {
|
||||
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
||||
writer.setBasePath(createOutputTargetPath("junit-swixml2"));
|
||||
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2);
|
||||
writer.execute();
|
||||
}
|
||||
|
||||
public void testSwiXml3Doc() throws Exception {
|
||||
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
||||
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});
|
||||
}
|
||||
}
|
||||
0
x4o-eld-doc/src/test/resources/.empty
Normal file
0
x4o-eld-doc/src/test/resources/.empty
Normal file
Loading…
Add table
Add a link
Reference in a new issue