Skip to content

Commit

Permalink
Progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott committed Apr 17, 2024
1 parent 67023d6 commit 99fc49d
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions tools/apiview/emitters/typespec-apiview/src/apiview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ export class ApiView {
}
}

trim() {
trim(trimNewlines: boolean = false) {
let last = this.tokens[this.tokens.length - 1];
while (last) {
if (last.Kind === ApiViewTokenKind.Whitespace) {
if (last.Kind === ApiViewTokenKind.Whitespace || (trimNewlines && last.Kind === ApiViewTokenKind.Newline)) {
this.tokens.pop();
last = this.tokens[this.tokens.length - 1];
} else {
Expand Down Expand Up @@ -594,21 +594,6 @@ export class ApiView {
this.punctuation("]", true, false);
break;
case SyntaxKind.TypeReference:

// if (isExpanded) {
// this.newline();
// this.indent();
// }
// if (obj.name) {
// this.text(obj.name.sv);
// this.punctuation("=", true, true);
// }
// if (isExpanded) {
// this.tokenizeModelExpressionExpanded(obj.argument as ModelExpressionNode, false, false);
// this.deindent();
// } else {
// this.tokenize(obj.argument);
// }
obj = node as TypeReferenceNode;
isExpanded = this.isTemplateExpanded(obj);
this.tokenizeIdentifier(obj.target, "reference");
Expand All @@ -622,6 +607,7 @@ export class ApiView {
const arg = obj.arguments[x];
this.tokenize(arg);
if (x !== obj.arguments.length - 1) {
this.trim(true);
this.renderPunctuation(",");
}
}
Expand Down Expand Up @@ -784,6 +770,7 @@ export class ApiView {
const propName = this.getNameForNode(prop);
this.namespaceStack.push(propName);
this.tokenize(prop);
this.trim(true);
this.punctuation(";", false, false);
this.namespaceStack.pop();
this.blankLines(0);
Expand Down Expand Up @@ -945,10 +932,11 @@ export class ApiView {
this.namespaceStack.pop();
if (isOperationSignature) {
if (x !== node.properties.length - 1) {
this.trim();
this.trim(true);
this.renderPunctuation(",");
}
} else {
this.trim(true);
this.renderPunctuation(";");
}
this.blankLines(0);
Expand Down

0 comments on commit 99fc49d

Please sign in to comment.