Skip to content

Commit 4c4151b

Browse files
committed
Add a test case to repro GitHub #2797
1 parent 83f8aef commit 4c4151b

6 files changed

Lines changed: 102 additions & 1 deletion

File tree

apps/api-extractor/.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"run",
8080
"--local",
8181
"--config",
82-
"./temp/configs/api-extractor-exportImportStarAs2.json"
82+
"./temp/configs/api-extractor-spanSorting.json"
8383
],
8484
"sourceMaps": true
8585
}

apps/api-extractor/src/analyzer/Span.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,49 @@ export class Span {
403403
return result;
404404
}
405405

406+
/**
407+
* Returns a diagnostic dump of the tree, showing the SpanModification settings for each nodde.
408+
*/
409+
public getModifiedDump(indent: string = ''): string {
410+
let result: string = indent + ts.SyntaxKind[this.node.kind] + ': ';
411+
412+
if (this.prefix) {
413+
result += ' pre=[' + this._getTrimmed(this.modification.prefix) + ']';
414+
}
415+
if (this.suffix) {
416+
result += ' suf=[' + this._getTrimmed(this.modification.suffix) + ']';
417+
}
418+
if (this.separator) {
419+
result += ' sep=[' + this._getTrimmed(this.separator) + ']';
420+
}
421+
if (this.modification.indentDocComment !== IndentDocCommentScope.None) {
422+
result += ' indentDocComment=' + IndentDocCommentScope[this.modification.indentDocComment];
423+
}
424+
if (this.modification.omitChildren) {
425+
result += ' omitChildren';
426+
}
427+
if (this.modification.omitSeparatorAfter) {
428+
result += ' omitSeparatorAfter';
429+
}
430+
if (this.modification.sortChildren) {
431+
result += ' sortChildren';
432+
}
433+
if (this.modification.sortKey !== undefined) {
434+
result += ` sortKey="${this.modification.sortKey}"`;
435+
}
436+
result += '\n';
437+
438+
if (!this.modification.omitChildren) {
439+
for (const child of this.children) {
440+
result += child.getModifiedDump(indent + ' ');
441+
}
442+
} else {
443+
result += `${indent} (${this.children.length} children)\n`;
444+
}
445+
446+
return result;
447+
}
448+
406449
/**
407450
* Recursive implementation of `getModifiedText()` and `writeModifiedText()`.
408451
*/

build-tests/api-extractor-scenarios/etc/test-outputs/spanSorting/api-extractor-scenarios.api.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,27 @@
351351
}
352352
],
353353
"implementsTokenRanges": []
354+
},
355+
{
356+
"kind": "Variable",
357+
"canonicalReference": "api-extractor-scenarios!exampleD:var",
358+
"docComment": "/**\n * Outer description\n */\n",
359+
"excerptTokens": [
360+
{
361+
"kind": "Content",
362+
"text": "exampleD: "
363+
},
364+
{
365+
"kind": "Content",
366+
"text": "(o: {\n a: number;\n b(): string;\n}) => void"
367+
}
368+
],
369+
"releaseTag": "Public",
370+
"name": "exampleD",
371+
"variableTypeTokenRange": {
372+
"startIndex": 1,
373+
"endIndex": 2
374+
}
354375
}
355376
]
356377
}

build-tests/api-extractor-scenarios/etc/test-outputs/spanSorting/api-extractor-scenarios.api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ export class ExampleC {
2222
member1(): void;
2323
}
2424

25+
// @public
26+
export const exampleD: (o: {
27+
a: number;
28+
b(): string;
29+
}) => void;
30+
2531
// (No @packageDocumentation comment for this package)
2632

2733
```

build-tests/api-extractor-scenarios/etc/test-outputs/spanSorting/rollup.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,19 @@ export declare class ExampleC {
3535
member1(): void;
3636
}
3737

38+
/**
39+
* Outer description
40+
*/
41+
export declare const exampleD: (o: {
42+
/**
43+
* Inner description
44+
*/
45+
a: number;
46+
/**
47+
* @returns a string
48+
* {@link http://example.com}
49+
*/
50+
b(): string;
51+
}) => void;
52+
3853
export { }

build-tests/api-extractor-scenarios/src/spanSorting/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,19 @@ export class ExampleC {
3939
*/
4040
public member1(): void {}
4141
}
42+
43+
/**
44+
* Outer description
45+
*/
46+
export const exampleD = (o: {
47+
/**
48+
* Inner description
49+
*/
50+
a: number;
51+
52+
/**
53+
* @returns a string
54+
* {@link http://example.com}
55+
*/
56+
b(): string;
57+
}) => {};

0 commit comments

Comments
 (0)