added more xml writer options and improved api doc output.
This commit is contained in:
parent
380b829fcb
commit
5f08acb488
12 changed files with 571 additions and 250 deletions
|
|
@ -175,8 +175,8 @@ public class EldDocWriter {
|
|||
doc.setNoFrameAllName("All Elements");
|
||||
doc.setFrameNavPrintParent(true);
|
||||
doc.setFrameNavPrintParentId(true);
|
||||
doc.setGroupTypeName("summary", "Summary");
|
||||
doc.setGroupTypeName("overview", "Overview");
|
||||
doc.setGroupTypeName("summary", "Summary",1);
|
||||
doc.setGroupTypeName("overview", "Overview",2);
|
||||
|
||||
// Javadoc linking config
|
||||
List<String> javadocLinkList = propertyConfig.getPropertyList(JAVADOC_LINK);
|
||||
|
|
|
|||
|
|
@ -94,13 +94,13 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
writeAllFrameNav(true);
|
||||
writeAllFrameNav(false);
|
||||
|
||||
// Write pages
|
||||
// Write api doc tree
|
||||
writeNode(doc.getRootNode());
|
||||
|
||||
// Write pages last
|
||||
for (ApiDocPage page:doc.getDocPages()) {
|
||||
writePage(page);
|
||||
}
|
||||
|
||||
// Write api doc tree
|
||||
writeNode(doc.getRootNode());
|
||||
}
|
||||
|
||||
private void writeNode(ApiDocNode node) throws SAXException {
|
||||
|
|
@ -371,7 +371,11 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
|
||||
private void configSubNavLinks(ApiDocNode node) {
|
||||
ApiDocNodeData conf = doc.getNodeData();
|
||||
for (ApiDocNodeWriter writer:findNodeBodyWriters(node, null)) {
|
||||
List<ApiDocNodeWriter> orderedWriters = new ArrayList<ApiDocNodeWriter>(10);
|
||||
for (ApiDocNodeBody bodyType:ApiDocNodeBody.values()) {
|
||||
orderedWriters.addAll(findNodeBodyWriters(node,bodyType)); // enum order is oke
|
||||
}
|
||||
for (ApiDocNodeWriter writer:orderedWriters) {
|
||||
String group = writer.getContentGroup();
|
||||
String groupTypeKey = writer.getContentGroupType();
|
||||
if (group==null | groupTypeKey==null) {
|
||||
|
|
@ -464,10 +468,16 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
}
|
||||
|
||||
private List<ApiDocNodeWriter> findNodeBodyWriters(ApiDocNode node,ApiDocNodeBody nodeBody) {
|
||||
if (node==null) {
|
||||
throw new NullPointerException("Can't search writers on null node.");
|
||||
}
|
||||
if (nodeBody==null) {
|
||||
throw new NullPointerException("Can't search writers with null nodeBody."); // for sorting rules
|
||||
}
|
||||
List<ApiDocNodeWriter> result = new ArrayList<ApiDocNodeWriter>();
|
||||
final Class<?> objClass = node.getUserData().getClass();
|
||||
for (ApiDocNodeWriter writer:doc.getNodeBodyWriters()) {
|
||||
if (nodeBody!=null && !nodeBody.equals(writer.getNodeBody())) {
|
||||
if (!nodeBody.equals(writer.getNodeBody())) {
|
||||
continue;
|
||||
}
|
||||
for (Class<?> c:writer.getTargetClasses()) {
|
||||
|
|
@ -476,46 +486,45 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(result, new Comparator<ApiDocNodeWriter>() {
|
||||
public int compare(ApiDocNodeWriter o1, ApiDocNodeWriter o2) {
|
||||
int index1 = -1;
|
||||
int index2 = -1;
|
||||
for (int i=0;i<o1.getTargetClasses().size();i++) {
|
||||
Class<?> c = o1.getTargetClasses().get(i);
|
||||
if (c.isAssignableFrom(objClass)) {
|
||||
index1 = i;
|
||||
break;
|
||||
}
|
||||
Collections.sort(result, new ApiDocNodeWriterComparator(objClass));
|
||||
return result;
|
||||
}
|
||||
|
||||
private class ApiDocNodeWriterComparator implements Comparator<ApiDocNodeWriter> {
|
||||
final Class<?> objClass;
|
||||
public ApiDocNodeWriterComparator(Class<?> objClass) {
|
||||
this.objClass=objClass;
|
||||
}
|
||||
public int compare(ApiDocNodeWriter o1, ApiDocNodeWriter o2) {
|
||||
int index1 = -1;
|
||||
int index2 = -1;
|
||||
for (int i=0;i<o1.getTargetClasses().size();i++) {
|
||||
Class<?> c = o1.getTargetClasses().get(i);
|
||||
if (c.isAssignableFrom(objClass)) {
|
||||
index1 = i;
|
||||
break;
|
||||
}
|
||||
for (int i=0;i<o2.getTargetClasses().size();i++) {
|
||||
Class<?> c = o2.getTargetClasses().get(i);
|
||||
if (c.isAssignableFrom(objClass)) {
|
||||
index1 = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO: note check return value if are oke in order..
|
||||
if (index1==-1 && index2==-1) {
|
||||
return 0;
|
||||
}
|
||||
if (index1==-1) {
|
||||
return 1;
|
||||
}
|
||||
if (index2==-1) {
|
||||
return -1;
|
||||
}
|
||||
int orderValue1 = o1.getNodeBodyOrders().get(index1);
|
||||
int orderValue2 = o2.getNodeBodyOrders().get(index2);
|
||||
if (orderValue1==orderValue2) {
|
||||
return 0;
|
||||
}
|
||||
if (orderValue1 > orderValue2) {
|
||||
return -1;
|
||||
}
|
||||
for (int i=0;i<o2.getTargetClasses().size();i++) {
|
||||
Class<?> c = o2.getTargetClasses().get(i);
|
||||
if (c.isAssignableFrom(objClass)) {
|
||||
index2 = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index1==-1 && index2==-1) {
|
||||
return 0;
|
||||
}
|
||||
if (index1==-1) {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
if (index2==-1) {
|
||||
return -1;
|
||||
}
|
||||
Integer orderValue1 = o1.getNodeBodyOrders().get(index1);
|
||||
Integer orderValue2 = o2.getNodeBodyOrders().get(index2);
|
||||
return orderValue1.compareTo(orderValue2);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ApiDocNodeDataConfigurator> findDataConfigurators(ApiDocNode node) {
|
||||
|
|
@ -980,6 +989,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
atts.addAttribute ("", "href", "", "", "#skip-"+barId);
|
||||
atts.addAttribute ("", "title", "", "", "Skip navigation links");
|
||||
writer.startElement("", "a", "", atts);
|
||||
writer.comment(" ");
|
||||
writer.endElement("", "a", "");
|
||||
writer.printHrefNamed(barId+"_firstrow");
|
||||
|
||||
|
|
@ -1055,18 +1065,27 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
}
|
||||
writer.printTagEnd(Tag.div);
|
||||
}
|
||||
|
||||
String tabSpace = " | ";
|
||||
List<String> groupKeys = conf.getGroupTypeKeys();
|
||||
boolean printLink = groupKeys.isEmpty()==false;
|
||||
boolean printLink = conf.getGroupTypeKeys().isEmpty()==false;
|
||||
if (printLink) {
|
||||
writer.printTagStart(Tag.div);
|
||||
writer.printTagStart(Tag.ul,ApiDocContentCss.subNavList);
|
||||
List<String> groupKeys = new ArrayList<String>(5);
|
||||
for (String groupKey:doc.getGroupTypesOrdered()) {
|
||||
if (!conf.getGroupTypeKeys().contains(groupKey)) {
|
||||
continue;
|
||||
}
|
||||
groupKeys.add(groupKey);
|
||||
}
|
||||
boolean printDiv = false;
|
||||
for (int i=0;i<groupKeys.size();i++) {
|
||||
String groupKey = groupKeys.get(i);
|
||||
String groupName = doc.getGroupTypeName(groupKey);
|
||||
List<ApiDocNavLink> links = conf.getGroupTypeLinks(groupKey);
|
||||
if (links.isEmpty()==false) {
|
||||
if (!printDiv) {
|
||||
printDiv = true;
|
||||
writer.printTagStart(Tag.div); // don't print empty div
|
||||
}
|
||||
writer.printTagStart(Tag.ul,ApiDocContentCss.subNavList);
|
||||
writer.printTagStart(Tag.li);writer.characters(groupName+": ");writer.printTagEnd(Tag.li);
|
||||
for (int l=0;l<links.size();l++) {
|
||||
ApiDocNavLink link = links.get(l);
|
||||
|
|
@ -1083,15 +1102,15 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
writer.characters(tab);
|
||||
}
|
||||
}
|
||||
|
||||
writer.printTagEnd(Tag.li);
|
||||
}
|
||||
writer.printTagEnd(Tag.ul);
|
||||
}
|
||||
}
|
||||
writer.printTagEnd(Tag.ul);
|
||||
writer.printTagEnd(Tag.div);
|
||||
if (printDiv) {
|
||||
writer.printTagEnd(Tag.div);
|
||||
}
|
||||
}
|
||||
|
||||
writer.printHrefNamed("skip-"+barId);
|
||||
writer.printTagEnd(Tag.div);
|
||||
writer.comment("========= END OF "+barComment+" NAVBAR =======");
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import java.util.Collection;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.x4o.xml.eld.doc.api.ApiDocNodeDataConfiguratorBean;
|
||||
import org.x4o.xml.eld.doc.api.ApiDocNodeWriterBean;
|
||||
|
|
@ -75,6 +76,7 @@ public class ApiDoc {
|
|||
private boolean printConceptTitle = true;
|
||||
private boolean printConceptPrevNext = true;
|
||||
private Map<String,String> groupTypeNames = null;
|
||||
private Map<String,Integer> groupTypeOrder = null;
|
||||
private String docPageSubTitle = null;
|
||||
|
||||
public ApiDoc() {
|
||||
|
|
@ -88,6 +90,7 @@ public class ApiDoc {
|
|||
annotatedClasses = new ArrayList<Class<?>>(5);
|
||||
remoteClasses = new ArrayList<ApiDocRemoteClass>(5);
|
||||
groupTypeNames = new HashMap<String,String>(3);
|
||||
groupTypeOrder = new HashMap<String,Integer>(3);
|
||||
}
|
||||
|
||||
public void checkModel() throws NullPointerException,IllegalArgumentException {
|
||||
|
|
@ -671,6 +674,15 @@ public class ApiDoc {
|
|||
this.printConceptPrevNext = printConceptPrevNext;
|
||||
}
|
||||
|
||||
public List<String> getGroupTypesOrdered() {
|
||||
Map<Integer,String> orderedMap = new TreeMap<Integer,String>();
|
||||
for (String key:groupTypeOrder.keySet()) {
|
||||
Integer order = groupTypeOrder.get(key);
|
||||
orderedMap.put(order, key);
|
||||
}
|
||||
return new ArrayList<String>(orderedMap.values());
|
||||
}
|
||||
|
||||
public String getGroupTypeName(String groupTypeKey) {
|
||||
String result = groupTypeNames.get(groupTypeKey);
|
||||
if (result==null) {
|
||||
|
|
@ -679,8 +691,9 @@ public class ApiDoc {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void setGroupTypeName(String groupTypeKey,String name) {
|
||||
public void setGroupTypeName(String groupTypeKey,String name,int order) {
|
||||
groupTypeNames.put(groupTypeKey,name);
|
||||
groupTypeOrder.put(groupTypeKey, order);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* ApiDocIndexItem holds data to print the index all page.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 09, 2013
|
||||
*/
|
||||
public class ApiDocIndexItem {
|
||||
|
||||
private String linkHref = null;
|
||||
private String linkText = null;
|
||||
private String titlePostHref = null;
|
||||
private String titlePostText = null;
|
||||
|
||||
private String title = null;
|
||||
private String description = null;
|
||||
|
||||
public ApiDocIndexItem() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the linkHref
|
||||
*/
|
||||
public String getLinkHref() {
|
||||
return linkHref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param linkHref the linkHref to set
|
||||
*/
|
||||
public void setLinkHref(String linkHref) {
|
||||
this.linkHref = linkHref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the linkText
|
||||
*/
|
||||
public String getLinkText() {
|
||||
return linkText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param linkText the linkText to set
|
||||
*/
|
||||
public void setLinkText(String linkText) {
|
||||
this.linkText = linkText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the titlePostHref
|
||||
*/
|
||||
public String getTitlePostHref() {
|
||||
return titlePostHref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param titlePostHref the titlePostHref to set
|
||||
*/
|
||||
public void setTitlePostHref(String titlePostHref) {
|
||||
this.titlePostHref = titlePostHref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the titlePostText
|
||||
*/
|
||||
public String getTitlePostText() {
|
||||
return titlePostText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param titlePostText the titlePostText to set
|
||||
*/
|
||||
public void setTitlePostText(String titlePostText) {
|
||||
this.titlePostText = titlePostText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title the title to set
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
@ -43,11 +43,21 @@ public class ApiDocNodeData {
|
|||
private String nextLink = null;
|
||||
private String framePath = null;;
|
||||
private List<ApiDocNavLink> navLinks = null;
|
||||
private List<ApiDocIndexItem> indexItems = null;
|
||||
|
||||
public ApiDocNodeData() {
|
||||
navLinks = new ArrayList<ApiDocNavLink>(12);
|
||||
groupTypeKeys = new ArrayList<String>(navLinks.size()/3);
|
||||
groupTypeLinks = new HashMap<String,List<ApiDocNavLink>>(groupTypeKeys.size());
|
||||
indexItems = new ArrayList<ApiDocIndexItem>(500);
|
||||
}
|
||||
|
||||
public List<ApiDocIndexItem> getIndexItems() {
|
||||
return indexItems;
|
||||
}
|
||||
|
||||
public void addIndexItem(ApiDocIndexItem indexItem) {
|
||||
indexItems.add(indexItem);
|
||||
}
|
||||
|
||||
public void addGroupTypeKey(String groupTypeKey) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue