mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
jsdoc: Add asCode parameter to Link() constructor, to define if it should be wrapped in <tt> or not.
This commit is contained in:
parent
16f184a9a1
commit
4f5415b1e5
5 changed files with 16 additions and 10 deletions
|
@ -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;
|
||||
|
@ -172,7 +173,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;
|
||||
|
|
|
@ -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:
|
||||
|
@ -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
|
||||
});
|
||||
},
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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) +}
|
||||
|
|
|
@ -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>
|
Loading…
Reference in a new issue