added function renderApi() which renders the whole application docs into
files. used via webinterface or commandline. changed RegExp: rhino needs global setting as second param in constructor
This commit is contained in:
parent
08d3a94429
commit
98ad7be09b
1 changed files with 26 additions and 8 deletions
|
@ -31,6 +31,27 @@ function getDir (dir, obj) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderApi() {
|
||||||
|
var prefix = this.href ("");
|
||||||
|
this.storePage (this, "main", "", "index.html");
|
||||||
|
this.storePage (this, "prototypes");
|
||||||
|
this.storePage (this, "summary");
|
||||||
|
this.storePage (this, "functionindex");
|
||||||
|
var ct = 4;
|
||||||
|
var arr = this.listChildren ();
|
||||||
|
for (var i=0; i<arr.length; i++) {
|
||||||
|
this.storePage (arr[i], "list", "../");
|
||||||
|
this.storePage (arr[i], "main", "../");
|
||||||
|
ct += 2;
|
||||||
|
var subarr = arr[i].listChildren ();
|
||||||
|
for (var j=0; j<subarr.length; j++) {
|
||||||
|
this.storePage (subarr[j], "main", "../", subarr[j].getElementName () + ".html");
|
||||||
|
ct += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ct;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function storePage (obj, action, backPath, filename) {
|
function storePage (obj, action, backPath, filename) {
|
||||||
if (filename==null)
|
if (filename==null)
|
||||||
|
@ -44,7 +65,7 @@ function storePage (obj, action, backPath, filename) {
|
||||||
f.open ();
|
f.open ();
|
||||||
f.write (str);
|
f.write (str);
|
||||||
f.close ();
|
f.close ();
|
||||||
app.log ("wrote file " + f.toString ());
|
app.log ("wrote file " + f.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,18 +77,15 @@ function getPage (obj, action, backPath) {
|
||||||
// get the baseURI out of the url and replace
|
// get the baseURI out of the url and replace
|
||||||
// it with the given relative prefix
|
// it with the given relative prefix
|
||||||
// (keep anchors in regex!)
|
// (keep anchors in regex!)
|
||||||
var reg = new RegExp ("href=\"" + this.href ("") + "([^\"#]+)([^\"]*)\"");
|
var reg = new RegExp ("href=\"" + this.href ("") + "([^\"#]+)([^\"]*)\"", "gim");
|
||||||
reg.global = true;
|
|
||||||
str = str.replace (reg, "href=\"" + backPath + "$1.html$2\"");
|
str = str.replace (reg, "href=\"" + backPath + "$1.html$2\"");
|
||||||
var reg = new RegExp ("src=\"" + this.href ("") + "([^\"#]+)([^\"]*)\"");
|
var reg = new RegExp ("src=\"" + this.href ("") + "([^\"#]+)([^\"]*)\"", "gim");
|
||||||
reg.global = true;
|
|
||||||
str = str.replace (reg, "src=\"" + backPath + "$1.html$2\"");
|
str = str.replace (reg, "src=\"" + backPath + "$1.html$2\"");
|
||||||
// shorten links, so that function files can move up one directory
|
// shorten links, so that function files can move up one directory
|
||||||
// in the hierarchy
|
// in the hierarchy
|
||||||
var reg = new RegExp ("(prototype_[^/]+/[^/]+)/main.html");
|
var reg = new RegExp ("(prototype_[^/]+/[^/]+)/main.html", "gim");
|
||||||
reg.global = true;
|
|
||||||
str = str.replace (reg, "$1.html");
|
str = str.replace (reg, "$1.html");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue