File tree 5 files changed +48
-0
lines changed 5 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ ### 3.0.1 (2024-10-15)
2
+
3
+ - Fixed an issue where modules could be created by this plugin with names
4
+ including an absolute path, #12 .
5
+
1
6
### 3.0.0 (2024-06-22)
2
7
3
8
- Support TypeDoc 0.26
Original file line number Diff line number Diff line change
1
+ import { relative } from "path" ;
1
2
import {
2
3
Application ,
3
4
Context ,
@@ -127,6 +128,19 @@ export function load(app: Application) {
127
128
if ( refl . kindOf ( ModuleLike ) ) {
128
129
knownPrograms . set ( refl , context . program ) ;
129
130
}
131
+
132
+ // #12 - This plugin might cause TypeDoc to convert some module without
133
+ // an export symbol to give it a name other than the full absolute
134
+ // path to the symbol. Detect this and rename it to a relative path
135
+ // based on base path if specified or CWD.
136
+ const symbol = context . project . getSymbolFromReflection ( refl ) ;
137
+ const file = symbol ?. declarations ?. find ( ts . isSourceFile ) ;
138
+ if ( file && / ^ " .* " $ / . test ( refl . name ) ) {
139
+ refl . name = relative (
140
+ app . options . getValue ( "basePath" ) || process . cwd ( ) ,
141
+ file . fileName ,
142
+ ) ;
143
+ }
130
144
} ,
131
145
) ;
132
146
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ beforeAll(async () => {
75
75
afterEach ( ( ) => {
76
76
app . options . reset ( "internalModule" ) ;
77
77
app . options . reset ( "placeInternalsInOwningModule" ) ;
78
+ app . options . reset ( "basePath" ) ;
78
79
79
80
expect ( logger . messages ) . toEqual ( [ ] ) ;
80
81
logger . messages = [ ] ;
@@ -159,6 +160,30 @@ test("Missing declaration", () => {
159
160
expect ( toStringHierarchy ( project ) ) . toBe ( hierarchy ) ;
160
161
} ) ;
161
162
163
+ // https://github.com/Gerrit0/typedoc-plugin-missing-exports/issues/12
164
+ test ( "Issue #12" , ( ) => {
165
+ const project = convert ( "gh12/index.ts" ) ;
166
+
167
+ const hierarchy = outdent `
168
+ Module <internal>
169
+ Namespace test/packages/gh12/mod.ts
170
+ Variable ReferencesModule
171
+ ` ;
172
+
173
+ expect ( toStringHierarchy ( project ) ) . toBe ( hierarchy ) ;
174
+
175
+ app . options . setValue ( "basePath" , "test/packages" ) ;
176
+ const project2 = convert ( "gh12/index.ts" ) ;
177
+
178
+ const hierarchy2 = outdent `
179
+ Module <internal>
180
+ Namespace gh12/mod.ts
181
+ Variable ReferencesModule
182
+ ` ;
183
+
184
+ expect ( toStringHierarchy ( project2 ) ) . toBe ( hierarchy2 ) ;
185
+ } ) ;
186
+
162
187
// https://github.com/Gerrit0/typedoc-plugin-missing-exports/issues/15
163
188
test ( "Issue #15" , ( ) => {
164
189
const project = convert ( "gh15/index.ts" ) ;
Original file line number Diff line number Diff line change
1
+ export declare const ReferencesModule : {
2
+ mod : typeof import ( "./mod.js" ) ;
3
+ } ;
Original file line number Diff line number Diff line change
1
+ export const abc = 123 ;
You can’t perform that action at this time.
0 commit comments