Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenWeatherford committed Sep 2, 2020
1 parent 7640451 commit 80ccf8a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/documents/templates/getDependsOnCompletions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MarkdownString } from "vscode";
import { assert } from "../../fixed_assert";
import * as Json from "../../language/json/JSON";
import { ContainsBehavior, Span } from "../../language/Span";
import { removeSingleQuotes } from "../../util/strings";
import { isSingleQuoted, removeSingleQuotes } from "../../util/strings";
import * as Completion from "../../vscodeIntegration/Completion";
import { TemplatePositionContext } from "../positionContexts/TemplatePositionContext";
import { getResourcesInfo, IJsonResourceInfo, IResourceInfo } from "./getResourcesInfo";
Expand Down Expand Up @@ -57,16 +57,26 @@ function getDependsOnCompletion(resource: IResourceInfo, span: Span): Completion

if (shortNameExpression && resourceIdExpression) {
const label = shortNameExpression;
let typeExpression = resource.getFullTypeExpression();
if (typeExpression && isSingleQuoted(typeExpression)) {
// Simplify the type expression to remove quotes and the first prefix (e.g. 'Microsoft.Compute/')
typeExpression = removeSingleQuotes(typeExpression);
typeExpression = typeExpression.replace(/^[^/]+\//, '');
}
const insertText = `"[${resourceIdExpression}]"`;
const detail = removeSingleQuotes(resource.getFullTypeExpression() ?? '');
const resourceResTypeMarkdown = `- **Name**: *${resource.getFullNameExpression()}*\n- **Type**: *${resource.getFullTypeExpression()}*`;
const longDocumentation = `Reference to resource\n${resourceResTypeMarkdown}`;
const detail = typeExpression;

//const resourceResTypeMarkdown = `- **Name**: *${resource.getFullNameExpression()}*\n- **Type**: *${resource.getFullTypeExpression()}*`;
// const resourceDocumentation = `#### Inserts a resourceId() reference to the following resource:\n${resourceResTypeMarkdown}`;
// const documentation = `\`\`\`csharp\n[${resourceIdExpression}]\n\`\`\`\n${resourceDocumentation}`;

const documentation = `Inserts this resourceId reference:\n\`\`\`arm-template\n"[${resourceIdExpression}]"\n\`\`\`\n<br/>`;

const item = new Completion.Item({
label,
insertText: insertText,
detail,
documentation: new MarkdownString(`${insertText}\n\n${longDocumentation}`),
documentation: new MarkdownString(documentation),
span,
kind: Completion.CompletionKind.dependsOnResourceId,
// Normally vscode uses label if this isn't specified, but it doesn't seem to like the "[" in the label,
Expand Down

0 comments on commit 80ccf8a

Please sign in to comment.