Skip to content

Commit

Permalink
feat: Add support for inputs deprecationMessage (#566)
Browse files Browse the repository at this point in the history
Add deprecation message to inputs table

Co-authored-by: Niek Palm <npalm@users.noreply.github.com>
  • Loading branch information
larmitage-bjss and npalm committed Mar 13, 2024
1 parent 5ea18d6 commit e283563
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
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
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

0 comments on commit e283563

Please sign in to comment.