Cleaned up xml leftovers, and changed paths

This commit is contained in:
Anadroid
2020-09-10 17:36:12 +02:00
parent 42b0efb8b8
commit 55994b73d8
14 changed files with 23 additions and 252 deletions
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,7 @@ echo "[REFERENCE GENERATOR] Booting up..."
# PROCESSING_SRC_PATH=./test
PROCESSING_SRC_PATH=../../core/src
PROCESSING_LIB_PATH=../../java/libraries
REFERENCES_OUT_PATH=../../../processing-website
REFERENCES_OUT_PATH=../../../processing-website/content/references/translations/en
# GENERATE REFERENCE ENTRIES AND INDEX THROUGH JAVADOC - BY DAVID WICKS
echo "[REFERENCE GENERATOR] Source Path :: $PROCESSING_SRC_PATH"
@@ -13,20 +13,14 @@ echo "[REFERENCE GENERATOR] Library Path :: $PROCESSING_LIB_PATH"
echo "[REFERENCE GENERATOR] Removing previous version of the ref..."
rm -rf ../../reference
mkdir ../../reference
rm -rf ../../distribution
mkdir ../../distribution
rm -rf $REFERENCES_OUT_PATH/json
mkdir $REFERENCES_OUT_PATH/json
mkdir $REFERENCES_OUT_PATH/json/libraries
mkdir $REFERENCES_OUT_PATH/json/libraries/io
mkdir $REFERENCES_OUT_PATH/json/libraries/net
mkdir $REFERENCES_OUT_PATH/json/libraries/data
mkdir $REFERENCES_OUT_PATH/json/libraries/serial
mkdir $REFERENCES_OUT_PATH/json/libraries/opengl
mkdir $REFERENCES_OUT_PATH/json/libraries/sound
mkdir $REFERENCES_OUT_PATH/json/libraries/video
rm -rf $REFERENCES_OUT_PATH
mkdir $REFERENCES_OUT_PATH
mkdir $REFERENCES_OUT_PATH/processing
mkdir $REFERENCES_OUT_PATH/io
mkdir $REFERENCES_OUT_PATH/net
mkdir $REFERENCES_OUT_PATH/serial
mkdir $REFERENCES_OUT_PATH/sound
mkdir $REFERENCES_OUT_PATH/video
echo "[REFERENCE GENERATOR] Generating new javadocs..."
javadoc -doclet ProcessingWeblet \
@@ -62,15 +62,6 @@ public class ProcessingWeblet extends Standard {
// see: /api_en/include
System.out.println("===Source code @webref files written.===");
if (!Shared.i().getIncludeDirectory().equals(""))
{
System.out.println("\n===Writing XML-sourced reference.===");
//XMLReferenceWriter.write( Shared.i().getIncludeDirectory(), indexWriter);
System.out.println("===Include directory files written.===");
}
// write out the index file
@@ -10,12 +10,6 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.TimeZone;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@@ -37,7 +31,7 @@ public class BaseWriter {
// Some utilities
public final static String MODE_JAVASCRIPT = "js";
public final static String jsonDir = "../../../processing-website/json/";
public final static String jsonDir = "../../../processing-website/content/references/translations/en/processing/";
public BaseWriter()
{
@@ -78,7 +72,11 @@ public class BaseWriter {
//add package name to anchor
String[] parts = doc.containingPackage().name().split("\\.");
String pkg = parts[parts.length-1] + "/";
ret = "libraries/" + pkg + ret;
if (pkg.equals("data/") || pkg.equals("opengl/"))
ret = ret;
else
ret = pkg + ret;
}
return ret;
@@ -597,49 +595,7 @@ public class BaseWriter {
// add link to each @see_external item
for( Tag tag : doc.tags( Shared.i().getSeeAlsoTagName() ) )
{
// get xml for method
String filename = tag.text() + ".json";
String basePath = Shared.i().getJSONDirectory();
File f = new File( basePath + filename );
if( ! f.exists() )
{
basePath = Shared.i().getIncludeDirectory();
f = new File( basePath + filename );
}
if( f.exists() )
{
Document xmlDoc = Shared.loadXmlDocument( f.getPath() );
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
try
{
String name = (String) xpath.evaluate("//name", xmlDoc, XPathConstants.STRING);
// get anchor from original filename
String path = f.getAbsolutePath();
String anchorBase = path.substring( path.lastIndexOf("/")+1, path.indexOf(".xml"));
if( name.endsWith("()") )
{
if( !anchorBase.endsWith("_" ) )
{
anchorBase += "_";
}
}
String anchor = anchorBase;
// get method name from xml
// get anchor from method name
HashMap<String, String> map = new HashMap<String, String>();
map.put( "anchor", anchor );
related.add( anchor );
} catch (XPathExpressionException e)
{
e.printStackTrace();
}
}
related.add( tag.text().concat("_") );
}
return related;
@@ -1,130 +0,0 @@
package writers;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.MethodDoc;
import com.sun.javadoc.PackageDoc;
/**
* Writes the index page of libraries.
* Also grabs the xml files in lib/dir/events
* and sends them to the XMLReferenceWriter
*
* @author davidwicks
*
*/
public class LibraryIndexWriter extends IndexWriter {
HashMap<String,String> sections;
ArrayList<String> classes;
ArrayList<String> events;
TemplateWriter templateWriter;
public LibraryIndexWriter(PackageDoc doc, String outputPath){
sections = new HashMap<String,String>();
classes = new ArrayList<String>();
events = new ArrayList<String>();
templateWriter = new TemplateWriter();
writePartials(doc, outputPath);
}
private void writePartials(PackageDoc doc, String outputPath){
for( ClassDoc cd : doc.allClasses() ){
addItem(cd);
}
}
private void getXMLInformation(String path){
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder;
Document xmlDoc = null;
try {
builder = factory.newDocumentBuilder();
xmlDoc = builder.parse(path);
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("WARNING: no index.xml file found at: " + path );
return;
}
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
try {
String name = (String) xpath.evaluate("//libraryName", xmlDoc, XPathConstants.STRING);
String desc = (String) xpath.evaluate("//libraryDescription", xmlDoc, XPathConstants.STRING);
sections.put("libraryname", name);
sections.put("librarydescription", desc);
} catch (XPathExpressionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private String explode(ArrayList<String> array){
String ret = "";
Collections.sort(array);
for(String s : array){
ret += s + "\n";
}
return ret;
}
public void write (String path) throws IOException {
templateWriter.write("library.index.template.html", sections, path+"index.html");
}
public void addItem (ClassDoc doc) {
ArrayList<HashMap<String, String>> methods = new ArrayList<HashMap<String,String>>();
HashMap<String, String> cmap = new HashMap<String, String>();
HashMap<String, String> map = new HashMap<String, String>();
map.put("name", getName(doc));
map.put("anchor", getLocalAnchor(doc));
methods.add(map);
for(MethodDoc m : doc.methods()){
if(Shared.i().isWebref(m)){
HashMap<String, String> methodMap = new HashMap<String, String>();
methodMap.put("name", getName(m));
methodMap.put("anchor", getLocalAnchor(m));
methods.add(methodMap);
}
}
cmap.put("methods", templateWriter.writeLoop("related.partial.html", methods));
cmap.put("classname", getName(doc) + " Class");
cmap.put("classdescription", getBriefDescriptionFromSource(doc));
classes.add(templateWriter.writePartial("library.section.partial.html", cmap));
}
public void addEvent(String name, String anchor){
HashMap<String, String> map = new HashMap<String, String>();
map.put("name", name);
map.put("anchor", getAnchorFromName(name));
events.add(templateWriter.writePartial("related.partial.html", map) + "\n");
}
}
@@ -10,11 +10,12 @@ import com.sun.javadoc.PackageDoc;
public class LibraryWriter extends BaseWriter {
PackageDoc doc;
String pkg;
LibraryIndexWriter indexWriter;
String dir;
static TemplateWriter templateWriter;
static ArrayList<String> writtenLibraries;
private String libDir ="../../../processing-website/content/references/translations/en/";
public LibraryWriter(){
if(templateWriter == null ){
@@ -38,10 +39,12 @@ public class LibraryWriter extends BaseWriter {
String[] parts = doc.name().split("\\.");
String pkg = parts[parts.length-1] + "/";
dir = jsonDir + "libraries/"+pkg;
if (pkg.equals("data/") || pkg.equals("opengl/"))
dir = jsonDir;
else
dir = libDir + pkg;
Shared.i().createOutputDirectory(dir);
indexWriter = new LibraryIndexWriter(doc, dir);
//grab all relevant information for the doc
for( ClassDoc classDoc : doc.allClasses() ){
@@ -58,19 +61,4 @@ public class LibraryWriter extends BaseWriter {
}
}
private void writeRemainingXml( String xmlDir )
{
File directory = new File( xmlDir );
File[] files = directory.listFiles();
for( File f : files )
{
if( f.getAbsolutePath().endsWith("xml") )
{
// try writing everything (will not overwrite any existing docs)
//XMLReferenceWriter.parseFile( f.getAbsoluteFile(), dir, indexWriter );
}
}
}
}
@@ -4,12 +4,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import com.sun.javadoc.Doc;
import com.sun.javadoc.ProgramElementDoc;
@@ -32,7 +27,7 @@ public class Shared {
private String templateDirectory = "templates";
private String exampleDirectory = "web_examples";
private String includeDirectory = "include";
private String jsonDirectory ="../../../processing-website/json/";
private String jsonDirectory ="../../../processing-website/content/references/translations/en/processing/";
boolean noisy = false;
public ArrayList<String> corePackages;
@@ -183,29 +178,6 @@ public class Shared {
f.mkdirs();
}
public static Document loadXmlDocument( String path )
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder;
Document doc = null;
try {
builder = factory.newDocumentBuilder();
doc = builder.parse( path );
} catch (ParserConfigurationException e) {
System.out.println("Failed to parse " + path );
System.out.println( e.getLocalizedMessage() );
} catch (SAXException e) {
System.out.println("Failed to parse " + path );
System.out.println( e.getLocalizedMessage() );
} catch (IOException e) {
System.out.println("Failed to parse " + path );
System.out.println( e.getLocalizedMessage() );
}
return doc;
}
public void createBaseDirectories(){
File f = new File(getLocalOutputDirectory());
f.mkdirs();