Skip to content

Commit e95fddc

Browse files
committed
fix: enable paths in usage
1 parent 097a335 commit e95fddc

22 files changed

+109
-21
lines changed

__tests__/action-docs-action.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ describe("Test output", () => {
6060
});
6161

6262
describe("Test update readme ", () => {
63+
test("With defaults.", async () => {
64+
await testReadme(
65+
{
66+
sourceFile: "action.yml", // Default value
67+
originalReadme: path.join(fixtureDir, "default_readme.input"),
68+
fixtureReadme: path.join(fixtureDir, "default_readme.output"),
69+
},
70+
{
71+
includeNameHeader: true,
72+
},
73+
);
74+
});
75+
6376
test("Empty readme (all fields)", async () => {
6477
await testReadme(
6578
{

__tests__/fixtures/action/action_deprecated.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Default test
1212
### Usage
1313

1414
```yaml
15-
- uses: npalm/action-docs@v1
15+
- uses: npalm/action-docs/__tests__/fixtures/action/all_fields_action.yml@v1
1616
with:
1717
inputA:
1818
# A description A

__tests__/fixtures/action/action_usage_readme.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## Usage
33

44
```yaml
5-
- uses: npalm/action-docs@v1
5+
- uses: npalm/action-docs/__tests__/fixtures/action/action.yml@v1
66
with:
77
inputA:
88
# - Item 1

__tests__/fixtures/action/all_fields_action.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This action is a `node12` action.
2828
## Usage
2929

3030
```yaml
31-
- uses: ***PROJECT***@***VERSION***
31+
- uses: ***PROJECT******SOURCE_FILE***@***VERSION***
3232
with:
3333
inputA:
3434
# A description A

__tests__/fixtures/action/all_fields_action_toc3_cli.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This action is a `node12` action.
2828
### Usage
2929

3030
```yaml
31-
- uses: ***PROJECT***@***VERSION***
31+
- uses: ***PROJECT******SOURCE_FILE***@***VERSION***
3232
with:
3333
inputA:
3434
# A description A

__tests__/fixtures/action/all_fields_one_annotation.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This action is a `node12` action.
2929
## Usage
3030

3131
```yaml
32-
- uses: npalm/action-docs@v1
32+
- uses: npalm/action-docs/__tests__/fixtures/action/all_fields_action.yml@v1
3333
with:
3434
inputA:
3535
# A description A

__tests__/fixtures/action/all_fields_readme.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Default test
1212
### Usage
1313

1414
```yaml
15-
- uses: npalm/action-docs@v1
15+
- uses: npalm/action-docs/__tests__/fixtures/action/all_fields_action.yml@v1
1616
with:
1717
inputA:
1818
# A description A

__tests__/fixtures/action/all_fields_usage_readme.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## Usage
33

44
```yaml
5-
- uses: npalm/action-docs@v1
5+
- uses: npalm/action-docs/__tests__/fixtures/action/all_fields_action.yml@v1
66
with:
77
inputA:
88
# A description A

__tests__/fixtures/action/default-with-header.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This action is a `node12` action.
2626
### Usage
2727

2828
```yaml
29-
- uses: ***PROJECT***@***VERSION***
29+
- uses: ***PROJECT******SOURCE_FILE***@***VERSION***
3030
with:
3131
inputA:
3232
# - Item 1

__tests__/fixtures/action/default.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This action is a `node12` action.
2424
## Usage
2525

2626
```yaml
27-
- uses: ***PROJECT***@***VERSION***
27+
- uses: ***PROJECT******SOURCE_FILE***@***VERSION***
2828
with:
2929
inputA:
3030
# - Item 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- action-docs-header source="action.yml" -->
2+
3+
<!-- action-docs-description source="action.yml" -->
4+
5+
<!-- action-docs-inputs source="action.yml" -->
6+
7+
<!-- action-docs-outputs source="action.yml" -->
8+
9+
<!-- action-docs-runs source="action.yml" -->
10+
11+
<!-- action-docs-usage source="action.yml" project="npalm/action-docs" version="v1" -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!-- action-docs-header source="action.yml" -->
2+
## An Action
3+
<!-- action-docs-header source="action.yml" -->
4+
5+
<!-- action-docs-description source="action.yml" -->
6+
### Description
7+
8+
Default test
9+
<!-- action-docs-description source="action.yml" -->
10+
11+
<!-- action-docs-inputs source="action.yml" -->
12+
### Inputs
13+
14+
| name | description | required | default |
15+
| --- | --- | --- | --- |
16+
| `inputA` | <ul> <li>Item 1<ul> <li>foo, bar, baz</li></ul></li> <li>Item 2<ul> <li><a href="https://github.com/">github</a></li> <li><strong>blah</strong></li></ul></li> <li>Item 3</li> </ul> | `false` | `test` |
17+
| `inputB` | <p>This is a multiline description</p> | `false` | `test` |
18+
<!-- action-docs-inputs source="action.yml" -->
19+
20+
<!-- action-docs-outputs source="action.yml" -->
21+
### Outputs
22+
23+
| name | description |
24+
| --- | --- |
25+
| `outputA` | <p>A description</p> |
26+
<!-- action-docs-outputs source="action.yml" -->
27+
28+
<!-- action-docs-runs source="action.yml" -->
29+
### Runs
30+
31+
This action is a `node12` action.
32+
<!-- action-docs-runs source="action.yml" -->
33+
34+
<!-- action-docs-usage source="action.yml" project="npalm/action-docs" version="v1" -->
35+
### Usage
36+
37+
```yaml
38+
- uses: npalm/action-docs@v1
39+
with:
40+
inputA:
41+
# - Item 1
42+
# - foo, bar, baz
43+
# - Item 2
44+
# - [github](https://github.com/)
45+
# - **blah**
46+
# - Item 3
47+
#
48+
# Required: false
49+
# Default: test
50+
51+
inputB:
52+
# This is a
53+
# multiline description
54+
#
55+
# Required: false
56+
# Default: test
57+
```
58+
<!-- action-docs-usage source="action.yml" project="npalm/action-docs" version="v1" -->

__tests__/fixtures/action/minimal_action.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This action is a `docker` action.
99
## Usage
1010

1111
```yaml
12-
- uses: ***PROJECT***@***VERSION***
12+
- uses: ***PROJECT******SOURCE_FILE***@***VERSION***
1313
```
1414

1515

__tests__/fixtures/workflow/all_fields_one_annotation.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
```yaml
3333
jobs:
3434
job1:
35-
uses: npalm/action-docs@v1
35+
uses: npalm/action-docs/__tests__/fixtures/workflow/all_fields_workflow.yml@v1
3636
with:
3737
inputA:
3838
# A description A

__tests__/fixtures/workflow/all_fields_readme.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
```yaml
99
jobs:
1010
job1:
11-
uses: npalm/action-docs@v1
11+
uses: npalm/action-docs/__tests__/fixtures/workflow/all_fields_workflow.yml@v1
1212
with:
1313
inputA:
1414
# A description A

__tests__/fixtures/workflow/all_fields_usage_readme.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
```yaml
55
jobs:
66
job1:
7-
uses: npalm/action-docs@v1
7+
uses: npalm/action-docs/__tests__/fixtures/workflow/all_fields_workflow.yml@v1
88
with:
99
inputA:
1010
# A description A

__tests__/fixtures/workflow/all_fields_workflow.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
```yaml
3232
jobs:
3333
job1:
34-
uses: ***PROJECT***@***VERSION***
34+
uses: ***PROJECT******SOURCE_FILE***@***VERSION***
3535
with:
3636
inputA:
3737
# A description A

__tests__/fixtures/workflow/default.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
```yaml
2121
jobs:
2222
job1:
23-
uses: ***PROJECT***@***VERSION***
23+
uses: ***PROJECT******SOURCE_FILE***@***VERSION***
2424
with:
2525
inputA:
2626
# - Item 1

__tests__/fixtures/workflow/minimal_workflow.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
```yaml
66
jobs:
77
job1:
8-
uses: ***PROJECT***@***VERSION***
8+
uses: ***PROJECT******SOURCE_FILE***@***VERSION***
99
```
1010

1111

__tests__/fixtures/workflow/secrets_workflow.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
```yaml
2828
jobs:
2929
job1:
30-
uses: ***PROJECT***@***VERSION***
30+
uses: ***PROJECT******SOURCE_FILE***@***VERSION***
3131
with:
3232
inputA:
3333
# - Item 1

__tests__/fixtures/workflow/workflow_usage_readme.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
```yaml
55
jobs:
66
job1:
7-
uses: npalm/action-docs@v1
7+
uses: npalm/action-docs/__tests__/fixtures/workflow/workflow.yml@v1
88
with:
99
inputA:
1010
# - Item 1

src/action-docs.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,23 @@ function createMdTable(
121121
function createMdCodeBlock(
122122
data: ActionInputsOutputs,
123123
options: DefaultOptions,
124-
isAction = true,
124+
isAction: boolean,
125125
): string {
126126
let codeBlockArray = ["```yaml"];
127127

128128
let indent = "";
129129

130130
if (isAction) {
131-
codeBlockArray.push("- uses: ***PROJECT***@***VERSION***");
131+
codeBlockArray.push("- uses: ***PROJECT******SOURCE_FILE***@***VERSION***");
132132
indent += " ";
133133
} else {
134134
codeBlockArray.push("jobs:");
135135
indent += " ";
136136
codeBlockArray.push(`${indent}job1:`);
137137
indent += " ";
138-
codeBlockArray.push(`${indent}uses: ***PROJECT***@***VERSION***`);
138+
codeBlockArray.push(
139+
`${indent}uses: ***PROJECT******SOURCE_FILE***@***VERSION***`,
140+
);
139141
}
140142

141143
const inputs = getInputOutput(
@@ -368,6 +370,10 @@ async function updateReadme(
368370
.replace(
369371
"***VERSION***",
370372
matchProjectVersion ? matchProjectVersion[2] : "",
373+
)
374+
.replace(
375+
"***SOURCE_FILE***",
376+
sourceFile !== defaultOptions.sourceFile ? `/${sourceFile}` : "",
371377
);
372378

373379
await replaceInFile.replaceInFile({

0 commit comments

Comments
 (0)