Skip to content

Commit 32ae13e

Browse files
stainless-emdsherretcrowlKats
authored
fix: handle name_path with single item (#726)
Co-authored-by: David Sherret <dsherret@gmail.com> Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
1 parent 3057e96 commit 32ae13e

File tree

3 files changed

+73
-29
lines changed

3 files changed

+73
-29
lines changed

src/parser.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,13 @@ impl<'a> DocParser<'a> {
341341
definitions.first().unwrap().module.specifier(),
342342
reference_def,
343343
// -1 to include the root
344-
name_path[i - 1..].to_vec(),
344+
if i > 1 {
345+
name_path[i - 1..].to_vec()
346+
} else {
347+
let mut out = vec![root_name];
348+
out.extend_from_slice(&name_path);
349+
out
350+
},
345351
false,
346352
);
347353
};

tests/specs/namespace_reexport_member.txt

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -182,34 +182,7 @@ Defined in file:///mod.ts:1:1
182182
},
183183
"kind": "namespace",
184184
"namespaceDef": {
185-
"elements": [
186-
{
187-
"name": "Completions",
188-
"isDefault": false,
189-
"location": {
190-
"filename": "file:///chat_completions.ts",
191-
"line": 2,
192-
"col": 0,
193-
"byteIndex": 11
194-
},
195-
"declarationKind": "export",
196-
"jsDoc": {
197-
"doc": "Doc"
198-
},
199-
"kind": "class",
200-
"classDef": {
201-
"isAbstract": false,
202-
"constructors": [],
203-
"properties": [],
204-
"indexSignatures": [],
205-
"methods": [],
206-
"extends": null,
207-
"implements": [],
208-
"typeParams": [],
209-
"superTypeParams": []
210-
}
211-
}
212-
]
185+
"elements": []
213186
}
214187
}
215188
]
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# mod.ts
2+
export { Audio } from './audio.ts';
3+
4+
# audio.ts
5+
import { Speech } from './speech.ts';
6+
7+
/** Some documentation. */
8+
export namespace Audio {
9+
export { Speech as Speech };
10+
}
11+
12+
# speech.ts
13+
/** Some documentation. */
14+
export namespace Speech {}
15+
16+
# output.txt
17+
Defined in file:///audio.ts:4:1
18+
19+
namespace Audio
20+
Some documentation.
21+
22+
namespace Speech
23+
Some documentation.
24+
25+
26+
# output.json
27+
[
28+
{
29+
"name": "Audio",
30+
"isDefault": false,
31+
"location": {
32+
"filename": "file:///audio.ts",
33+
"line": 4,
34+
"col": 0,
35+
"byteIndex": 66
36+
},
37+
"declarationKind": "export",
38+
"jsDoc": {
39+
"doc": "Some documentation."
40+
},
41+
"kind": "namespace",
42+
"namespaceDef": {
43+
"elements": [
44+
{
45+
"name": "Speech",
46+
"isDefault": false,
47+
"location": {
48+
"filename": "file:///speech.ts",
49+
"line": 2,
50+
"col": 0,
51+
"byteIndex": 27
52+
},
53+
"declarationKind": "export",
54+
"jsDoc": {
55+
"doc": "Some documentation."
56+
},
57+
"kind": "namespace",
58+
"namespaceDef": {
59+
"elements": []
60+
}
61+
}
62+
]
63+
}
64+
}
65+
]

0 commit comments

Comments
 (0)