Skip to content

Commit ce3930a

Browse files
Allow to specify an alternate caption when linking to other symbols, resolves #82
1 parent 18ef7b3 commit ce3930a

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

bin/typedoc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7252,14 +7252,19 @@ var td;
72527252
var _this = this;
72537253
return text.replace(/\[\[([^\]]+)\]\]/g, function (match, name) {
72547254
var reflection;
7255+
var caption = name, splitAt = name.indexOf('|');
7256+
if (splitAt !== -1) {
7257+
caption = name.substr(splitAt + 1);
7258+
name = name.substr(0, splitAt);
7259+
}
72557260
if (_this.reflection) {
72567261
reflection = _this.reflection.findReflectionByName(name);
72577262
}
72587263
else if (_this.project) {
72597264
reflection = _this.project.findReflectionByName(name);
72607265
}
72617266
if (reflection && reflection.url) {
7262-
return td.Util.format('<a href="%s">%s</a>', _this.getRelativeUrl(reflection.url), name);
7267+
return td.Util.format('<a href="%s">%s</a>', _this.getRelativeUrl(reflection.url), caption);
72637268
}
72647269
else {
72657270
return match;

examples/basic/src/classes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ export class GenericClass<T extends BaseClass>
301301
}
302302

303303

304+
/**
305+
* This a non generic class derived from a [[GenericClass|generic class]].
306+
*/
304307
export class NonGenericClass extends GenericClass<SubClassB>
305308
{
306309

src/td/output/plugins/MarkedPlugin.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,20 @@ module td.output
274274
public parseReferences(text:string) {
275275
return text.replace(/\[\[([^\]]+)\]\]/g, (match:string, name:string) => {
276276
var reflection:models.Reflection;
277+
var caption = name, splitAt = name.indexOf('|');
278+
if (splitAt !== -1) {
279+
caption = name.substr(splitAt + 1);
280+
name = name.substr(0, splitAt);
281+
}
282+
277283
if (this.reflection) {
278284
reflection = this.reflection.findReflectionByName(name);
279285
} else if (this.project) {
280286
reflection = this.project.findReflectionByName(name);
281287
}
282288

283289
if (reflection && reflection.url) {
284-
return Util.format('<a href="%s">%s</a>', this.getRelativeUrl(reflection.url), name);
290+
return Util.format('<a href="%s">%s</a>', this.getRelativeUrl(reflection.url), caption);
285291
} else {
286292
return match;
287293
}

test/renderer/specs/classes/_classes_.nongenericclass.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ <h1>Class NonGenericClass</h1>
7070
<div class="container container-main">
7171
<div class="row">
7272
<div class="col-8 col-content">
73+
<section class="tsd-panel tsd-comment">
74+
<div class="tsd-comment tsd-typography">
75+
<div class="lead">
76+
<p>This a non generic class derived from a <a href="_classes_.genericclass.html">generic class</a>.</p>
77+
</div>
78+
</div>
79+
</section>
7380
<section class="tsd-panel tsd-hierarchy">
7481
<h3>Hierarchy</h3>
7582
<ul class="tsd-hierarchy">

0 commit comments

Comments
 (0)