typedoc-plugin-mdn-links
Advanced tools
Comparing version 3.2.12 to 3.3.0
@@ -37,3 +37,10 @@ "use strict"; | ||
}); | ||
app.converter.addUnknownSymbolResolver((declaration) => { | ||
app.converter.addUnknownSymbolResolver(resolveSymbol); | ||
function resolveSymbol(declaration, _refl, _part, symbolId) { | ||
if (symbolId) { | ||
return resolveDeclaration(makeDeclarationReference(symbolId)); | ||
} | ||
return resolveDeclaration(declaration); | ||
} | ||
function resolveDeclaration(declaration) { | ||
const validSources = [ | ||
@@ -63,3 +70,3 @@ ...app.options.getValue("additionalModuleSources"), | ||
} | ||
}); | ||
} | ||
} | ||
@@ -73,1 +80,35 @@ function stringifyPath(path) { | ||
} | ||
function makeDeclarationReference(symbolId) { | ||
if ("toDeclarationReference" in symbolId) { | ||
// Method added in TypeDoc 0.26.8, use it if present as it will be | ||
// smarter about package names which aren't in node_modules. Probably not | ||
// an issue for this project, so the simpler method is also included here. | ||
return symbolId.toDeclarationReference(); | ||
} | ||
return { | ||
resolutionStart: "global", | ||
moduleSource: getModuleName(symbolId.fileName), | ||
symbolReference: getSymbolReference(symbolId.qualifiedName), | ||
}; | ||
} | ||
function getModuleName(symbolPath) { | ||
// Attempt to decide package name from path if it contains "node_modules" | ||
let startIndex = symbolPath.lastIndexOf("node_modules/"); | ||
if (startIndex !== -1) { | ||
startIndex += "node_modules/".length; | ||
let stopIndex = symbolPath.indexOf("/", startIndex); | ||
// Scoped package, e.g. `@types/node` | ||
if (symbolPath[startIndex] === "@") { | ||
stopIndex = symbolPath.indexOf("/", stopIndex + 1); | ||
} | ||
return symbolPath.substring(startIndex, stopIndex); | ||
} | ||
} | ||
function getSymbolReference(qualifiedName) { | ||
return { | ||
path: (0, typedoc_1.splitUnquotedString)(qualifiedName, ".").map((path) => ({ | ||
navigation: ".", | ||
path, | ||
})), | ||
}; | ||
} |
{ | ||
"name": "typedoc-plugin-mdn-links", | ||
"version": "3.2.12", | ||
"version": "3.3.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -7,3 +7,3 @@ # typedoc-plugin-mdn-links | ||
If you're explicitly referencing a type in a comment, you can use `{@link | ||
!HTMLElement}` to have it processed by this plugin. | ||
!HTMLElement}` or `{@link HTMLElement}` to have it processed by this plugin. | ||
@@ -10,0 +10,0 @@ If you set `--logLevel Verbose`, it will print out when failing to resolve a |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
703368
10957