Skip to content

Commit

Permalink
fix: Added support for third party symbols (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Nov 12, 2021
1 parent 950d872 commit e5a40d5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
2 changes: 2 additions & 0 deletions packages/typedoc-plugin-markdown/src/render-utils.ts
@@ -1,6 +1,7 @@
import * as fs from 'fs';
import * as Handlebars from 'handlebars';
import * as path from 'path';
import attemptExternalResolution from './resources/helpers/attemptExternalResolution';
import breadcrumbsHelper from './resources/helpers/breadcrumbs';
import commentHelper from './resources/helpers/comment';
import commentsHelper from './resources/helpers/comments';
Expand Down Expand Up @@ -54,6 +55,7 @@ export function registerPartials() {
}

export function registerHelpers(theme: MarkdownTheme) {
attemptExternalResolution(theme);
breadcrumbsHelper(theme);
commentHelper(theme);
commentsHelper();
Expand Down
@@ -0,0 +1,13 @@
import * as Handlebars from 'handlebars';
import type * as ts from 'typescript';

import { MarkdownTheme } from '../../theme';

export default function (theme: MarkdownTheme) {
Handlebars.registerHelper(
'attemptExternalResolution',
function (symbol: ts.Symbol | undefined) {
return theme.owner.attemptExternalResolution(symbol);
},
);
}
25 changes: 17 additions & 8 deletions packages/typedoc-plugin-markdown/src/resources/helpers/type.ts
Expand Up @@ -193,14 +193,23 @@ export function getFunctionType(modelSignatures: SignatureReflection[]) {

function getReferenceType(model: ReferenceType, emphasis) {
if (model.reflection || (model.name && model.typeArguments)) {
const reflection =
model.reflection && model.reflection.url
? [
`[${`\`${model.reflection.name}\``}](${Handlebars.helpers.relativeURL(
model.reflection.url,
)})`,
]
: [`\`${model.name}\``];
const reflection: string[] = [];
if (model.reflection?.url) {
reflection.push(
`[${`\`${model.reflection.name}\``}](${Handlebars.helpers.relativeURL(
model.reflection.url,
)})`,
);
} else {
const externalUrl = Handlebars.helpers.attemptExternalResolution(
model.getSymbol(),
);
reflection.push(
externalUrl
? `[${`\`${model.name}\``}](${externalUrl})`
: `\`${model.name}\``,
);
}
if (model.typeArguments && model.typeArguments.length > 0) {
reflection.push(
`<${model.typeArguments
Expand Down

0 comments on commit e5a40d5

Please sign in to comment.