Skip to content

Commit 99fc49d

Browse files
committed
Progress.
1 parent 67023d6 commit 99fc49d

1 file changed

Lines changed: 6 additions & 18 deletions

File tree

  • tools/apiview/emitters/typespec-apiview/src

tools/apiview/emitters/typespec-apiview/src/apiview.ts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ export class ApiView {
137137
}
138138
}
139139

140-
trim() {
140+
trim(trimNewlines: boolean = false) {
141141
let last = this.tokens[this.tokens.length - 1];
142142
while (last) {
143-
if (last.Kind === ApiViewTokenKind.Whitespace) {
143+
if (last.Kind === ApiViewTokenKind.Whitespace || (trimNewlines && last.Kind === ApiViewTokenKind.Newline)) {
144144
this.tokens.pop();
145145
last = this.tokens[this.tokens.length - 1];
146146
} else {
@@ -594,21 +594,6 @@ export class ApiView {
594594
this.punctuation("]", true, false);
595595
break;
596596
case SyntaxKind.TypeReference:
597-
598-
// if (isExpanded) {
599-
// this.newline();
600-
// this.indent();
601-
// }
602-
// if (obj.name) {
603-
// this.text(obj.name.sv);
604-
// this.punctuation("=", true, true);
605-
// }
606-
// if (isExpanded) {
607-
// this.tokenizeModelExpressionExpanded(obj.argument as ModelExpressionNode, false, false);
608-
// this.deindent();
609-
// } else {
610-
// this.tokenize(obj.argument);
611-
// }
612597
obj = node as TypeReferenceNode;
613598
isExpanded = this.isTemplateExpanded(obj);
614599
this.tokenizeIdentifier(obj.target, "reference");
@@ -622,6 +607,7 @@ export class ApiView {
622607
const arg = obj.arguments[x];
623608
this.tokenize(arg);
624609
if (x !== obj.arguments.length - 1) {
610+
this.trim(true);
625611
this.renderPunctuation(",");
626612
}
627613
}
@@ -784,6 +770,7 @@ export class ApiView {
784770
const propName = this.getNameForNode(prop);
785771
this.namespaceStack.push(propName);
786772
this.tokenize(prop);
773+
this.trim(true);
787774
this.punctuation(";", false, false);
788775
this.namespaceStack.pop();
789776
this.blankLines(0);
@@ -945,10 +932,11 @@ export class ApiView {
945932
this.namespaceStack.pop();
946933
if (isOperationSignature) {
947934
if (x !== node.properties.length - 1) {
948-
this.trim();
935+
this.trim(true);
949936
this.renderPunctuation(",");
950937
}
951938
} else {
939+
this.trim(true);
952940
this.renderPunctuation(";");
953941
}
954942
this.blankLines(0);

0 commit comments

Comments
 (0)