Skip to content

Commit 9791f88

Browse files
committed
fix: enable paths in usage
1 parent 5f01ac1 commit 9791f88

21 files changed

+108
-20
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
@@ -25,7 +25,7 @@
2525
```yaml
2626
jobs:
2727
job1:
28-
uses: npalm/action-docs@v1
28+
uses: npalm/action-docs/__tests__/fixtures/workflow/all_fields_workflow.yml@v1
2929
with:
3030
inputA:
3131
# 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
@@ -24,7 +24,7 @@
2424
```yaml
2525
jobs:
2626
job1:
27-
uses: ***PROJECT***@***VERSION***
27+
uses: ***PROJECT******SOURCE_FILE***@***VERSION***
2828
with:
2929
inputA:
3030
# 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/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
@@ -118,21 +118,23 @@ function createMdTable(
118118
function createMdCodeBlock(
119119
data: ActionInputsOutputs,
120120
options: DefaultOptions,
121-
isAction = true,
121+
isAction: boolean,
122122
): string {
123123
let codeBlockArray = ["```yaml"];
124124

125125
let indent = "";
126126

127127
if (isAction) {
128-
codeBlockArray.push("- uses: ***PROJECT***@***VERSION***");
128+
codeBlockArray.push("- uses: ***PROJECT******SOURCE_FILE***@***VERSION***");
129129
indent += " ";
130130
} else {
131131
codeBlockArray.push("jobs:");
132132
indent += " ";
133133
codeBlockArray.push(`${indent}job1:`);
134134
indent += " ";
135-
codeBlockArray.push(`${indent}uses: ***PROJECT***@***VERSION***`);
135+
codeBlockArray.push(
136+
`${indent}uses: ***PROJECT******SOURCE_FILE***@***VERSION***`,
137+
);
136138
}
137139

138140
const inputs = getInputOutput(
@@ -352,6 +354,10 @@ async function updateReadme(
352354
.replace(
353355
"***VERSION***",
354356
matchProjectVersion ? matchProjectVersion[2] : "",
357+
)
358+
.replace(
359+
"***SOURCE_FILE***",
360+
sourceFile !== defaultOptions.sourceFile ? `/${sourceFile}` : "",
355361
);
356362

357363
await replaceInFile.replaceInFile({

0 commit comments

Comments
 (0)