mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
More jsdoc work, including exporting of templatedocs.
This commit is contained in:
parent
5dd5694e3b
commit
3274102dec
7 changed files with 117 additions and 77 deletions
|
@ -10,7 +10,18 @@
|
|||
# All rights reserved. See LICENSE file for details.
|
||||
|
||||
# Generate documentation
|
||||
#
|
||||
# MODE:
|
||||
# docs Generates the JS API docs
|
||||
# templatedocs Generates the website templates for the online JS API docs
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
MODE="docs"
|
||||
else
|
||||
MODE=$1
|
||||
fi
|
||||
|
||||
cd jsdoc-toolkit
|
||||
java -jar jsrun.jar app/run.js -c=conf/paperjs.conf
|
||||
cd ..
|
||||
java -jar jsrun.jar app/run.js -c=conf/$MODE.conf
|
||||
cd ..
|
|
@ -26,5 +26,8 @@
|
|||
d: "../../out/docs",
|
||||
|
||||
// use this template
|
||||
t: "templates/jsdoc"
|
||||
t: "templates/jsdoc",
|
||||
|
||||
// set variables:
|
||||
D: "renderMode:docs"
|
||||
}
|
33
build/jsdoc-toolkit/conf/templatedocs.conf
Normal file
33
build/jsdoc-toolkit/conf/templatedocs.conf
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
This is an example of one way you could set up a configuration file to more
|
||||
conveniently define some commandline options. You might like to do this if
|
||||
you frequently reuse the same options. Note that you don't need to define
|
||||
every option in this file, you can combine a configuration file with
|
||||
additional options on the commandline if your wish.
|
||||
|
||||
You would include this configuration file by running JsDoc Toolkit like so:
|
||||
java -jar jsrun.jar app/run.js -c=conf/sample.conf
|
||||
|
||||
*/
|
||||
|
||||
{
|
||||
// source files to use
|
||||
_: ['../../src'],
|
||||
|
||||
r: 2,
|
||||
|
||||
// document all functions, even uncommented ones
|
||||
a: false,
|
||||
|
||||
// including those marked @private
|
||||
p: false,
|
||||
|
||||
// use this directory as the output directory
|
||||
d: "../../out/templates",
|
||||
|
||||
// use this template
|
||||
t: "templates/jsdoc",
|
||||
|
||||
// set variables:
|
||||
D: "renderMode:templatedocs"
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
Point
|
||||
Rectangle
|
||||
Size
|
||||
Matrix
|
||||
Color
|
||||
GrayColor
|
||||
RGBColor
|
||||
GradientColor
|
||||
Item
|
||||
PathItem
|
||||
Path
|
||||
CompoundPath
|
||||
TextItem
|
||||
PointText
|
||||
Raster
|
||||
Group
|
||||
Layer
|
||||
PlacedItem
|
||||
Symbol
|
||||
Project
|
||||
ProjectView
|
||||
Segment
|
||||
Curve
|
||||
PathStyle
|
||||
CharacterStyle
|
||||
ParagraphStyle
|
||||
Gradient
|
||||
GradientStop
|
||||
Symbol
|
|
@ -1,14 +1,16 @@
|
|||
/** Called automatically by JsDoc Toolkit. */
|
||||
function publish(symbolSet) {
|
||||
var renderMode = JSDOC.opt.D.renderMode;
|
||||
publish.conf = { // trailing slash expected for dirs
|
||||
ext: '.html',
|
||||
ext: renderMode == 'docs' ? '.html' : '.jstl',
|
||||
outDir: JSDOC.opt.d || SYS.pwd + '../out/jsdoc/',
|
||||
templateDir: JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/',
|
||||
staticDir: (JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/') + 'static/',
|
||||
symbolsDir: 'packages/',
|
||||
srcDir: 'symbols/src/'
|
||||
symbolsDir: renderMode == 'docs' ? 'packages/' : 'paper/',
|
||||
srcDir: 'symbols/src/',
|
||||
renderMode: renderMode
|
||||
};
|
||||
publish.conf.packagesDir = publish.conf.outDir + 'packages/';
|
||||
publish.conf.packagesDir = publish.conf.outDir + publish.conf.symbolsDir;
|
||||
var templatesDir = publish.conf.templateDir + 'templates/';
|
||||
publish.templates = {
|
||||
_class: 'class.tmpl',
|
||||
|
@ -29,12 +31,17 @@ function publish(symbolSet) {
|
|||
publish.templates[i] = new JSDOC.JsPlate(templatesDir +
|
||||
publish.templates[i]);
|
||||
}
|
||||
|
||||
// Copy over the static files
|
||||
Utils.copyDirectory(
|
||||
new java.io.File(publish.conf.staticDir),
|
||||
new java.io.File(publish.conf.outDir)
|
||||
);
|
||||
|
||||
if (renderMode == 'docs') {
|
||||
// Copy over the static files
|
||||
Utils.copyDirectory(
|
||||
new java.io.File(publish.conf.staticDir),
|
||||
new java.io.File(publish.conf.outDir)
|
||||
);
|
||||
} else {
|
||||
Utils.deleteFiles(new File(publish.conf.outDir));
|
||||
new java.io.File(publish.conf.outDir + 'paper/').mkdirs();
|
||||
}
|
||||
|
||||
// used to allow Link to check the details of things being linked to
|
||||
Link.symbolSet = symbolSet;
|
||||
|
@ -77,16 +84,19 @@ function publish(symbolSet) {
|
|||
}
|
||||
|
||||
Link.currentSymbol= symbol;
|
||||
var html = publish.templates.html.process({
|
||||
content: publish.templates._class.process(symbol),
|
||||
title: symbol.alias
|
||||
});
|
||||
var html = publish.templates._class.process(symbol);
|
||||
var name = ((JSDOC.opt.u)? Link.filemap[symbol.alias] : symbol.alias)
|
||||
+ publish.conf.ext;
|
||||
if (renderMode == 'docs') {
|
||||
html = publish.templates.html.process({
|
||||
content: html,
|
||||
title: symbol.alias
|
||||
});
|
||||
}
|
||||
IO.saveFile(publish.conf.packagesDir, name, html);
|
||||
}
|
||||
|
||||
Utils.publishMenu();
|
||||
if (renderMode == 'docs')
|
||||
Utils.publishMenu();
|
||||
}
|
||||
|
||||
var Operator = new function() {
|
||||
|
@ -195,6 +205,17 @@ var Utils = {
|
|||
}
|
||||
},
|
||||
|
||||
deleteFiles: function(path) {
|
||||
if (path.isDirectory()) {
|
||||
var files = path.listFiles();
|
||||
for (var i = 0, l = files.length; i < l; i++) {
|
||||
Utils.deleteFiles(files[i]);
|
||||
}
|
||||
}
|
||||
if (!path['delete']())
|
||||
throw Error('Could not delete ' + path);
|
||||
},
|
||||
|
||||
processGroupTitle: function(str, symbol) {
|
||||
var groupTitle = str.match(/\{@grouptitle ([^}]+)\}/);
|
||||
if (groupTitle) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{! data.classId = data.alias.toLowerCase() !}
|
||||
{!
|
||||
data.classId = data.alias.toLowerCase();
|
||||
var constructors = data.methods.filter(function($){return $.memberOf == data.alias && $.isConstructor});
|
||||
var ownProperties = data.properties.filter(function($){return $.memberOf == data.alias && !$.isNamespace && !$.isStatic && !$.isConstructor});
|
||||
var staticProperties = data.properties.filter(function($){return $.memberOf == data.alias && !$.isNamespace && $.isStatic && !$.isConstructor});
|
||||
|
@ -43,14 +43,14 @@
|
|||
}
|
||||
!}
|
||||
<div class="reference-class">
|
||||
<h1>{+data.alias+}</h1>
|
||||
<if test="publish.conf.renderMode == 'docs'"><h1>{+data.alias+}</h1></if>
|
||||
<if test="inheritedClassLinks.length">
|
||||
<p> Extends {+ inheritedClassLinks.join(', ') +}</p>
|
||||
</if>
|
||||
{+Utils.processInlineTags(data.classDesc)+}
|
||||
</div>
|
||||
<!-- ============================== constructors ========================= -->
|
||||
<if test="!/(Event|Style)/.test(data.alias) && !data.isNamespace && !data.ignore && data.desc.length">
|
||||
<!-- ============================== constructors ========================= -->
|
||||
<div class="reference-members"><h2>Constructors</h2>
|
||||
{+ publish.templates.constructor.process(data) +}
|
||||
<for each="constructor" in="constructors">
|
||||
|
@ -59,8 +59,8 @@
|
|||
</div>
|
||||
</if>
|
||||
|
||||
<!-- ============================== properties ========================= -->
|
||||
<if test="defined(operators)">
|
||||
<!-- ============================== properties ========================= -->
|
||||
<div class="reference-members"><h2>Operators</h2>
|
||||
<for each="member" in="operators">
|
||||
{+ publish.templates.operators.process(member) +}
|
||||
|
@ -76,8 +76,8 @@
|
|||
</div>
|
||||
</if>
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
<if test="defined(ownMethods) && ownMethods.length">
|
||||
<!-- ============================== methods ================================ -->
|
||||
<div class="reference-members"><h2>Functions</h2>
|
||||
<for each="member" in="ownMethods">
|
||||
{+ publish.templates.method.process(member) +}
|
||||
|
@ -92,21 +92,24 @@
|
|||
</div>
|
||||
</if>
|
||||
<for each="inheritedClass" in="inheritedClasses">
|
||||
<!-- ============================== properties ========================= -->
|
||||
<if test="inheritedClass.properties.length">
|
||||
<div class="reference-members"><h2>Properties inherited from {+ new Link().toSymbol(inheritedClass.className) +}</h2>
|
||||
<for each="member" in="inheritedClass.properties">
|
||||
{+ publish.templates.property.process(member) +}
|
||||
</for>
|
||||
</div>
|
||||
</if>
|
||||
<!-- ============================== properties ========================= -->
|
||||
<if test="inheritedClass.methods.length">
|
||||
<div class="reference-members"><h2>Functions inherited from {+ new Link().toSymbol(inheritedClass.className) +}</h2>
|
||||
<for each="member" in="inheritedClass.methods">
|
||||
{+ publish.templates.method.process(member) +}
|
||||
</for>
|
||||
</div>
|
||||
</if>
|
||||
<if test="inheritedClass.properties.length">
|
||||
<!-- =========================== inherited properties ====================== -->
|
||||
<div class="reference-members"><h2>Properties inherited from {+ new Link().toSymbol(inheritedClass.className) +}</h2>
|
||||
<for each="member" in="inheritedClass.properties">
|
||||
{+ publish.templates.property.process(member) +}
|
||||
</for>
|
||||
<p class="footer">Copyright © 21011 <a href="http://www.lehni.org" target="_blank">Jürg Lehni</a> & <a href="http://www.jonathanpuckey.com" target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>
|
||||
</div>
|
||||
</if>
|
||||
<if test="inheritedClass.methods.length">
|
||||
<!-- =========================== inherited methods ========================= -->
|
||||
<div class="reference-members"><h2>Functions inherited from {+ new Link().toSymbol(inheritedClass.className) +}</h2>
|
||||
<for each="member" in="inheritedClass.methods">
|
||||
{+ publish.templates.method.process(member) +}
|
||||
</for>
|
||||
</div>
|
||||
</if>
|
||||
</for>
|
||||
<if test="publish.conf.renderMode == 'docs'">
|
||||
<!-- =========================== copyright notice ========================= -->
|
||||
<p class="footer">Copyright © 21011 <a href="http://www.lehni.org" target="_blank">Jürg Lehni</a> & <a href="http://www.jonathanpuckey.com" target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>
|
||||
</if>
|
|
@ -5,9 +5,7 @@
|
|||
if (data.returns.length == 0)
|
||||
data.returns = [{type: data.memberOf ? data.memberOf : data.alias, desc: ''}];
|
||||
!}
|
||||
<if test="defined(data.groupTitle)">
|
||||
<h3>{+data.groupTitle+}</h3>
|
||||
</if>
|
||||
<if test="defined(data.groupTitle)"><h3>{+data.groupTitle+}</h3></if>
|
||||
<div id="{+constructorId+}" class="member">
|
||||
<div id="{+constructorId+}-link" class="member-link">
|
||||
<a name="{+constructorId+}" href="#" onClick="return toggleMember('{+constructorId+}', false);"><tt><b>{+ name +}</b>{+ Utils.makeSignature(data.params) +}</tt></a>
|
||||
|
@ -23,10 +21,10 @@
|
|||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="member-text">{+Utils.processInlineTags(data.desc)+}
|
||||
{+ publish.templates.parameters.process(data) +}
|
||||
{+ publish.templates.returns.process(data) +}
|
||||
{+ Utils.parseExamples(data) +}
|
||||
{+ publish.templates.seeAlsos.process(data) +}
|
||||
{+ publish.templates.parameters.process(data) +}
|
||||
{+ publish.templates.returns.process(data) +}
|
||||
{+ Utils.parseExamples(data) +}
|
||||
{+ publish.templates.seeAlsos.process(data) +}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue