From e283563580e9f0cc0e71cd4205ef587e50845ef9 Mon Sep 17 00:00:00 2001 From: Laura Armitage <156074260+larmitage-bjss@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:02:32 +0000 Subject: [PATCH] feat: Add support for inputs deprecationMessage (#566) Add deprecation message to inputs table Co-authored-by: Niek Palm --- __tests__/action-docs-action.test.ts | 8 ++++++++ .../action/deprecated_input_action.input | 1 + .../action/deprecated_input_action.output | 8 ++++++++ .../fixtures/action/deprecated_input_action.yml | 17 +++++++++++++++++ src/action-docs.ts | 10 ++++++++++ 5 files changed, 44 insertions(+) create mode 100644 __tests__/fixtures/action/deprecated_input_action.input create mode 100644 __tests__/fixtures/action/deprecated_input_action.output create mode 100644 __tests__/fixtures/action/deprecated_input_action.yml diff --git a/__tests__/action-docs-action.test.ts b/__tests__/action-docs-action.test.ts index f2af111..0c867e2 100644 --- a/__tests__/action-docs-action.test.ts +++ b/__tests__/action-docs-action.test.ts @@ -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", () => { diff --git a/__tests__/fixtures/action/deprecated_input_action.input b/__tests__/fixtures/action/deprecated_input_action.input new file mode 100644 index 0000000..fa1eacc --- /dev/null +++ b/__tests__/fixtures/action/deprecated_input_action.input @@ -0,0 +1 @@ + diff --git a/__tests__/fixtures/action/deprecated_input_action.output b/__tests__/fixtures/action/deprecated_input_action.output new file mode 100644 index 0000000..4f57181 --- /dev/null +++ b/__tests__/fixtures/action/deprecated_input_action.output @@ -0,0 +1,8 @@ + +## Inputs + +| name | description | required | default | +| --- | --- | --- | --- | +| `inputA` |

This is an input
Deprecated: This input has been deprecated

| `false` | `""` | +| `inputB` |

This is an input
Deprecated

| `false` | `""` | + diff --git a/__tests__/fixtures/action/deprecated_input_action.yml b/__tests__/fixtures/action/deprecated_input_action.yml new file mode 100644 index 0000000..063c75b --- /dev/null +++ b/__tests__/fixtures/action/deprecated_input_action.yml @@ -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 + inputB: + required: false + description: This is an input + deprecationMessage: '' + +runs: + using: "node12" + main: "dist/index.js" + \ No newline at end of file diff --git a/src/action-docs.ts b/src/action-docs.ts index 28de31b..e243b4b 100644 --- a/src/action-docs.ts +++ b/src/action-docs.ts @@ -93,6 +93,7 @@ interface InputOutput { description?: string; default?: string; type?: InputType; + deprecationMessage?: string; } function createMdTable( @@ -415,6 +416,15 @@ function getInputOutput( if (columnName === "name") { rowValue = key; + } else if (columnName === "description") { + rowValue = value[columnName]; + if (value["deprecationMessage"] !== undefined) { + rowValue += "
_Deprecated"; + if (value["deprecationMessage"] !== "") { + rowValue += `: ${value["deprecationMessage"]}`; + } + rowValue += "_"; + } } else if (columnName === "default") { rowValue = value[columnName] !== undefined && value[columnName] !== ""