mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
JSDocs: Move Utils.publishMenu() funcitonality to Render.classes(), but have it not render the template yet, as it is requied by both docs and templatedocs, through the index rendering functions Render.index() (previoulsy Render.menu()) and Render.indexjs (previously Render.packagesjs).
This commit is contained in:
parent
928cd7c39e
commit
2d71ff9c9e
7 changed files with 67 additions and 62 deletions
|
@ -84,9 +84,9 @@ function publish(symbolSet) {
|
|||
}
|
||||
IO.saveFile(publish.conf.packagesDir, name, html);
|
||||
}
|
||||
if (renderMode == 'docs')
|
||||
Utils.publishMenu();
|
||||
if (renderMode == 'templatedocs') {
|
||||
IO.saveFile(publish.conf.outDir, 'packages.js', Render.packagesjs());
|
||||
if (templatedocs) {
|
||||
IO.saveFile(publish.conf.outDir, 'packages.js', Render.indexjs());
|
||||
} else {
|
||||
IO.saveFile(publish.conf.classesDir, 'index.html', Render.index());
|
||||
}
|
||||
}
|
|
@ -14,9 +14,9 @@ var Render = new function() {
|
|||
example: 'example.tmpl',
|
||||
constructor: 'constructor.tmpl',
|
||||
html: 'html.tmpl',
|
||||
menu: 'packages.tmpl',
|
||||
operator: 'operator.tmpl',
|
||||
packagesjs: 'packagesjs.tmpl'
|
||||
index: 'index.tmpl',
|
||||
indexjs: 'indexjs.tmpl',
|
||||
operator: 'operator.tmpl'
|
||||
};
|
||||
publish.classes = [];
|
||||
for (var i in templates) {
|
||||
|
@ -328,11 +328,64 @@ var Render = new function() {
|
|||
html: function(content) {
|
||||
return templates.html.process(content);
|
||||
},
|
||||
menu: function(html) {
|
||||
return templates.menu.process(html);
|
||||
classes: function() {
|
||||
// TODO: Use Template instead?
|
||||
var renderMode = publish.conf.renderMode;
|
||||
load(JSDOC.opt.t + 'classLayout.js');
|
||||
function parseClassNames(classNames) {
|
||||
var out = '';
|
||||
for (var i = 0, l = classNames.length; i < l; i++) {
|
||||
if (typeof classNames[i] == 'string') {
|
||||
var name = classNames[i];
|
||||
out += (name == 'ruler') ? getRuler() : getLink(name);
|
||||
} else {
|
||||
for (var j in classNames[i]) {
|
||||
out += getHeading(j);
|
||||
out += parseClassNames(classNames[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function getLink(name) {
|
||||
var link = name;
|
||||
if (name.indexOf(':') > 0) {
|
||||
var names = name.split(':');
|
||||
name = names[0];
|
||||
link = names[1];
|
||||
}
|
||||
if (renderMode == 'docs') {
|
||||
link += '.html';
|
||||
} else if (renderMode == 'templatedocs') {
|
||||
link = link.toLowerCase();
|
||||
link = '/reference/' + (link == '_global_' ? 'global' : link);
|
||||
}
|
||||
return '<li><a href="' + link + '">' + name + '</a></li>\n';
|
||||
}
|
||||
|
||||
function getRuler() {
|
||||
return '<li><hr /></li>\n';
|
||||
}
|
||||
|
||||
function getHeading(title) {
|
||||
return '<li><h3>' + title + '</h3></li>\n';
|
||||
}
|
||||
var first = true,
|
||||
out = '<ul class="package-classes">';
|
||||
for (var i in classLayout) {
|
||||
out += '<li' + (first ? ' class="first">' : '>');
|
||||
out += '<h2>' + i + '</h2></li>\n';
|
||||
out += parseClassNames(classLayout[i]);
|
||||
first = false;
|
||||
}
|
||||
out += '</ul>';
|
||||
return out;
|
||||
},
|
||||
packagesjs: function() {
|
||||
return templates.packagesjs.process(publish.classes);
|
||||
index: function(html) {
|
||||
return templates.index.process(html);
|
||||
},
|
||||
indexjs: function() {
|
||||
return templates.indexjs.process(publish.classes);
|
||||
}
|
||||
};
|
||||
};
|
|
@ -41,54 +41,6 @@ var Utils = {
|
|||
throw Error('Could not delete ' + path);
|
||||
},
|
||||
|
||||
publishMenu: function() {
|
||||
load(JSDOC.opt.t + 'classLayout.js');
|
||||
function parseClassNames(classNames) {
|
||||
var out = '';
|
||||
for (var i = 0, l = classNames.length; i < l; i++) {
|
||||
if (typeof classNames[i] == 'string') {
|
||||
var name = classNames[i];
|
||||
out += (name == 'ruler') ? getRuler() : getLink(name);
|
||||
} else {
|
||||
for (var j in classNames[i]) {
|
||||
out += getHeading(j);
|
||||
out += parseClassNames(classNames[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function getLink(name) {
|
||||
var link = name;
|
||||
if (name.indexOf(':') > 0) {
|
||||
var names = name.split(':');
|
||||
name = names[0];
|
||||
link = names[1];
|
||||
}
|
||||
return '<li><a href="' + link + '.html">' + name + '</a></li>\n';
|
||||
}
|
||||
|
||||
function getRuler() {
|
||||
return '<li><hr /></li>\n';
|
||||
}
|
||||
|
||||
function getHeading(title) {
|
||||
return '<li><h3>' + title + '</h3></li>\n';
|
||||
}
|
||||
var first = true,
|
||||
out = '<ul class="package-classes">';
|
||||
for (var i in classLayout) {
|
||||
out += '<li' + (first ? ' class="first">' : '>');
|
||||
out += '<h2>' + i + '</h2></li>\n';
|
||||
out += parseClassNames(classLayout[i]);
|
||||
first = false;
|
||||
}
|
||||
out += '</ul>';
|
||||
|
||||
var classesIndex = Render.menu(out);
|
||||
IO.saveFile(publish.conf.packagesDir, 'packages.html', classesIndex);
|
||||
},
|
||||
|
||||
makeSortby: function(attribute) {
|
||||
return function(a, b) {
|
||||
if (a[attribute] != undefined && b[attribute] != undefined) {
|
||||
|
|
|
@ -6,7 +6,7 @@ Paper.js API
|
|||
</title>
|
||||
</head>
|
||||
<frameset cols="230,*">
|
||||
<frame src="packages/packages.html" name="packageListFrame" title="All Packages">
|
||||
<frame src="classes/index.html" name="packageListFrame" title="All Packages">
|
||||
<frame src="about:blank" name="classFrame" title="Class and interface descriptions">
|
||||
</frameset>
|
||||
</html>
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
<body class="reference">
|
||||
<div class="reference-packages">
|
||||
<h1>Paper.js</h1>
|
||||
{+ data +}
|
||||
{+ Render.classes() +}
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
createPackage("", {+ JSON.stringify(data) +}, "", {+ JSON.stringify(Render.classes()) +});
|
|
@ -1 +0,0 @@
|
|||
createPackage("Paper", {+ JSON.stringify(data) +});
|
Loading…
Reference in a new issue