From 4f5415b1e5860d5555b1143a0931b7f2d99341f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Wed, 8 Jun 2011 13:36:46 +0100 Subject: [PATCH] jsdoc: Add asCode parameter to Link() constructor, to define if it should be wrapped in or not. --- build/jsdoc-toolkit/app/frame/Link.js | 10 ++++++++-- build/jsdoc-toolkit/templates/jsdoc/src/Render.js | 8 ++++---- .../jsdoc-toolkit/templates/jsdoc/templates/class.tmpl | 4 ++-- .../templates/jsdoc/templates/property.tmpl | 2 +- .../templates/jsdoc/templates/seeAlsos.tmpl | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/build/jsdoc-toolkit/app/frame/Link.js b/build/jsdoc-toolkit/app/frame/Link.js index d609156c..0c958641 100644 --- a/build/jsdoc-toolkit/app/frame/Link.js +++ b/build/jsdoc-toolkit/app/frame/Link.js @@ -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 = ""+link.linkText+""; + 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 = "" + text + ""; + var html = "" + text + ""; if (this.prefix || this.suffix) html = (this.prefix || '') + html + (this.suffix || ''); return html; diff --git a/build/jsdoc-toolkit/templates/jsdoc/src/Render.js b/build/jsdoc-toolkit/templates/jsdoc/src/Render.js index ca509247..8471d18c 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/src/Render.js +++ b/build/jsdoc-toolkit/templates/jsdoc/src/Render.js @@ -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('' + new Link().toSymbol(i) + ''); + param.inheritedLinks.push('' + new Link(true).toSymbol(i) + ''); } 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 }); }, diff --git a/build/jsdoc-toolkit/templates/jsdoc/templates/class.tmpl b/build/jsdoc-toolkit/templates/jsdoc/templates/class.tmpl index 4ca36b58..67af90ae 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/templates/class.tmpl +++ b/build/jsdoc-toolkit/templates/jsdoc/templates/class.tmpl @@ -49,7 +49,7 @@ -

Properties inherited from {+ new Link().toSymbol(inheritedClass.className) +}

+

Properties inherited from {+ new Link(true).toSymbol(inheritedClass.className) +}

{+ Render.property(member, true) +} @@ -57,7 +57,7 @@ -

Functions inherited from {+ new Link().toSymbol(inheritedClass.className) +}

+

Functions inherited from {+ new Link(true).toSymbol(inheritedClass.className) +}

{+ Render.method(member, true) +} diff --git a/build/jsdoc-toolkit/templates/jsdoc/templates/property.tmpl b/build/jsdoc-toolkit/templates/jsdoc/templates/property.tmpl index 44585e6c..2f10348e 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/templates/property.tmpl +++ b/build/jsdoc-toolkit/templates/jsdoc/templates/property.tmpl @@ -30,7 +30,7 @@
    Type:
  • - {+new Link().toSymbol(data.symbol.type)+} + {+new Link(true).toSymbol(data.symbol.type)+}
{+ Render.seeAlsos(data.symbol) +} diff --git a/build/jsdoc-toolkit/templates/jsdoc/templates/seeAlsos.tmpl b/build/jsdoc-toolkit/templates/jsdoc/templates/seeAlsos.tmpl index f8cb0eac..76133ece 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/templates/seeAlsos.tmpl +++ b/build/jsdoc-toolkit/templates/jsdoc/templates/seeAlsos.tmpl @@ -1,5 +1,5 @@

See also: - , {+ new Link().toSymbol(item) +} + , {+ new Link(true).toSymbol(item) +}

\ No newline at end of file