@@ -96,3 +96,58 @@ export function load(app: Application) {
96
96
});
97
97
}
98
98
```
99
+
100
+ Since TypeDoc 0.23.26, plugins may also return return an object for more control
101
+ over the displayed link. The returned ` caption ` will be used if the user does not
102
+ specify the link text.
103
+
104
+ ``` ts
105
+ import { Application , type DeclarationReference } from " typedoc" ;
106
+
107
+ const documentedExports = [
108
+ " chunk" ,
109
+ " compact" ,
110
+ " concat" ,
111
+ " difference" ,
112
+ " differenceBy" ,
113
+ " differenceWith" ,
114
+ ];
115
+
116
+ export function load(app : Application ) {
117
+ app .converter .addUnknownSymbolResolver ((ref : DeclarationReference ) => {
118
+ if (
119
+ // TS defined symbols
120
+ ref .moduleSource !== " @types/lodash" &&
121
+ // User {@link} tags
122
+ ref .moduleSource !== " lodash"
123
+ ) {
124
+ return ;
125
+ }
126
+
127
+ // If someone did {@link lodash!}, link them directly to the home page.
128
+ if (! ref .symbolReference ) {
129
+ return " https://lodash.com/" ;
130
+ }
131
+
132
+ if (! ref .symbolReference .path ) {
133
+ // Someone included a meaning, but not a path.
134
+ // https://typedoc.org/guides/declaration-references/#meaning
135
+ return ;
136
+ }
137
+
138
+ if (ref .symbolReference .path .length === 1 ) {
139
+ const name = ref .symbolReference .path [0 ].path ;
140
+ if (documentedExports .includes (name )) {
141
+ return {
142
+ target: ` https://lodash.com/docs/4.17.15#${name } ` ,
143
+ caption: name ,
144
+ };
145
+ }
146
+ }
147
+ });
148
+ }
149
+ ```
150
+
151
+ The unknown symbol resolver will also be passed the reflection containing the link
152
+ and, if the link was defined by the user, the [ CommentDisplayPart] ( https://typedoc.org/api/types/CommentDisplayPart.html )
153
+ which was parsed into the ` DeclarationReference ` provided as the first argument.
0 commit comments