typedoc-plugin-dt-links 1.1.15 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -13
- package/data/dt_history.txt +29 -0
- package/dist/plugin.js +27 -28
- package/package.json +12 -14
package/README.md
CHANGED
|
@@ -8,22 +8,17 @@ to their source code on GitHub.
|
|
|
8
8
|
If VSCode can follow a link into an `@types` package, this plugin should also
|
|
9
9
|
be able to provide links to that package.
|
|
10
10
|
|
|
11
|
-
> Note: Using TypeDoc before 0.26.8 may result in links which go to the start of
|
|
12
|
-
> the doc comment rather to the symbol name.
|
|
13
|
-
|
|
14
|
-
Supports TypeDoc 0.23.14 through 0.26.x.
|
|
15
|
-
|
|
16
11
|
## Options
|
|
17
12
|
|
|
18
|
-
-
|
|
13
|
+
- `warnOnUnstableDtLink`
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
Defaults to `true`. If set, and an `@types` package is referenced which is newer
|
|
16
|
+
than this plugin, produces a warning as this plugin won't be able to produce a stable
|
|
17
|
+
link.
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
This plugin is automatically published weekly, so if you are upgrading `@types` packages
|
|
20
|
+
and rebuilding docs more frequently than that, you may want to disable this option as
|
|
21
|
+
the link won't be dead long enough to matter.
|
|
27
22
|
|
|
28
23
|
## Changelog
|
|
29
24
|
|
|
@@ -50,4 +45,4 @@ was released more recently than this plugin, the plugin can't know what git hash
|
|
|
50
45
|
should be used and will instead use `master` as the reference.
|
|
51
46
|
|
|
52
47
|
[useTsLinkResolution]: https://typedoc.org/options/comments/#usetslinkresolution
|
|
53
|
-
[ReflectionSymbolId]:
|
|
48
|
+
[ReflectionSymbolId]: https://typedoc.org/api/classes/Models.ReflectionSymbolId.html
|
package/data/dt_history.txt
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
a4450792b76f9faa16b0f91bcac5d6be1fcb66e6 1742009665
|
|
2
|
+
14e79d1bfbe91e3c4d407a9dd0811a706fcb0728 1742009633
|
|
3
|
+
b14d38a91d3de37b80d15886e077e6f3378b143f 1742009615
|
|
4
|
+
7dc36999aa047ce4bebba3014ff68678e59adcda 1742009594
|
|
5
|
+
6a5b8b4a29e746d7d47082916bfdd52ddc0554b4 1741961393
|
|
6
|
+
ea93fee0fb0f6476df8df9893d48b2e6a3d3dc2e 1741950983
|
|
7
|
+
dfc45cb4828559e2f42e0d1e3681edb576cecaae 1741915914
|
|
8
|
+
a5527849cfcedf1c395dceeca048fff546edb7ef 1741910036
|
|
9
|
+
ccb4f1f25899c83fbbb8cbc40dea1faffeecd640 1741880923
|
|
10
|
+
880802ce3b991dfc0df17fc9ba7f259116355afe 1741880866
|
|
11
|
+
6811a6e969d2ce8d77287f8d313ab4c8afdda57d 1741876961
|
|
12
|
+
4f8782f5dfed4357491755686472091533fbf646 1741876903
|
|
13
|
+
7c75cbcebcdeaed1835f48d625f43593a551667a 1741852632
|
|
14
|
+
ab19e5186566bfb97be06dedd4bb60880affcd75 1741852619
|
|
15
|
+
4abe267a418604bf3fb495d4df45280732ac55ef 1741852559
|
|
16
|
+
be35a3189a293fd5b7b7e6bc067e3dd74a058704 1741815595
|
|
17
|
+
086eb914c542d356865d03ddd6c58bdb6c445d2c 1741812982
|
|
18
|
+
c4d0e466d185ec95388bceb13f115b7f6863f5bc 1741805148
|
|
19
|
+
e658654b3ed1389fdfb1ce6097ebe7329e3bee27 1741764149
|
|
20
|
+
1cc65785c9cacb6321d0454a243e31344ce4a723 1741730871
|
|
21
|
+
482ac704d9f29afbf96da9bca4844090bf918d39 1741730856
|
|
22
|
+
dfb194a2c6ffb263836a4637ad8106d2667af78e 1741730843
|
|
23
|
+
6a37d9c7e075eb31543bbdec2bf5f77a8ab0c6e5 1741730819
|
|
24
|
+
3a17ff00600a50db103774cfb818685c5677e815 1741728492
|
|
25
|
+
7a5918872ede386c800bc54e44dc34d3c0927278 1741675547
|
|
26
|
+
3686cb7ac894aa033a5ab5fa02c94b73810b4ef6 1741662274
|
|
27
|
+
5958465eb0de1b1f305b8d02d343659cb34ea271 1741622480
|
|
28
|
+
f3fe8a416a1f26a52c82c759c6027e185ecd6077 1741597646
|
|
29
|
+
5cbed3e95e982cbe6ea1f07e8b5f38478ab977fe 1741594304
|
|
1
30
|
da70d4aee37cd531df1fc030c1e068fe51d3b5e9 1741417271
|
|
2
31
|
06153425477bcba69fce608e3a369dea94b4b505 1741415796
|
|
3
32
|
f0671a5d05a3b245b2a1a1e1e8a55a3f29824d69 1741405833
|
package/dist/plugin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ParameterType, splitUnquotedString, TypeScript as ts, } from "typedoc";
|
|
2
1
|
import { readFileSync } from "node:fs";
|
|
3
2
|
import { dirname } from "node:path";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { ParameterType, splitUnquotedString, TypeScript as ts, } from "typedoc";
|
|
5
5
|
const PLUGIN_PREFIX = "[typedoc-plugin-dt-links]";
|
|
6
6
|
const DT_DEFAULT_BRANCH = "master";
|
|
7
7
|
export const DT_COMMITS = readFileSync(dirname(fileURLToPath(import.meta.url)) + "/../data/dt_history.txt", "utf-8")
|
|
@@ -44,8 +44,8 @@ function discoverSourceFilePosition(sf, qualifiedName) {
|
|
|
44
44
|
function walkPath(index, node) {
|
|
45
45
|
if (index === path.length) {
|
|
46
46
|
const name = node.name;
|
|
47
|
-
if (name
|
|
48
|
-
(ts.isMemberName(name) || ts.isComputedPropertyName(name))) {
|
|
47
|
+
if (name
|
|
48
|
+
&& (ts.isMemberName(name) || ts.isComputedPropertyName(name))) {
|
|
49
49
|
return name.getStart(sf, false);
|
|
50
50
|
}
|
|
51
51
|
return node.getStart(sf, false);
|
|
@@ -62,30 +62,30 @@ function discoverSourceFilePosition(sf, qualifiedName) {
|
|
|
62
62
|
else if (child.name.text === path[index]) {
|
|
63
63
|
return walkPath(index + 1, child);
|
|
64
64
|
}
|
|
65
|
-
else if (child.name.text === "global"
|
|
65
|
+
else if (child.name.text === "global"
|
|
66
66
|
// Not quite sure why TypeDoc gives this name...
|
|
67
|
-
path[index] === "__global") {
|
|
67
|
+
&& path[index] === "__global") {
|
|
68
68
|
return walkPath(index + 1, child);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
if (ts.isModuleBlock(child)
|
|
72
|
-
ts.isVariableDeclaration(child)
|
|
73
|
-
ts.isVariableDeclarationList(child)) {
|
|
71
|
+
if (ts.isModuleBlock(child)
|
|
72
|
+
|| ts.isVariableDeclaration(child)
|
|
73
|
+
|| ts.isVariableDeclarationList(child)) {
|
|
74
74
|
return walkPath(index, child);
|
|
75
75
|
}
|
|
76
|
-
if (ts.isClassDeclaration(child)
|
|
77
|
-
ts.isInterfaceDeclaration(child)) {
|
|
76
|
+
if (ts.isClassDeclaration(child)
|
|
77
|
+
|| ts.isInterfaceDeclaration(child)) {
|
|
78
78
|
if ((child.name?.text ?? "default") === path[index]) {
|
|
79
79
|
return walkPath(index + 1, child);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
if (ts.isFunctionDeclaration(child)
|
|
83
|
-
ts.isPropertyDeclaration(child)
|
|
84
|
-
ts.isVariableDeclaration(child)
|
|
85
|
-
ts.isMethodDeclaration(child)
|
|
86
|
-
ts.isMethodSignature(child)
|
|
87
|
-
ts.isPropertySignature(child)
|
|
88
|
-
ts.isPropertyAssignment(child)) {
|
|
82
|
+
if (ts.isFunctionDeclaration(child)
|
|
83
|
+
|| ts.isPropertyDeclaration(child)
|
|
84
|
+
|| ts.isVariableDeclaration(child)
|
|
85
|
+
|| ts.isMethodDeclaration(child)
|
|
86
|
+
|| ts.isMethodSignature(child)
|
|
87
|
+
|| ts.isPropertySignature(child)
|
|
88
|
+
|| ts.isPropertyAssignment(child)) {
|
|
89
89
|
if (child.name?.getText() === path[index]) {
|
|
90
90
|
return walkPath(index + 1, child);
|
|
91
91
|
}
|
|
@@ -95,6 +95,8 @@ function discoverSourceFilePosition(sf, qualifiedName) {
|
|
|
95
95
|
}
|
|
96
96
|
const sourceFileCache = new Map();
|
|
97
97
|
export function getLineNumber(symbolId) {
|
|
98
|
+
if (!symbolId.fileName)
|
|
99
|
+
throw new Error("Requires a filename");
|
|
98
100
|
let sf = sourceFileCache.get(symbolId.fileName);
|
|
99
101
|
if (!sf) {
|
|
100
102
|
try {
|
|
@@ -143,16 +145,15 @@ export function load(app) {
|
|
|
143
145
|
else {
|
|
144
146
|
const publishDate = Date.parse(update[1]);
|
|
145
147
|
app.logger.verbose(`${PLUGIN_PREFIX} @types/${packageName} was updated at ${new Date(publishDate).toISOString()}`);
|
|
146
|
-
hash =
|
|
147
|
-
|
|
148
|
-
DT_DEFAULT_BRANCH;
|
|
148
|
+
hash = findDtCommitHash(publishDate / 1000)
|
|
149
|
+
?? DT_DEFAULT_BRANCH;
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
catch {
|
|
152
153
|
hash = DT_DEFAULT_BRANCH;
|
|
153
154
|
}
|
|
154
|
-
if (hash === DT_DEFAULT_BRANCH
|
|
155
|
-
app.options.getValue("warnOnUnstableDtLink")) {
|
|
155
|
+
if (hash === DT_DEFAULT_BRANCH
|
|
156
|
+
&& app.options.getValue("warnOnUnstableDtLink")) {
|
|
156
157
|
const version = JSON.parse(readFileSync(packagePath + "/package.json", "utf-8")).version;
|
|
157
158
|
app.logger.warn(`${PLUGIN_PREFIX} Failed to discover git hash for @types/${packageName} v${version}, linking to ${DT_DEFAULT_BRANCH} branch. This will eventually cause broken links.`);
|
|
158
159
|
}
|
|
@@ -162,7 +163,7 @@ export function load(app) {
|
|
|
162
163
|
return publishHashCache.get(packagePath);
|
|
163
164
|
}
|
|
164
165
|
function resolveSymbol(_declaration, _refl, _part, symbolId) {
|
|
165
|
-
if (!symbolId) {
|
|
166
|
+
if (!symbolId || !symbolId.packageName.startsWith("@types/") || !symbolId.fileName) {
|
|
166
167
|
return;
|
|
167
168
|
}
|
|
168
169
|
// Attempt to decide package name from path if it contains "node_modules"
|
|
@@ -172,16 +173,14 @@ export function load(app) {
|
|
|
172
173
|
startIndex += "node_modules/@types/".length;
|
|
173
174
|
let stopIndex = symbolId.fileName.indexOf("/", startIndex);
|
|
174
175
|
const packageName = symbolId.fileName.substring(startIndex, stopIndex);
|
|
175
|
-
const innerPath = symbolId.fileName
|
|
176
|
-
.substring(stopIndex)
|
|
177
|
-
.replaceAll("\\", "/");
|
|
178
176
|
const hash = getPublishHash(symbolId.fileName.substring(0, stopIndex), packageName);
|
|
179
177
|
return [
|
|
180
178
|
"https://github.com/DefinitelyTyped/DefinitelyTyped/blob/",
|
|
181
179
|
hash,
|
|
182
180
|
"/types/",
|
|
183
|
-
packageName,
|
|
184
|
-
|
|
181
|
+
symbolId.packageName.replace("@types/", ""),
|
|
182
|
+
"/",
|
|
183
|
+
symbolId.packagePath,
|
|
185
184
|
"#L",
|
|
186
185
|
getLineNumber(symbolId),
|
|
187
186
|
].join("");
|
package/package.json
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typedoc-plugin-dt-links",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"main": "dist/plugin.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@types/node": "22.7.4",
|
|
9
9
|
"@voxpelli/node-test-pretty-reporter": "^1.1.2",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"typedoc": "^0.27.0-beta.1",
|
|
15
|
-
"typescript": "^5.7.2"
|
|
10
|
+
"dprint": "^0.49.0",
|
|
11
|
+
"tsx": "^4.19.3",
|
|
12
|
+
"typedoc": "^0.28.0",
|
|
13
|
+
"typescript": "^5.8.2"
|
|
16
14
|
},
|
|
17
15
|
"keywords": [
|
|
18
16
|
"typedoc-plugin"
|
|
@@ -22,12 +20,7 @@
|
|
|
22
20
|
"data/dt_history.txt"
|
|
23
21
|
],
|
|
24
22
|
"peerDependencies": {
|
|
25
|
-
"typedoc": "
|
|
26
|
-
},
|
|
27
|
-
"scripts": {
|
|
28
|
-
"lint": "prettier --check .",
|
|
29
|
-
"build": "tsc",
|
|
30
|
-
"test": "tsx --test --test-reporter=@voxpelli/node-test-pretty-reporter src/test/plugin.test.ts"
|
|
23
|
+
"typedoc": "0.28.x"
|
|
31
24
|
},
|
|
32
25
|
"repository": {
|
|
33
26
|
"type": "git",
|
|
@@ -35,5 +28,10 @@
|
|
|
35
28
|
},
|
|
36
29
|
"bugs": {
|
|
37
30
|
"url": "https://github.com/Gerrit0/typedoc-plugin-dt-links/issues"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"lint": "dprint check",
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"test": "tsx --test --test-reporter=@voxpelli/node-test-pretty-reporter src/test/plugin.test.ts"
|
|
38
36
|
}
|
|
39
|
-
}
|
|
37
|
+
}
|