Merge remote branch 'origin/master'

This commit is contained in:
Jonathan Puckey 2011-06-09 23:21:21 +02:00
commit d688faf805
24 changed files with 7121 additions and 174 deletions

View file

@ -1,7 +1,7 @@
/** Handle the creation of HTML links to documented symbols.
@constructor
*/
function Link() {
function Link(asCode) {
this.alias = "";
this.src = "";
this.file = "";
@ -9,6 +9,7 @@ function Link() {
this.innerName = "";
this.classLink = false;
this.targetName = "";
this.asCode = asCode;
this.target = function(targetName) {
if (defined(targetName)) this.targetName = targetName;
@ -131,15 +132,18 @@ Link.prototype._makeSymbolLink = function(alias, parameters) {
if (parameters) {
parameters = parameters.replace(/\,([^\s])/, ', $1')
}
var linkText = (this.text || (alias == '_global_' && publish.conf.globalName
|| alias)) + (parameters || '');
// if there is no symbol by that name just return the name unaltered
if (!linkTo) {
return this.text || alias + (parameters || '');
return linkText;
} else {
// it's a symbol in another file
if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property
linkPath= (Link.filemap) ? Link.filemap[linkTo.memberOf] :
escape(linkTo.memberOf) || "global";
escape(linkTo.memberOf) || "_global_";
linkPath += publish.conf.ext + "#" + Link.symbolNameToLinkName(linkTo).toLowerCase();
if (parameters) {
linkPath += '-' + parameters.replace(/[()]+/g, '').split(', ').join('-').toLowerCase();
@ -150,8 +154,6 @@ Link.prototype._makeSymbolLink = function(alias, parameters) {
}
linkPath = linkBase + linkPath
}
var linkText= (this.text || alias) + (parameters || '');
var link = {
linkPath: linkPath,
@ -172,7 +174,12 @@ Link.prototype._makeSymbolLink = function(alias, parameters) {
var linkName = link.linkPath.replace(/^[^#]+#/, '');
onClick = " onclick=\"return toggleMember('" + linkName + "', true);\"";
}
var html = "<a href=\""+link.linkPath+link.linkInner+"\""+target+onClick+"><tt>"+link.linkText+"</tt></a>";
var text = link.linkText;
// TODO: tt is gone in HTML5. Instead we should give these links and code
// elements a special class so they can be styled through CSS.
if (this.asCode)
text = "<tt>" + text + "</tt>";
var html = "<a href=\""+link.linkPath+link.linkInner+"\""+target+onClick+">" + text + "</a>";
if (this.prefix || this.suffix)
html = (this.prefix || '') + html + (this.suffix || '');
return html;

View file

@ -1,5 +1,5 @@
var classLayout = {
'Paper.js': ['Global Scope:_global_'],
'_global_': ['Global Scope:_global_'],
'Basic Types': ['Point', 'Size', 'Rectangle', 'Matrix'],
'Items': ['Item', 'Layer', 'Group', 'Raster', 'PlacedSymbol'],
'Paths': ['Path', 'CompoundPath', 'Segment', 'Curve', 'PathStyle', 'ruler',

View file

@ -6,25 +6,25 @@ load(JSDOC.opt.t + 'src/Render.js');
function publish(symbolSet) {
var renderMode = JSDOC.opt.D.renderMode;
var templatedocs = renderMode == 'templatedocs';
var extension = templatedocs ? '.jstl' : '.html';
var templates = renderMode == 'templates';
var extension = templates ? '.jstl' : '.html';
var templateDir = JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/';
var outDir = JSDOC.opt.d || SYS.pwd + '../out/jsdoc/';
publish.conf = { // trailing slash expected for dirs
// Use no extensions in links for templatedocs
ext: templatedocs ? '' : extension,
// Use no extensions in links for templates
ext: templates ? '' : extension,
outDir: outDir,
templateDir: templateDir,
staticDir: templateDir + 'static/',
classesDir: outDir + 'classes/',
symbolsDir: templatedocs ? 'reference/' : 'classes/',
symbolsDir: templates ? 'reference/' : 'classes/',
srcDir: 'symbols/src/',
renderMode: renderMode,
globalName: 'Global Scope'
};
Link.base = templatedocs ? '/' : '../';
Link.base = templates ? '/' : '../';
if (renderMode == 'docs') {
// Copy over the static files
@ -32,13 +32,11 @@ function publish(symbolSet) {
new java.io.File(publish.conf.staticDir),
new java.io.File(publish.conf.outDir)
);
// Create the classes directory
new java.io.File(publish.conf.classesDir).mkdir();
} else {
Utils.deleteFiles(new File(publish.conf.outDir));
new java.io.File(publish.conf.classesDir).mkdirs();
}
// Create the classes directory
new java.io.File(publish.conf.classesDir).mkdirs();
// used to allow Link to check the details of things being linked to
Link.symbolSet = symbolSet;
@ -50,24 +48,25 @@ function publish(symbolSet) {
classes = symbols.filter(Utils.isaClass).sort(aliasSort);
// create a filemap in which outfiles must be to be named uniquely, ignoring case
// Since we want lowercase links in templatedocs, we always use this
if (JSDOC.opt.u || templatedocs) {
var filemapCounts = {};
Link.filemap = {};
for (var i = 0, l = classes.length; i < l; i++) {
var alias = classes[i].alias,
lcAlias = alias.toLowerCase();
if (!filemapCounts[lcAlias]) {
filemapCounts[lcAlias] = 1;
} else {
filemapCounts[lcAlias]++;
}
// Use lowercase links for templatedocs
var linkAlias = templatedocs ? lcAlias : alias;
Link.filemap[alias] = filemapCounts[lcAlias] > 1
? linkAlias + '_' + filemapCounts[lcAlias] : linkAlias;
// Since we want lowercase links in templates, we always use this
var filemapCounts = {};
Link.filemap = {};
for (var i = 0, l = classes.length; i < l; i++) {
var alias = classes[i].alias,
lcAlias = alias.toLowerCase();
if (!filemapCounts[lcAlias]) {
filemapCounts[lcAlias] = 1;
} else {
filemapCounts[lcAlias]++;
}
// Use lowercase links for templates
var linkAlias = templates ? lcAlias : alias;
// Rename _global_.html to global.html
if (linkAlias == '_global_')
linkAlias = 'global';
Link.filemap[alias] = filemapCounts[lcAlias] > 1
? linkAlias + '_' + filemapCounts[lcAlias] : linkAlias;
}
// create each of the class pages
@ -81,10 +80,9 @@ function publish(symbolSet) {
method.isOperator = Operator.isOperator(method);
}
Link.currentSymbol= symbol;
Link.currentSymbol = symbol;
var html = Render._class(symbol);
var name = ((JSDOC.opt.u)? Link.filemap[symbol.alias] : symbol.alias)
+ extension;
var name = Link.filemap[symbol.alias] + extension;
if (renderMode == 'docs') {
html = Render.html({
content: html,
@ -93,8 +91,8 @@ function publish(symbolSet) {
}
IO.saveFile(publish.conf.classesDir, name, html);
}
if (templatedocs) {
IO.saveFile(publish.conf.outDir, 'packages.js', Render.indexjs());
if (templates) {
IO.saveFile(publish.conf.outDir, 'packages.js', Render.packages());
} else {
IO.saveFile(publish.conf.classesDir, 'index.html', Render.index());
}

View file

@ -15,7 +15,7 @@ var Render = new function() {
constructor: 'constructor.tmpl',
html: 'html.tmpl',
index: 'index.tmpl',
indexjs: 'indexjs.tmpl',
packages: 'packages.tmpl',
operator: 'operator.tmpl'
};
publish.classes = [];
@ -35,7 +35,7 @@ var Render = new function() {
// {@link ...} -> html links
str = str.replace(/\{@link ([^} ]+) ?\}/gi,
function(match, symbolName) {
return new Link().toSymbol(symbolName.replace(/[\^]/g, '-'));
return new Link(true).toSymbol(symbolName.replace(/[\^]/g, '-'));
}
);
// {@code ...} -> code blocks
@ -142,7 +142,7 @@ var Render = new function() {
};
param.inheritedLinks = [];
for (var i in param.inheritedClasses) {
param.inheritedLinks.push('<b>' + new Link().toSymbol(i) + '</b>');
param.inheritedLinks.push('<b>' + new Link(true).toSymbol(i) + '</b>');
}
param.inheritedLinks = param.inheritedLinks.join(', ');
// Add the grouped operators to param:
@ -157,8 +157,8 @@ var Render = new function() {
param.operators[name].push(operator);
}
}
var name = param.name == '_global_'
? publish.conf.globalName : param.name;
var name = param.name == '_global_' && publish.conf.globalName
|| param.name;
publish.curClass = {
name: name,
index: {
@ -234,7 +234,7 @@ var Render = new function() {
name: symbol.name,
description: processInlineTags(symbol.desc,
{stripParagraphs: true}),
typeLink: new Link().toSymbol(symbol.type),
typeLink: new Link(true).toSymbol(symbol.type),
symbol: symbol
});
},
@ -271,7 +271,7 @@ var Render = new function() {
name: symbol.name,
description: processInlineTags(symbol.desc,
{stripParagraphs: true}),
typeLink: new Link().toSymbol(symbol.type),
typeLink: new Link(true).toSymbol(symbol.type),
symbol: symbol
});
},
@ -329,8 +329,10 @@ var Render = new function() {
return templates.html.process(content);
},
classes: function() {
// TODO: Use Template instead?
// TODO: Use a template instead?
var renderMode = publish.conf.renderMode;
var out = '<ul class="package-classes">';
load(JSDOC.opt.t + 'classLayout.js');
function parseClassNames(classNames) {
var out = '';
@ -347,6 +349,7 @@ var Render = new function() {
}
return out;
}
function getLink(name) {
var link = name;
if (name.indexOf(':') > 0) {
@ -354,13 +357,7 @@ var Render = new function() {
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';
return '<li>' + new Link(false).toSymbol(link) + '</li>\n';
}
function getRuler() {
@ -370,22 +367,28 @@ var Render = new function() {
function getHeading(title) {
return '<li><h3>' + title + '</h3></li>\n';
}
var first = true,
out = '<ul class="package-classes">';
var first = true;
for (var i in classLayout) {
out += '<li' + (first ? ' class="first">' : '>');
out += '<h2>' + i + '</h2></li>\n';
if (i != '_global_') {
out += '<li' + (first ? ' class="first">' : '>\n');
out += '<h2>' + i + '</h2>\n';
out += '<ul>\n';
}
out += parseClassNames(classLayout[i]);
if (i != '_global_') {
out += '</ul>\n';
}
first = false;
}
out += '</ul>';
return out;
return out + '</ul>';
},
index: function(html) {
return templates.index.process(html);
},
indexjs: function() {
return templates.indexjs.process(publish.classes);
packages: function() {
return templates.packages.process(publish.classes);
}
};
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 B

View file

@ -106,5 +106,5 @@ span.js-variable {
}
span.js-variabledef,
span.js-localvariable {
color: #3a4a64 /*#687687;*/
color: #3a4a64;
}

View file

@ -0,0 +1,53 @@
.paperscript .button {
display: none;
position: relative; /* position (top / right) relative to paperscriptcontainer */
float: right; /* align right as block */
font-size: 11px;
line-height: 16px;
padding: 2px 6px;
margin-bottom: -20px; /* move canvas up by 16px (height) + 2 * 2px (padding) */
top: 8px; /* margin to top */
right: 8px; /* margin to right */
background: #eee;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
z-index: 1;
}
.paperscript .source {
overflow: auto;
border: 1px solid #999;
}
.paperscript:hover .button {
display: block;
}
.paperscript .button:hover {
background: #ddd;
cursor: pointer;
}
.paperscript .CodeMirror {
margin-bottom: 0; /* Override any potential bottom margins again */
}
.paperscript .CodeMirror-gutter-text,
.paperscript .CodeMirror-lines {
padding-top: 10px;
padding-bottom: 10px;
}
.paperscript .canvas {
line-height: 0; /* prevent weird 5px padding under canvas elements */
}
.paperscript .canvas.border canvas {
border: 1px solid #999;
}
.paperscript.split .canvas {
border: 1px solid #999;
border-top: 0;
}

View file

@ -1,12 +1,12 @@
/* These styles are shared with the server version of docs */
.reference h1, .reference h2, .reference h3 {
font-size: 12px;
font-size: 13px;
font-weight: normal;
display: block;
height: 17px;
margin: 0 0 16px 0;
height: 18px; /* -2px so border-bottom aligns with contained links */
border-bottom: 1px solid;
margin-top: 0;
margin-bottom: 16px;
}
.reference h3 {
@ -14,13 +14,18 @@
border-bottom-style: dotted;
}
.reference a tt {
line-height: 18px;
}
/*
.reference a tt,
.reference a tt b {
padding-bottom: 1px;
}
*/
.reference pre {
margin: 0 0 20px 0;
.reference p {
margin: 0 0 16px 0;
}
.reference ul {
@ -58,12 +63,8 @@
list-style-image: none; /* needed for ie 6 */
}
.reference-end {
height: 600px;
}
.reference-members {
padding-bottom: 16px;
margin-bottom: 16px;
}
.member-group-text {
@ -94,6 +95,18 @@
.member-text {
border-top: 1px dashed #999;
padding: 10px 10px 0 10px;
margin-bottom: -6px; /* Compensate margins of p and ul to end up with 10px */
}
.reference ul,
.reference .paperscript,
.reference .CodeMirror {
margin-top: -8px; /* Move half way up close to previous paragraph */
margin-bottom: 16px;
}
.reference ul {
margin-top: 0; /* Clear the above -10px for ul again */
}
.member-link {
@ -106,20 +119,13 @@
padding-left: 30px;
}
.member-text ul {
padding-bottom: 10px;
}
ul.package-classes {
.package-classes {
padding-bottom: 4px;
}
.package-classes li {
.package-classes ul {
margin-left: 10px;
}
.package-classes li h2 {
margin-left: -10px;
margin-bottom: 10px;
}
.reference h2 a {

View file

@ -12,7 +12,7 @@ body {
}
select, input, textarea {
font-size: 12px;
font-size: 11px;
margin: 0;
color: #000;
}
@ -44,7 +44,7 @@ p {
ul {
padding: 0;
margin: 0 0 20px 16px;
list-style: disc outside url(../assets/bullet.gif);
list-style: disc outside url(assets/bullet.gif);
}
ol {
@ -84,55 +84,3 @@ ol {
.footer {
margin-top: 20px;
}
/* PaperScript */
.paperscript {
margin-bottom: 20px;
}
.paperscript .button {
display: none;
position: relative; /* position (top / right) relative to paperscriptcontainer */
float: right; /* align right as block */
font-size: 11px;
line-height: 16px;
padding: 2px 6px;
margin-bottom: -20px; /* move canvas up by 16px (height) + 2 * 2px (padding) */
top: 8px; /* margin to top */
right: 8px; /* margin to right */
background: #eee;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
z-index: 1;
}
.paperscript .source {
overflow: auto;
border: 1px solid #999;
}
.paperscript:hover .button {
display: block;
}
.paperscript .button:hover {
background: #ddd;
cursor: pointer;
}
.paperscript .CodeMirror-gutter-text,
.paperscript .CodeMirror-lines {
padding-top: 10px;
padding-bottom: 10px;
}
.paperscript .canvas {
line-height: 0; /* prevent weird 5px padding under canvas elements */
}
.paperscript.split .canvas {
border: 1px solid #999;
border-top: 0;
}

File diff suppressed because one or more lines are too long

View file

@ -48,7 +48,6 @@ Code = HtmlElement.extend({
}
});
PaperScript = HtmlElement.extend({
_class: 'paperscript',
@ -176,45 +175,56 @@ PaperScript = HtmlElement.extend({
}
});
$document.addEvent('domready', function() {
var h = unescape(document.location.hash);
if (h) scrollToElement(h.substring(1));
});
var lastMemberId = null;
function toggleMember(id, scrollTo) {
function toggleMember(id, scrollTo, dontScroll) {
var link = $('#' + id + '-link');
if (!link)
return true;
var desc = $('#' + id + '-description');
var v = !link.hasClass('hidden');
// Retrieve y-offset before any changes, so we can correct scrolling after
var offset = (v ? link : desc).getOffset().y;
if (lastMemberId && lastMemberId != id) {
var prevId = lastMemberId;
lastMemberId = null;
toggleMember(prevId);
toggleMember(prevId, false, true);
}
var link = $('#' + id + '-link');
if (link) {
var desc = $('#' + id + '-description');
var v = !link.hasClass('hidden');
lastMemberId = v && id;
link.modifyClass('hidden', v);
desc.modifyClass('hidden', !v);
if (!desc.editor && v) {
desc.editor = $$('pre.code, .paperscript', desc).each(function(code) {
code.initialize();
});
}
if (scrollTo)
scrollToMember(id);
return false;
lastMemberId = v && id;
link.modifyClass('hidden', v);
desc.modifyClass('hidden', !v);
if (!dontScroll) {
// Correct scrolling relatively to where we are, by checking the amount
// the element has shifted due to the above toggleMember call, and
// correcting by 11px offset, caused by 1px border and 10px padding.
var scroll = $window.getScrollOffset();
$window.setScrollOffset(scroll.x, scroll.y
+ (v ? desc : link).getOffset().y - offset + 11 * (v ? 1 : -1));
}
return true;
if (!desc.editor && v) {
desc.editor = $$('pre.code, .paperscript', desc).each(function(code) {
code.initialize();
});
}
if (scrollTo)
scrollToMember(id);
return false;
}
function scrollToElement(id) {
var e = $('#' + id + '-member');
if (e) {
var offs = e.getOffset();
$window.setScrollOffset(offs);
if (e.hasClass('member'))
toggleMember(id);
var offs = e.getOffset();
$window.setScrollOffset(offs);
} else {
document.location.hash = id;
window.location.hash = id;
}
}
$document.addEvent('domready', function() {
var h = unescape(document.location.hash);
if (h) scrollToElement(h.substring(1));
if (window.paper)
paper.load();
});

View file

@ -1,5 +1,5 @@
<div class="reference-class">
<if test="publish.conf.renderMode == 'docs'"><h1>{+ data.name == '_global_' ? publish.conf.globalName : data.name +}</h1></if>
<if test="publish.conf.renderMode == 'docs'"><h1>{+ data.name == '_global_' && publish.conf.globalName || data.name +}</h1></if>
<if test="data.inheritedLinks">
<p> Extends {+ data.inheritedLinks +}</p>
</if>
@ -49,7 +49,7 @@
<for each="inheritedClass" in="data.inheritedClasses">
<if test="inheritedClass.properties.length">
<!-- =========================== inherited properties ====================== -->
<div class="reference-members"><h2>Properties inherited from {+ new Link().toSymbol(inheritedClass.className) +}</h2>
<div class="reference-members"><h2>Properties inherited from {+ new Link(true).toSymbol(inheritedClass.className) +}</h2>
<for each="member" in="inheritedClass.properties">
{+ Render.property(member, true) +}
</for>
@ -57,7 +57,7 @@
</if>
<if test="inheritedClass.methods.length">
<!-- =========================== inherited methods ========================= -->
<div class="reference-members"><h2>Functions inherited from {+ new Link().toSymbol(inheritedClass.className) +}</h2>
<div class="reference-members"><h2>Functions inherited from {+ new Link(true).toSymbol(inheritedClass.className) +}</h2>
<for each="member" in="inheritedClass.methods">
{+ Render.method(member, true) +}
</for>

View file

@ -1,4 +1,6 @@
<p>
<b>Example</b> <if test="data.description.length">{+ '&mdash; ' + data.description +}</if>
</p>
<if test="data.paperScript">
<div class="paperscript <if test="data.paperScript.mode">{+ data.paperScript.mode +}</if>">
<if test="data.paperScript.source != 'false'"><div class="button">{+ data.paperScript.mode == 'source' ? 'Source' : 'Run' +}</div></if>
@ -9,7 +11,5 @@
</div>
</if>
<if test="!data.paperScript">
<div class='paperscript'>
<pre class="code">{+ data.code +}</pre>
</div>
</if>

View file

@ -5,6 +5,7 @@
<base target="classFrame">
<link rel="stylesheet" href="../resources/css/reference.css" type="text/css">
<link rel="stylesheet" href="../resources/css/style.css" type="text/css">
<link rel="stylesheet" href="../resources/css/paperscript.css" type="text/css">
<link rel="stylesheet" href="../resources/css/codemirror.css" type="text/css">
<script src="../resources/js/bootstrap.js" type="text/javascript"></script>
<script src="../resources/js/paper.js" type="text/javascript"></script>

View file

@ -30,7 +30,7 @@
</if>
<ul><b>Type:</b>
<li>
{+new Link().toSymbol(data.symbol.type)+}
{+new Link(true).toSymbol(data.symbol.type)+}
</li>
</ul>
{+ Render.seeAlsos(data.symbol) +}

View file

@ -1,5 +1,5 @@
<if test="data.see.length">
<p><b>See also:</b>
<for each="item" in="data.see"><if test="$item_i > 0">, </if><tt>{+ new Link().toSymbol(item) +}</tt></for>
<for each="item" in="data.see"><if test="$item_i > 0">, </if><tt>{+ new Link(true).toSymbol(item) +}</tt></for>
</p>
</if>

View file

@ -101,7 +101,7 @@ var Raster = this.Raster = Item.extend({
},
/**
* Pixels per inch of the raster at it's current size.
* Pixels per inch of the raster at its current size.
*
* @type Size
* @bean