Skip to content

Commit e798507

Browse files
committed
fix(core): moved source link inline and exposed to all parent symbols
1 parent 09f6e97 commit e798507

18 files changed

+544
-872
lines changed

.changeset/healthy-camels-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'typedoc-plugin-markdown': minor
3+
---
4+
5+
- Moved source link inline and exposed to all parent symbols (#746).

packages/typedoc-plugin-markdown/src/theme/context/partials/member.accessor.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,11 @@ export function accessor(
100100

101101
if (showSources && !this.options.getValue('disableSources')) {
102102
if (model.getSignature?.sources) {
103-
md.push(
104-
this.partials.sources(model.getSignature, {
105-
headingLevel: options.headingLevel,
106-
}),
107-
);
103+
md.push(this.partials.sources(model.getSignature));
108104
} else if (model.setSignature?.sources) {
109-
md.push(
110-
this.partials.sources(model.setSignature, {
111-
headingLevel: options.headingLevel,
112-
}),
113-
);
105+
md.push(this.partials.sources(model.setSignature));
114106
} else {
115-
md.push(
116-
this.partials.sources(model, { headingLevel: options.headingLevel }),
117-
);
107+
md.push(this.partials.sources(model));
118108
}
119109
}
120110

packages/typedoc-plugin-markdown/src/theme/context/partials/member.declaration.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ export function declaration(
2929

3030
md.push(this.partials.declarationTitle(model));
3131

32+
if (
33+
!opts.nested &&
34+
model.sources &&
35+
!this.options.getValue('disableSources')
36+
) {
37+
md.push(this.partials.sources(model));
38+
}
39+
3240
if (model?.documents) {
3341
md.push(
3442
this.partials.documents(model, {
@@ -147,13 +155,5 @@ export function declaration(
147155
this.partials.inheritance(model, { headingLevel: opts.headingLevel }),
148156
);
149157

150-
if (
151-
!opts.nested &&
152-
model.sources &&
153-
!this.options.getValue('disableSources')
154-
) {
155-
md.push(this.partials.sources(model, { headingLevel: opts.headingLevel }));
156-
}
157-
158158
return md.join('\n\n');
159159
}

packages/typedoc-plugin-markdown/src/theme/context/partials/member.enumMembersTable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function enumMembersTable(
5959
}
6060

6161
if (hasSources) {
62-
row.push(this.partials.sources(property, { headingLevel: -1 }));
62+
row.push(this.partials.sources(property, { hideLabel: true }));
6363
}
6464

6565
rows.push(row);

packages/typedoc-plugin-markdown/src/theme/context/partials/member.memberWithGroups.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export function memberWithGroups(
1212
): string {
1313
const md: string[] = [];
1414

15+
if (model.sources && !this.options.getValue('disableSources')) {
16+
md.push(this.partials.sources(model));
17+
}
18+
1519
if (model.comment) {
1620
md.push(
1721
this.partials.comment(model.comment, {

packages/typedoc-plugin-markdown/src/theme/context/partials/member.propertiesTable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export function propertiesTable(
159159
}
160160

161161
if (hasSources) {
162-
row.push(this.partials.sources(property, { headingLevel: -1 }));
162+
row.push(this.partials.sources(property, { hideLabel: true }));
163163
}
164164

165165
rows.push(row);

packages/typedoc-plugin-markdown/src/theme/context/partials/member.signature.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ export function signature(
2222
);
2323
}
2424

25+
if (
26+
!options.nested &&
27+
model.sources &&
28+
!this.options.getValue('disableSources')
29+
) {
30+
md.push(this.partials.sources(model));
31+
}
32+
2533
let modelComments = options.multipleSignatures
2634
? model.comment
2735
: model.comment || model.parent?.comment;
@@ -120,15 +128,5 @@ export function signature(
120128
this.partials.inheritance(model, { headingLevel: options.headingLevel }),
121129
);
122130

123-
if (
124-
!options.nested &&
125-
model.sources &&
126-
!this.options.getValue('disableSources')
127-
) {
128-
md.push(
129-
this.partials.sources(model, { headingLevel: options.headingLevel }),
130-
);
131-
}
132-
133131
return md.join('\n\n');
134132
}
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import { heading, link } from '@plugin/libs/markdown/index.js';
1+
import { bold, link } from '@plugin/libs/markdown/index.js';
22
import { escapeChars } from '@plugin/libs/utils/index.js';
33
import { MarkdownThemeContext } from '@plugin/theme/index.js';
44
import { DeclarationReflection, SignatureReflection } from 'typedoc';
55

66
export function sources(
77
this: MarkdownThemeContext,
88
model: DeclarationReflection | SignatureReflection,
9-
options: { headingLevel: number },
9+
options?: { hideLabel: boolean },
1010
): string {
1111
const md: string[] = [];
1212

13-
if (options.headingLevel !== -1) {
14-
md.push(heading(options.headingLevel, this.i18n.theme_defined_in()));
13+
if (!options?.hideLabel) {
14+
md.push(`${bold(this.i18n.theme_defined_in())}:`);
1515
}
16+
1617
model.sources?.forEach((source, index) => {
1718
if (index === 0) {
1819
if (source.url) {
@@ -24,5 +25,6 @@ export function sources(
2425
}
2526
}
2627
});
27-
return md.join('\n\n');
28+
29+
return md.join(' ');
2830
}

packages/typedoc-plugin-markdown/src/theme/context/partials/member.typeDeclarationTable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function typeDeclarationTable(
107107
}
108108

109109
if (hasSources) {
110-
row.push(this.partials.sources(declaration, { headingLevel: -1 }));
110+
row.push(this.partials.sources(declaration, { hideLabel: true }));
111111
}
112112

113113
rows.push(row);

packages/typedoc-plugin-markdown/src/theme/context/resources.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ There is no association list partial for properties as these are handled as a st
193193
) => partials.signatures.apply(context, [model, options]) as string,
194194
sources: (
195195
model: DeclarationReflection | SignatureReflection,
196-
options: { headingLevel: number },
196+
options?: { hideLabel: boolean } | undefined,
197197
) => partials.sources.apply(context, [model, options]) as string,
198198
member: (
199199
model: DeclarationReflection,

0 commit comments

Comments
 (0)