Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for inputs deprecationMessage #566

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions __tests__/action-docs-action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ describe("Test update readme ", () => {
fixtureReadme: path.join(fixtureDir, "two_actions_readme.output"),
});
});

test("Readme for deprecated inputs", async () => {
await testReadme({
sourceFile: path.join(fixtureDir, "deprecated_input_action.yml"),
originalReadme: path.join(fixtureDir, "deprecated_input_action.input"),
fixtureReadme: path.join(fixtureDir, "deprecated_input_action.output"),
});
});
});

describe("Test usage format", () => {
Expand Down
1 change: 1 addition & 0 deletions __tests__/fixtures/action/deprecated_input_action.input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- action-docs-inputs action="__tests__/fixtures/action/deprecated_input_action.yml" -->
8 changes: 8 additions & 0 deletions __tests__/fixtures/action/deprecated_input_action.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- action-docs-inputs action="__tests__/fixtures/action/deprecated_input_action.yml" -->
## Inputs

| name | description | required | default |
| --- | --- | --- | --- |
| `inputA` | <p>This is an input<br/><em>Deprecated: This input has been deprecated</em></p> | `false` | `""` |
| `inputB` | <p>This is an input<br/><em>Deprecated</em></p> | `false` | `""` |
<!-- action-docs-inputs action="__tests__/fixtures/action/deprecated_input_action.yml" -->
17 changes: 17 additions & 0 deletions __tests__/fixtures/action/deprecated_input_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "An Action"
description: "Test of deprecated inputs"
author: "Niek Palm"
inputs:
inputA:
required: false
description: This is an input
deprecationMessage: This input has been deprecated
npalm marked this conversation as resolved.
Show resolved Hide resolved
inputB:
required: false
description: This is an input
deprecationMessage: ''

runs:
using: "node12"
main: "dist/index.js"

10 changes: 10 additions & 0 deletions src/action-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ interface InputOutput {
description?: string;
default?: string;
type?: InputType;
deprecationMessage?: string;
}

function createMdTable(
Expand Down Expand Up @@ -415,6 +416,15 @@ function getInputOutput(

if (columnName === "name") {
rowValue = key;
} else if (columnName === "description") {
rowValue = value[columnName];
if (value["deprecationMessage"] !== undefined) {
rowValue += "<br/>_Deprecated";
if (value["deprecationMessage"] !== "") {
rowValue += `: ${value["deprecationMessage"]}`;
}
rowValue += "_";
}
} else if (columnName === "default") {
rowValue =
value[columnName] !== undefined && value[columnName] !== ""
Expand Down