Merge pull request #74 from github/cschleiden/expression-docs
Use markdown details for (expression) auto-completions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {TextEdit} from "vscode-languageserver-types";
|
||||
import {MarkupContent, TextEdit} from "vscode-languageserver-types";
|
||||
import {complete} from "./complete";
|
||||
import {WorkflowContext} from "./context/workflow-context";
|
||||
import {registerLogger} from "./log";
|
||||
@@ -311,7 +311,7 @@ jobs:
|
||||
]);
|
||||
|
||||
// Includes detail when available. Using continue-on-error as a sample here.
|
||||
expect(result.map(x => x.detail)).toContain(
|
||||
expect(result.map(x => (x.documentation as MarkupContent)?.value)).toContain(
|
||||
"Prevents a job from failing when a step fails. Set to true to allow a job to pass when this step fails."
|
||||
);
|
||||
});
|
||||
@@ -337,7 +337,7 @@ o|
|
||||
const result = await complete(...getPositionFromCursor(input));
|
||||
const onResult = result.find(x => x.label === "on");
|
||||
expect(onResult).not.toBeUndefined();
|
||||
expect(onResult?.detail).toEqual(
|
||||
expect((onResult!.documentation as MarkupContent).value).toEqual(
|
||||
"The name of the GitHub event that triggers the workflow. You can provide a single event string, array of events, array of event types, or an event configuration map that schedules a workflow or restricts the execution of a workflow to specific files, tags, or branch changes. For a list of available events, see https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows."
|
||||
);
|
||||
});
|
||||
@@ -348,7 +348,7 @@ o|
|
||||
const result = await complete(...getPositionFromCursor(input));
|
||||
const dispatchResult = result.find(x => x.label === "workflow_dispatch");
|
||||
expect(dispatchResult).not.toBeUndefined();
|
||||
expect(dispatchResult?.detail).toEqual(
|
||||
expect((dispatchResult!.documentation as MarkupContent).value).toEqual(
|
||||
"You can now create workflows that are manually triggered with the new workflow_dispatch event. You will then see a 'Run workflow' button on the Actions tab, enabling you to easily trigger a run."
|
||||
);
|
||||
});
|
||||
|
||||
@@ -109,7 +109,10 @@ export async function complete(
|
||||
|
||||
const item: CompletionItem = {
|
||||
label: value.label,
|
||||
detail: value.description,
|
||||
documentation: value.description && {
|
||||
kind: "markdown",
|
||||
value: value.description
|
||||
},
|
||||
tags: value.deprecated ? [CompletionItemTag.Deprecated] : undefined,
|
||||
textEdit: replaceRange ? TextEdit.replace(replaceRange, newText) : TextEdit.insert(position, newText)
|
||||
};
|
||||
@@ -212,6 +215,10 @@ function mapExpressionCompletionItem(item: ExpressionCompletionItem, charAfterPo
|
||||
}
|
||||
return {
|
||||
label: item.label,
|
||||
documentation: item.description && {
|
||||
kind: "markdown",
|
||||
value: item.description
|
||||
},
|
||||
insertText: insertText,
|
||||
kind: item.function ? CompletionItemKind.Function : CompletionItemKind.Variable
|
||||
};
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {TextDocument} from "vscode-languageserver-textdocument";
|
||||
import {hover} from "./hover";
|
||||
import {getPositionFromCursor} from "./test-utils/cursor-position";
|
||||
|
||||
@@ -25,7 +24,6 @@ jobs:
|
||||
expect(result?.contents).toEqual("Runs your workflow when you push a commit or tag.");
|
||||
});
|
||||
|
||||
|
||||
it("on a parameter with a description", async () => {
|
||||
const input = `on: push
|
||||
jobs:
|
||||
@@ -35,7 +33,7 @@ jobs:
|
||||
expect(result).not.toBeUndefined();
|
||||
expect(result?.contents).toEqual(
|
||||
"Prevents a workflow run from failing when a job fails. Set to true to allow a workflow run to pass when this job fails.\n\n" +
|
||||
"**Context:** github, inputs, vars, needs, strategy, matrix"
|
||||
"**Context:** github, inputs, vars, needs, strategy, matrix"
|
||||
);
|
||||
});
|
||||
|
||||
@@ -52,7 +50,7 @@ jobs:
|
||||
});
|
||||
|
||||
it("on a value in a sequence", async () => {
|
||||
const input = `on: [pull_request,
|
||||
const input = `on: [pull_request,
|
||||
pu|sh]
|
||||
jobs:
|
||||
build:
|
||||
|
||||
Generated
+6
-6
@@ -685,9 +685,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@github/actions-expressions": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://npm.pkg.github.com/download/@github/actions-expressions/0.0.8/055f455fcb0ed907f52c349b9385728aeed38f9a",
|
||||
"integrity": "sha512-SPuGfnjgKAbMzJNCk4sZPAK2bxHlRXDJCk6vrwIi9VJL16Eh1YyiyM4fU9kV5EXEE5AV9aPFlZAPXu6t0mmBNw==",
|
||||
"version": "0.0.9",
|
||||
"resolved": "https://npm.pkg.github.com/download/@github/actions-expressions/0.0.9/9124cb4602858cf4e97ca01ec4371bac7bd278df",
|
||||
"integrity": "sha512-6cgVHf2t2wYeFkF0rSZ6t65ttP+RNf2g5pL9QlA9AAkHqX1bym0yO6AzMt1XUjQn+fJN+Di+xvVJkJT4fpgSDA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 16"
|
||||
@@ -13526,9 +13526,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@github/actions-expressions": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://npm.pkg.github.com/download/@github/actions-expressions/0.0.8/055f455fcb0ed907f52c349b9385728aeed38f9a",
|
||||
"integrity": "sha512-SPuGfnjgKAbMzJNCk4sZPAK2bxHlRXDJCk6vrwIi9VJL16Eh1YyiyM4fU9kV5EXEE5AV9aPFlZAPXu6t0mmBNw=="
|
||||
"version": "0.0.9",
|
||||
"resolved": "https://npm.pkg.github.com/download/@github/actions-expressions/0.0.9/9124cb4602858cf4e97ca01ec4371bac7bd278df",
|
||||
"integrity": "sha512-6cgVHf2t2wYeFkF0rSZ6t65ttP+RNf2g5pL9QlA9AAkHqX1bym0yO6AzMt1XUjQn+fJN+Di+xvVJkJT4fpgSDA=="
|
||||
},
|
||||
"@github/actions-languageserver": {
|
||||
"version": "file:actions-languageserver",
|
||||
|
||||
Reference in New Issue
Block a user