mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
More docs rendering work.
This commit is contained in:
parent
f9d9847320
commit
41925ea990
5 changed files with 64 additions and 12 deletions
|
@ -59,7 +59,7 @@
|
||||||
<if test="inheritedClassLinks.length">
|
<if test="inheritedClassLinks.length">
|
||||||
<p> Extends {+ inheritedClassLinks.join(', ') +}</p>
|
<p> Extends {+ inheritedClassLinks.join(', ') +}</p>
|
||||||
</if>
|
</if>
|
||||||
<p>{+processInlineTags(data.classDesc)+}</p>
|
{+processInlineTags(data.classDesc)+}
|
||||||
</div>
|
</div>
|
||||||
<!-- ============================== constructors ========================= -->
|
<!-- ============================== constructors ========================= -->
|
||||||
<if test="!/(Event|Style)/.test(data.alias)">
|
<if test="!/(Event|Style)/.test(data.alias)">
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
<div class="member-close"><input type="button" value="Close" onClick="toggleMember('{+data.classId+}', false);"></div>
|
<div class="member-close"><input type="button" value="Close" onClick="toggleMember('{+data.classId+}', false);"></div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="member-text"><p>{+processInlineTags(data.desc)+}</p>
|
<div class="member-text">{+processInlineTags(data.desc)+}
|
||||||
<if test="data.example.length">
|
<if test="data.example.length">
|
||||||
<for each="example" in="data.example">
|
<for each="example" in="data.example">
|
||||||
<pre>{+example+}</pre>
|
<pre>{+example+}</pre>
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
<ul><b>Returns:</b>
|
<ul><b>Returns:</b>
|
||||||
<li>
|
<li>
|
||||||
<for each="item" in="data.returns">
|
<for each="item" in="data.returns">
|
||||||
<dd>{+((item.type)?"<span class=\"light fixedFont\">{"+(new Link().toSymbol(item.type))+"}</span> " : "")+}{+processInlineTags(item.desc)+}</dd>
|
<dd>{+((item.type)?"<span class=\"light fixedFont\">{"+(new Link().toSymbol(item.type))+"}</span> " : "")+}{+processInlineTags(item.desc, { stripParagraphs: true })+}</dd>
|
||||||
</for>
|
</for>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -22,14 +22,14 @@
|
||||||
<div class="member-close"><input type="button" value="Close" onClick="toggleMember('{+ memberId +}', false);"></div>
|
<div class="member-close"><input type="button" value="Close" onClick="toggleMember('{+ memberId +}', false);"></div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="member-text"><p>{+processInlineTags(data.desc)+}</p>
|
<div class="member-text">{+processInlineTags(data.desc)+}
|
||||||
{+ new JSDOC.JsPlate(publish.conf.templatesDir+"examples.tmpl").process(data) +}
|
{+ new JSDOC.JsPlate(publish.conf.templatesDir+"examples.tmpl").process(data) +}
|
||||||
{+ new JSDOC.JsPlate(publish.conf.templatesDir+"parameters.tmpl").process(data) +}
|
{+ new JSDOC.JsPlate(publish.conf.templatesDir+"parameters.tmpl").process(data) +}
|
||||||
<if test="data.returns.length">
|
<if test="data.returns.length">
|
||||||
<ul><b>Returns:</b>
|
<ul><b>Returns:</b>
|
||||||
<for each="item" in="data.returns">
|
<for each="item" in="data.returns">
|
||||||
<li>
|
<li>
|
||||||
<tt><if test="defined(item.type)">{+ new Link().toSymbol(item.type) +}<if test="item.desc"> — </if></if>{+processInlineTags(item.desc)+}</tt>
|
<tt><if test="defined(item.type)">{+ new Link().toSymbol(item.type) +}<if test="item.desc"> — </if></if>{+processInlineTags(item.desc, { stripParagraphs: true })+}</tt>
|
||||||
</li>
|
</li>
|
||||||
</for>
|
</for>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -34,12 +34,12 @@
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<if test="operator.type">
|
<if test="operator.type">
|
||||||
<div class="member-text"><p>{+processInlineTags(operator.desc)+}</p>
|
<div class="member-text">{+processInlineTags(operator.desc)+}
|
||||||
{+ new JSDOC.JsPlate(publish.conf.templatesDir+"examples.tmpl").process(operator) +}
|
{+ new JSDOC.JsPlate(publish.conf.templatesDir+"examples.tmpl").process(operator) +}
|
||||||
<ul><b>Returns:</b>
|
<ul><b>Returns:</b>
|
||||||
<for each="item" in="operator.returns">
|
<for each="item" in="operator.returns">
|
||||||
<li>
|
<li>
|
||||||
<tt><if test="defined(item.type)">{+ new Link().toSymbol(item.type) +} — </if>{+processInlineTags(item.desc)+}</tt>
|
<tt><if test="defined(item.type)">{+ new Link().toSymbol(item.type) +} — </if>{+processInlineTags(item.desc, { stripParagraphs: true })+}</tt>
|
||||||
</li>
|
</li>
|
||||||
</for>
|
</for>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
|
|
|
@ -25,8 +25,9 @@
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<if test="data.type">
|
<if test="data.type">
|
||||||
<div class="member-text"><p>
|
<div class="member-text">
|
||||||
{+processInlineTags(data.desc)+}<if test="data.readOnly"> Read only.</if></p>
|
{+processInlineTags(data.desc)+}
|
||||||
|
<if test="data.readOnly"> Read only.</if>
|
||||||
{+ new JSDOC.JsPlate(publish.conf.templatesDir+"examples.tmpl").process(data) +}
|
{+ new JSDOC.JsPlate(publish.conf.templatesDir+"examples.tmpl").process(data) +}
|
||||||
<if test="data.defaultValue">
|
<if test="data.defaultValue">
|
||||||
<ul><b>Default:</b>
|
<ul><b>Default:</b>
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
var templates;
|
|
||||||
|
|
||||||
var Operator = new function() {
|
var Operator = new function() {
|
||||||
var operators = {
|
var operators = {
|
||||||
add: '+', subtract: '-', multiply: '*', divide: '/', equals: '==',
|
add: '+', subtract: '-', multiply: '*', divide: '/', equals: '==',
|
||||||
|
@ -51,6 +49,7 @@ var Helpers = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var templates;
|
||||||
/** Called automatically by JsDoc Toolkit. */
|
/** Called automatically by JsDoc Toolkit. */
|
||||||
function publish(symbolSet) {
|
function publish(symbolSet) {
|
||||||
publish.conf = { // trailing slash expected for dirs
|
publish.conf = { // trailing slash expected for dirs
|
||||||
|
@ -276,7 +275,9 @@ function processGroupTitle(str, symbol) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processInlineTags(str) {
|
function processInlineTags(str, param) {
|
||||||
|
if (!param)
|
||||||
|
param = {};
|
||||||
// <code>..</code> -> <pre>..</pre>
|
// <code>..</code> -> <pre>..</pre>
|
||||||
str = str.replace(/<(\/)*(code)>/g, '<$1pre>');
|
str = str.replace(/<(\/)*(code)>/g, '<$1pre>');
|
||||||
|
|
||||||
|
@ -292,9 +293,59 @@ function processInlineTags(str) {
|
||||||
return '<tt>' + code + '</tt>';
|
return '<tt>' + code + '</tt>';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var lineBreak = java.lang.System.getProperty('line.separator');
|
||||||
|
|
||||||
|
// Convert any type of lineBreak to the one we're using now:
|
||||||
|
str = str.replace(/(\r\n|\n|\r)/g, function(match, lineBreak) {
|
||||||
|
return lineBreak;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Replace inline <code></code> with <tt></tt>
|
||||||
|
str = str.replace(/<code>[ \t]*([^\n\r]*?)[ \t]*<\/code>/g, function(match, content) {
|
||||||
|
return '<tt>' + content + '</tt>';
|
||||||
|
});
|
||||||
|
|
||||||
|
// Put code and pre tags on the same line as the content, as white-space: pre is set:
|
||||||
|
str = str.replace(/(<(?:code|pre)>)\s*([\u0000-\uffff]*?)\s*(<\/(?:code|pre)>)/g, function(match, open, content, close) {
|
||||||
|
// Filter out the first white space at the beginning of each line, since
|
||||||
|
// that stems from the space after the * in the comment and replace <code>
|
||||||
|
// with <pre>, to fix a IE problem where lighter.js does not receive
|
||||||
|
// linebreaks from code tags weven when white-space: pre is set.
|
||||||
|
return '<pre>' + content.replace(/(\r\n|\n|\r) /mg, function(match, lineBreak) {
|
||||||
|
return lineBreak;
|
||||||
|
}) + '</pre>';
|
||||||
|
});
|
||||||
|
// Empty lines -> Paragraphs
|
||||||
|
if (!param.stripParagraphs) {
|
||||||
|
if (param.wrapInParagraphs === undefined || param.wrapInParagraphs)
|
||||||
|
str = '<p>' + str.trim() + '</p>';
|
||||||
|
str = str.trim().replace(/(\r\n|\n|\r)\s*(\r\n|\n|\r)/g, function(match, lineBreak) {
|
||||||
|
return '</p>' + lineBreak + '<p>';
|
||||||
|
});
|
||||||
|
// Automatically put </p><p> at the end of sentences with line breaks.
|
||||||
|
// Match following </p> and <p> tags and swallow them. This happens when
|
||||||
|
// the original content contains these.
|
||||||
|
str = str.trim().replace(/([.:?!;])\s*(\r\n|\n|\r)(\s*)(<\/p>|<p>|)/g, function(match, before, lineBreak, whiteSpace, after) {
|
||||||
|
// Include following whiteSpace as well, since for code blocks they are relevant (e.g. indentation on new line)
|
||||||
|
return before + '</p>' + lineBreak + whiteSpace + '<p>';
|
||||||
|
});
|
||||||
|
// Filter out <p> tags within and around <code> and <pre> blocks again
|
||||||
|
str = str.replace(/((?:<p>\s*|)<(?:code|pre)[^>]*>[\u0000-\uffff]*<\/(?:code|pre)>(?:\s*<\/p>|))/g, function(match, code) {
|
||||||
|
return stripTags(code, 'p');
|
||||||
|
});
|
||||||
|
// Filter out empty paragraphs
|
||||||
|
str = str.replace(/<p><\/p>/g, '');
|
||||||
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stripTags(str, tag) {
|
||||||
|
var tag = tag || '.*?'; // Default: all tags
|
||||||
|
return str.replace(new RegExp('<' + tag + '>|</' + tag + '>', 'g'), '');
|
||||||
|
}
|
||||||
|
|
||||||
function copyStatic(dir) {
|
function copyStatic(dir) {
|
||||||
var dir = publish.conf.templatesDir + 'resources/';
|
var dir = publish.conf.templatesDir + 'resources/';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue