Switch href args and changed DESCRIPTION_NODE div-ving schema

This commit is contained in:
Willem Cazander 2025-01-19 17:46:25 +01:00
parent 2930452b07
commit 373174a58d
12 changed files with 229 additions and 155 deletions

View file

@ -22,10 +22,10 @@
*/
package org.x4o.fc18.cake2.fcdoc;
import java.io.Closeable;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.x4o.fc18.cake2.FourCornerDotCake;
@ -47,7 +47,7 @@ import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
*/
public class FCDocSegmentWriterCake implements FCDocSegmentWriter {
private final String[] FC_FEATURES = new String[] {
private static final String[] FC_FEATURES = new String[] {
"VT-06 terminal control for CDC1604(1960) 6 bit main frames",
"Has underscored letters to migrate EBCDIC(1963) APL code from z/OS",
"Program with (local) words not with lettersssss",
@ -60,22 +60,25 @@ public class FCDocSegmentWriterCake implements FCDocSegmentWriter {
"Contains the BIP0039(2013) keyword encoding too",
};
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_NODE,targetClasses={TDocCake.class})
public void writeSchemaViewSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
@ApiDocNodeWriterMethod(nodeBody = ApiDocNodeBody.DESCRIPTION_NODE, targetClasses = {TDocCake.class}, nodeBodyOrders = 20)
public void writeFeatureListing(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
writer.printCharacters("Features;");
try (ContentCloseable content = writer.docPageContent()) {
try (ContentCloseable ul = writer.printTag(Tag.ul)) {
for (String feature : FC_FEATURES) {
try (ContentCloseable li = writer.printTag(Tag.li, "", null, "circle")) {
writer.printCharacters(feature);
}
}
}
}
}
@ApiDocNodeWriterMethod(nodeBody = ApiDocNodeBody.DESCRIPTION_NODE, targetClasses = {TDocCake.class}, nodeBodyOrders = 1)
public void writeIntro(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
writer.printCharacters("Four corner is 18 bit text encoding for 144 bit computers.");
writer.printTagStartEnd(Tag.br);
writer.printTagStartEnd(Tag.br);
writer.printCharacters("Features;");
try (Closeable content = writer.docPageContent()) {
writer.printTagStart(Tag.ul);
for (String feature : FC_FEATURES) {
writer.printTagStart(Tag.li,"",null,"circle");
writer.printCharacters(feature);
writer.printTagEnd(Tag.li);
}
writer.printTagEnd(Tag.ul);
}
}
@ApiDocNodeWriterMethod(nodeBody = ApiDocNodeBody.SUMMARY, targetClasses = {TDocCake.class}, nodeBodyOrders = 20)
@ -105,15 +108,14 @@ public class FCDocSegmentWriterCake implements FCDocSegmentWriter {
public void writeTowerSummary(ApiDocWriteEvent<ApiDocNode> e) throws IOException {
String rootId = e.getDoc().getRootNode().getId();
ApiDocConcept concept = e.getDoc().findConceptByClass(e.getEventObject().getUserData().getClass());
String tableName = concept.getName()+" Details";
String tableName = concept.getName() + " Elevator";
ApiDocContentWriter writer = e.getWriter();
//try (ContentCloseable content = writer.docPageContent()) {
try (ContentCloseable table = writer.docTable(tableName, null, ApiDocContentCss.overviewSummary)) {
writeTableBoxHeader(writer, new String[] {"Cake", "Tower", "Start", "Stop", "Size", "External"});
Set<FourCornerDotCake> linkableSlices = new HashSet<>();
for (ApiDocNode towerNode : e.getEventObject().getNodes()) {
for (ApiDocNode sliceNode : towerNode.getNodes()) {
FourCornerDotCake slice = FourCornerDotCake.class.cast(sliceNode.getUserData());
FourCornerDotCake slice = sliceNode.toUserData(TDocCakeSlice.class).getSlice();
linkableSlices.add(slice);
StringBuilder buf = new StringBuilder();
buf.append(ApiDocContentWriter.toSafeUri(rootId)); // TODO: add full tree node ID href version of toSafeUri
@ -122,26 +124,25 @@ public class FCDocSegmentWriterCake implements FCDocSegmentWriter {
buf.append("/");
buf.append(ApiDocContentWriter.toSafeUri(sliceNode.getId()));
buf.append("/index.html");
writeCake(writer, slice, buf.toString());
writeCake(writer, slice, Optional.of(buf.toString()));
}
}
for (FourCornerDotCake slice : FourCornerDotCake.values()) {
if (linkableSlices.contains(slice)) {
continue;
}
writeCake(writer, slice, null);
writeCake(writer, slice, Optional.empty());
}
}
//}
}
private void writeCake(ApiDocContentWriter writer, FourCornerDotCake slice, String href) throws IOException {
private void writeCake(ApiDocContentWriter writer, FourCornerDotCake slice, Optional<String> href) throws IOException {
try (ContentCloseable tableRow = writer.docTableRow()) {
try (ContentCloseable td = writer.printTag(Tag.td, ApiDocContentCss.colFirst)) {
if (href == null) {
if (href.isEmpty()) {
writer.printCharacters(slice.nameSpec());
} else {
writer.printHref(href, slice.description(), slice.nameSpec(), "strong"); // TODO: reverse href method arguments
writer.printHref(href.get(), slice.nameSpec(), slice.description(), "strong");
}
}
try (ContentCloseable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) {

View file

@ -50,7 +50,7 @@ import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
*/
public class FCDocSegmentWriterCakeSlice implements FCDocSegmentWriter {
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL, targetClasses={FourCornerDotCake.class}, nodeBodyOrders=20)
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL, targetClasses={TDocCakeSlice.class}, nodeBodyOrders=20)
public void writeDefaultSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
// NOTE: copyed from defaultWriteSummary as that only called with zero summaries + changes name end in; Words
ApiDocContentWriter writer = event.getWriter();
@ -73,10 +73,10 @@ public class FCDocSegmentWriterCakeSlice implements FCDocSegmentWriter {
writer.docTableEnd();
}
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY, targetClasses={FourCornerDotCake.class}, nodeBodyOrders=1)
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY, targetClasses={TDocCakeSlice.class}, nodeBodyOrders=1)
public void writeCakeSliceDetails(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
FourCornerDotCake slice = (FourCornerDotCake)event.getEventObject().getUserData();
FourCornerDotCake slice = event.getEventObject().toUserData(TDocCakeSlice.class).getSlice();
try (ContentCloseable table = writer.docTable("Cake Slice", null, ApiDocContentCss.overviewSummary)) {
writer.docTableHeader("Information", "Value");
writer.docTableRow("Start index", String.format("0x%06X", slice.getStart()));

View file

@ -45,7 +45,7 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter {
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={TDocCakeWord.class})
public void writeCakeWordSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
TDocCakeWord word = (TDocCakeWord)event.getEventObject().getUserData();
TDocCakeWord word = event.getEventObject().toUserData(TDocCakeWord.class);
FourCornerX00PetitVidePoints[] videPoints = word.getSlice().getVidePoints();
if (videPoints.length == 0) {
return;
@ -84,7 +84,7 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter {
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL,targetClasses={TDocCakeWord.class})
public void writeCakeWordDetail(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
TDocCakeWord word = (TDocCakeWord)event.getEventObject().getUserData();
TDocCakeWord word = event.getEventObject().toUserData(TDocCakeWord.class);
FourCornerX00PetitVidePoints[] videPoints = word.getSlice().getVidePoints();
if (videPoints.length == 0) {
return;

View file

@ -128,7 +128,7 @@ public class FCDocWriter {
doc.setGroupTypeName("overview", "Overview",2);
doc.addTreeNodeClassExclude(TDocCakeWord.class);
doc.setFrameNavConceptClass(FourCornerDotCake.class);
doc.setFrameNavConceptClass(TDocCakeSlice.class);
doc.addTreeNodePageModeClass(TDocCake.class);
doc.addTreeNodePageModeClass(TDocCakeTower.class);
@ -139,7 +139,7 @@ public class FCDocWriter {
ApiDocConcept adc1 = doc.addConcept(new ApiDocConcept(null,C_FC_ROOT,TDocCake.class));
ApiDocConcept adc2 = doc.addConcept(new ApiDocConcept(adc1,C_FC_TOWER,TDocCakeTower.class));
ApiDocConcept adc3 = doc.addConcept(new ApiDocConcept(adc2,C_FC_SLICE,FourCornerDotCake.class));
ApiDocConcept adc3 = doc.addConcept(new ApiDocConcept(adc2,C_FC_SLICE,TDocCakeSlice.class));
/*ApiDocConcept adc4 = */doc.addConcept(new ApiDocConcept(adc3,C_FC_WORD,TDocCakeWord.class));
//ApiDocConcept adc4 = doc.addConcept(new ApiDocConcept(adc3,C_TABLE,Table.class));
@ -175,8 +175,8 @@ public class FCDocWriter {
return new ApiDocNode(new TDocCakeTower(tower), tower.name(), tower.nameNice(), tower.description());
}
private ApiDocNode createNodeCakeSlice(FourCornerDotCake dotCake) {
return new ApiDocNode(dotCake, dotCake.name(), dotCake.nameSpec(), dotCake.description());
private ApiDocNode createNodeCakeSlice(FourCornerDotCake slice) {
return new ApiDocNode(new TDocCakeSlice(slice), slice.name(), slice.nameSpec(), slice.description());
}
private ApiDocNode createNodeCakeWord(FourCornerDotCake dotCake, int offset) {

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2004-2014, 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.fc18.cake2.fcdoc;
import org.x4o.fc18.cake2.FourCornerDotCake;
/**
* Cake slice doc model type.
*
* @author Willem Cazander
* @version 1.0 Jan 19, 2025
*/
public class TDocCakeSlice {
private final FourCornerDotCake slice;
public TDocCakeSlice(FourCornerDotCake slice) {
this.slice = slice;
}
public FourCornerDotCake getSlice() {
return slice;
}
}

View file

@ -132,24 +132,24 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagEnd(Tag.a);
}
public void printHrefTarget(String href,String title,String target) throws IOException {
public void printHrefTarget(String href, String target, String text) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "href", "", "", href);
atts.addAttribute("", "target", "", "", target);
printTagStart(Tag.a,atts);
printCharacters(title);
printCharacters(text);
printTagEnd(Tag.a);
}
public void printHref(String href,String title) throws IOException {
printHref(href,title,title);
public void printHref(String href, String text) throws IOException {
printHref(href, text, text);
}
public void printHref(String href,String title,String text) throws IOException {
printHref(href,title,text,null);
public void printHref(String href, String text, String title) throws IOException {
printHref(href, text, title, null);
}
public void printHref(String href,String title,String text,String spanClass) throws IOException {
public void printHref(String href, String text, String title, String spanClass) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "href", "", "", href);
if (title != null) {
@ -263,7 +263,8 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
datalist,keygen,output,
article,aside,bdi,command,details,dialog,summary,
figure,figcaption,footer,header,hgroup,mark,meter,
nav,progress,ruby,rt,rp,section,time,wbr
nav,progress,ruby,rt,rp,section,time,wbr,
;
}
private final static String DOCTYPE_NAME = "HTML PUBLIC";
@ -279,28 +280,33 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
XHTML_1_TRANSITIONAL(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.0 Transitional//EN\"","http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"),
XHTML_1_STRICT(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.0 Strict//EN\"","http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"),
XHTML_11(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.1//EN\"","http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd");
XHTML_11(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.1//EN\"","http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"),
;
private final String name;
private final String publicId;
private final String systemId;
private DocType(String name, String publicId, String systemId) {
this.name=name;
this.publicId=publicId;
this.systemId=systemId;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the publicId
*/
public String getPublicId() {
return publicId;
}
/**
* @return the systemId
*/

View file

@ -35,10 +35,10 @@ import java.io.IOException;
@FunctionalInterface
public interface ContentCloseable extends Closeable {
void closeTag() throws IOException;
void closeContent() throws IOException;
@Override
default void close() throws IOException {
closeTag();
closeContent(); // wrap for stack trace users
}
}

View file

@ -170,7 +170,7 @@ public interface ApiDocContentPrinter {
if (remoteUrl==null) {
continue;
}
writer.printHref(remoteUrl, cls.getName(), cls.getSimpleName());
writer.printHref(remoteUrl, cls.getSimpleName(), cls.getName());
return null;
}

View file

@ -330,7 +330,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
static public String toSafeUri(String uri) {
StringBuilder buf = new StringBuilder(20);
for (char c:uri.toLowerCase().toCharArray()) {
for (char c : uri.toLowerCase().toCharArray()) { // TODO: unicode 16+ error
if (Character.isLetter(c)) {
buf.append(c);
}

View file

@ -167,7 +167,6 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} else {
writer.docPageClassStart(titleContent, titleNodeSub,Tag.h2);
}
writer.docPageContentStart();
if (!isNodePageMode) {
writeNodeTreePath(bodyEvent);
@ -216,7 +215,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
ApiDocContentWriter writer = event.getWriter();
List<ApiDocNodeWriter> bodyWriterDescriptionLinks = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_LINKS);
List<ApiDocNodeWriter> bodyWriterDescriptionNode = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_NODE);
writer.printTagStart(Tag.div, ApiDocContentCss.description);
//writer.printTagStart(Tag.div, ApiDocContentCss.description);
writer.docPageBlockStart();
if (isPageMode==false) {
if (bodyWriterDescriptionLinks.isEmpty()) {
@ -224,20 +223,39 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
}
for (int i=0;i<bodyWriterDescriptionLinks.size();i++) {
ApiDocNodeWriter nodeWriter = bodyWriterDescriptionLinks.get(i);
writer.printTagStart(Tag.div, ApiDocContentCss.description);
nodeWriter.writeNodeContent(event);
writer.printTagEnd(Tag.div);
if (i+1<bodyWriterDescriptionLinks.size()) {
writer.printTagStart(Tag.div, ApiDocContentCss.description);
writer.printCharacters("&nbsp;");
writer.printTagEnd(Tag.div);
}
}
writer.printTagStartEnd(Tag.hr);
writer.printTagStartEnd(Tag.br); // mmm
writer.printTagStart(Tag.div, ApiDocContentCss.description);
writer.printCharacters("&nbsp;");
writer.printTagEnd(Tag.div);
//writer.printTagStartEnd(Tag.br); // mmm
}
if (bodyWriterDescriptionNode.isEmpty()) {
writer.printTagStart(Tag.div, ApiDocContentCss.description);
defaultWriteNodeDescription(event);
writer.printTagEnd(Tag.div);
}
for (int i=0;i<bodyWriterDescriptionNode.size();i++) {
ApiDocNodeWriter nodeWriter = bodyWriterDescriptionNode.get(i);
writer.printTagStart(Tag.div, ApiDocContentCss.description);
nodeWriter.writeNodeContent(event);
writer.printTagEnd(Tag.div);
if (i+1<bodyWriterDescriptionNode.size()) {
writer.printTagStart(Tag.div, ApiDocContentCss.description);
writer.printCharacters("&nbsp;");
writer.printTagEnd(Tag.div);
}
}
writer.docPageBlockEnd();
writer.printTagEnd(Tag.div); // description
//writer.printTagEnd(Tag.div); // description
}
private void writeNodeSummary(ApiDocWriteEvent<ApiDocNode> event,boolean isPageMode) throws IOException {
@ -427,7 +445,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
ApiDocConcept concept = doc.findConceptByClass(node.getUserData().getClass());
linkHref = buf+"../overview-"+concept.getId()+".html";
}
writer.printHref(linkHref, node.getDescription(), nodeTitle);
writer.printHref(linkHref, nodeTitle, node.getDescription());
writer.printTagEnd(Tag.li);
writer.printTagStart(Tag.li);
@ -720,7 +738,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
writer.printTagStart(Tag.body);
writer.printTagStart(Tag.div,ApiDocContentCss.indexHeader);
writer.printHrefTarget("all"+concept.getId()+"-frame.html", "All "+conceptPlural,ApiDocContentCss.frameNavDetail.name());
writer.printHrefTarget("all"+concept.getId()+"-frame.html", ApiDocContentCss.frameNavDetail.name(), "All " + conceptPlural);
writer.printTagEnd(Tag.div);
writer.printTagStart(Tag.div,ApiDocContentCss.indexContainer);
@ -747,7 +765,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
buf.append("/");
buf.append(ApiDocContentWriter.toSafeUri(node.getId()));
buf.append("-frame.html");
writer.printHrefTarget(buf.toString(), linkName, ApiDocContentCss.frameNavDetail.name());
writer.printHrefTarget(buf.toString(), ApiDocContentCss.frameNavDetail.name(), linkName);
writer.printTagEnd(Tag.li);
}
writer.printTagEnd(Tag.ul);
@ -806,7 +824,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
writer.printTagCharacters(Tag.h1, "All "+conceptPlural, "bar");
} else {
writer.printTagStart(Tag.h1,ApiDocContentCss.bar);
writer.printHrefTarget("index.html", searchNode.getId(),ApiDocContentCss.frameContent.name());
writer.printHrefTarget("index.html", ApiDocContentCss.frameContent.name(), searchNode.getId());
writer.printTagEnd(Tag.h1);
}
@ -854,7 +872,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
}
writer.printTagStart(Tag.li);
if (isFrame) {
writer.printHrefTarget(linkUrl, linkName,ApiDocContentCss.frameContent.name());
writer.printHrefTarget(linkUrl, ApiDocContentCss.frameContent.name(), linkName);
} else {
writer.printHref(linkUrl, linkName);
}
@ -1062,10 +1080,10 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
if (conf.getFramePath()!=null) {
writer.printTagStart(Tag.ul,ApiDocContentCss.navList);
writer.printTagStart(Tag.li);
writer.printHrefTarget(pathPrefix+"index.html?"+conf.getFramePath(), "Frames", "_top");
writer.printHrefTarget(pathPrefix+"index.html?"+conf.getFramePath(), "_top", "Frames");
writer.printTagEnd(Tag.li);
writer.printTagStart(Tag.li);
writer.printHrefTarget(pathPrefix+conf.getFramePath(), "No Frames", "_top");
writer.printHrefTarget(pathPrefix+conf.getFramePath(), "_top", "No Frames");
writer.printTagEnd(Tag.li);
writer.printTagEnd(Tag.ul);
}
@ -1134,7 +1152,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
private void docNavBarListItemHref(ApiDocContentWriter writer, String href, String title, String text, String cssClass, String spanCss, String linkSpace) throws IOException {
writer.printTagStart(Tag.li, cssClass);
writer.printHref(href,title,text,spanCss);
writer.printHref(href, text, title, spanCss);
writer.printCharacters(linkSpace);
writer.printTagEnd(Tag.li);
}

View file

@ -69,6 +69,11 @@ public class ApiDocNode {
return nodes;
}
@SuppressWarnings("unchecked")
public <T> T toUserData(Class<T> type) {
return (T)getUserData();
}
/**
* @return the userData
*/