Merge pull request #180 from github/lauraway/hover-context-display
Hover: Separate out function contexts and remove `()`
This commit is contained in:
@@ -154,7 +154,8 @@ jobs:
|
|||||||
|
|
||||||
// The `ref` is a `string` definition and inherits the context from `step-with`
|
// The `ref` is a `string` definition and inherits the context from `step-with`
|
||||||
const expected =
|
const expected =
|
||||||
"Available expression contexts: `github`, `inputs`, `vars`, `needs`, `strategy`, `matrix`, `secrets`, `steps`, `job`, `runner`, `env`, `hashFiles(1,255)`";
|
"Available expression contexts: `github`, `inputs`, `vars`, `needs`, `strategy`, `matrix`, `secrets`, `steps`, `job`, `runner`, `env`\n\n" +
|
||||||
|
"Available expression functions: `hashFiles`";
|
||||||
expect(result?.contents).toEqual(expected);
|
expect(result?.contents).toEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -180,7 +181,8 @@ jobs:
|
|||||||
|
|
||||||
const expected =
|
const expected =
|
||||||
"The branch, tag or SHA to checkout.\n\n" +
|
"The branch, tag or SHA to checkout.\n\n" +
|
||||||
"Available expression contexts: `github`, `inputs`, `vars`, `needs`, `strategy`, `matrix`, `secrets`, `steps`, `job`, `runner`, `env`, `hashFiles(1,255)`";
|
"Available expression contexts: `github`, `inputs`, `vars`, `needs`, `strategy`, `matrix`, `secrets`, `steps`, `job`, `runner`, `env`\n\n" +
|
||||||
|
"Available expression functions: `hashFiles`";
|
||||||
expect(result?.contents).toEqual(expected);
|
expect(result?.contents).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -112,13 +112,23 @@ function appendContext(description: string, allowedContext?: string[]) {
|
|||||||
if (!allowedContext || allowedContext.length == 0) {
|
if (!allowedContext || allowedContext.length == 0) {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
let {namedContexts, functions} = splitAllowedContext(allowedContext);
|
||||||
|
let namedContextsString = "";
|
||||||
|
let functionsString = "";
|
||||||
|
|
||||||
const contextDescription = `Available expression contexts: ${allowedContext.map(c => `\`${c}\``).join(", ")}`;
|
if (namedContexts.length > 0) {
|
||||||
if (description.length == 0) {
|
namedContextsString = `${description.length > 0 ? `\n\n` : ""}Available expression contexts: ${namedContexts
|
||||||
return contextDescription;
|
.map(x => `\`${x}\``)
|
||||||
|
.join(", ")}`;
|
||||||
|
}
|
||||||
|
if (functions.length > 0) {
|
||||||
|
functionsString = `${namedContexts.length > 0 ? `\n\n` : ""}Available expression functions: ${functions
|
||||||
|
.map(x => x.name)
|
||||||
|
.map(x => `\`${x}\``)
|
||||||
|
.join(", ")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${description}\n\n${contextDescription}`;
|
return `${description}${namedContextsString}${functionsString}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDescription(
|
async function getDescription(
|
||||||
|
|||||||
Reference in New Issue
Block a user