Skip to content

Commit b5db5b1

Browse files
authored
generate inputs-outputs doc (#210)
- remove static docs/inputs-outputs.md - gitignore docs/inputs-outputs.md - add script to generate docs/inputs-outputs.md dynamically on build
1 parent 599f02b commit b5db5b1

File tree

6 files changed

+253
-290
lines changed

6 files changed

+253
-290
lines changed

action.yml

+172-62
Original file line numberDiff line numberDiff line change
@@ -5,118 +5,228 @@ branding:
55
icon: "check-circle"
66
color: "green"
77
inputs:
8-
thread-comments:
9-
description: >-
10-
Set this option to 'true' or 'false' to enable or disable the use of
11-
thread comments as feedback. Set this to 'update' to update an existing comment
12-
if one exists; the value 'true' will always delete an old comment and post a new one
13-
if necessary. Defaults to false.
14-
required: false
15-
default: 'false'
16-
no-lgtm:
17-
description: >-
18-
Set this option to true or false to enable or disable the use of a thread comment that
19-
basically says 'Looks Good To Me' (when all checks pass). Defaults to true.
20-
See `thread-comments` option for further details.
21-
required: false
22-
default: true
23-
step-summary:
24-
description: >
25-
Set this option to true to append content as part of workflow's job summary. Defaults to false.
26-
27-
See implementation details in GitHub's documentation about
28-
[Adding a job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary).
29-
This option is independent of the `thread-comments` option, rather this option uses the same content that
30-
the `thread-comments` option would use.
31-
required: false
32-
default: false
33-
file-annotations:
34-
description: Set this option to false to disable the use of file annotations as feedback. Defaults to true.
35-
required: false
36-
default: true
378
style:
38-
description: >
39-
The style rules to use (defaults to 'llvm').
40-
Set this to 'file' to have clang-format use the closest relative .clang-format file.
9+
description: |
10+
The style rules to use.
11+
12+
- Set this to `file` to have clang-format use the closest relative .clang-format file.
13+
- Set this to a blank string (`''`) to disable the use of clang-format entirely.
14+
- Any code style supported by the specified version of clang-format.
4115
required: false
4216
default: "llvm"
17+
minimum-version: '1.2.0'
4318
extensions:
44-
description: >
45-
The file extensions to run the action against.
46-
This comma-separated string defaults to 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx'.
19+
description: The file extensions to run the action against. This is a comma-separated string.
4720
required: false
4821
default: "c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx"
22+
minimum-version: '1.2.0'
4923
tidy-checks:
50-
description: >
51-
A string of regex-like patterns specifying what checks clang-tidy will use.
52-
This defaults to 'boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*'. See also clang-tidy docs for more info.
24+
description: |
25+
Comma-separated list of globs with optional `-` prefix.
26+
Globs are processed in order of appearance in the list.
27+
Globs without `-` prefix add checks with matching names to the set,
28+
globs with the `-` prefix remove checks with matching names from the set of enabled checks.
29+
This option's value is appended to the value of the 'Checks' option in a .clang-tidy file (if any).
30+
31+
- It is possible to disable clang-tidy entirely by setting this option to `'-*'`.
32+
- It is also possible to rely solely on a .clang-tidy config file by specifying this option as a blank string (`''`).
5333
required: false
5434
default: "boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*"
35+
minimum-version: '1.2.0'
5536
repo-root:
5637
description: >
57-
The relative path to the repository root directory. The default value '.' is relative to the runner's GITHUB_WORKSPACE environment variable.
38+
The relative path to the repository root directory.
39+
This path is relative to the path designated as the runner's `GITHUB_WORKSPACE` environment variable.
5840
required: false
59-
default: "."
41+
default: '.'
42+
minimum-version: '1.2.0'
6043
version:
61-
description: "The desired version of the clang tools to use. Accepted options are strings which can be 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8 or 7. Defaults to 12."
44+
description: |
45+
The desired version of the [clang-tools](https://github.com/cpp-linter/clang-tools-pip) to use.
46+
Accepted options are strings which can be 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8 or 7.
47+
48+
- Set this option to a blank string (`''`) to use the platform's default installed version.
49+
- This value can also be a path to where the clang tools are installed (if using a custom install location).
6250
required: false
63-
default: "12"
51+
default: 12
52+
minimum-version: '1.2.0'
6453
verbosity:
65-
description: A hidden option to control the action's log verbosity. This is the `logging` level (defaults to `info`).
54+
description: |
55+
This controls the action's verbosity in the workflow's logs.
56+
Supported options are `info` or `debug`.
57+
This option does not affect the verbosity of resulting thread comments or file annotations.
58+
59+
The verbosity can also be engaged by enabling debug logs when
60+
[re-running jobs or workflows](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs).
6661
required: false
6762
default: info
63+
minimum-version: '1.3.0'
6864
lines-changed-only:
69-
description: Set this option to 'true' to only analyze changes in the event's diff. Defaults to 'false'.
65+
description: |
66+
This controls what part of the files are analyzed. The following values are accepted:
67+
68+
- `false`: All lines in a file are analyzed.
69+
- `true`: Only lines in the diff that contain additions are analyzed.
70+
- `diff`: All lines in the diff are analyzed (including unchanged lines but not subtractions).
71+
72+
!!! info "Important"
73+
This feature requires special permissions to perform successfully.
74+
See our [documented permissions](permissions.md)
7075
required: false
7176
default: false
77+
minimum-version: '1.5.0'
78+
required-permission: 'content: read #file-changes'
7279
files-changed-only:
73-
description: Set this option to 'false' to analyze any source files in the repo. Defaults to 'true'.
80+
description: |
81+
Set this option to false to analyze any source files in the repo.
82+
This is automatically enabled if [`lines-changed-only`](#lines-changed-only) is enabled.
83+
84+
!!! info "Important"
85+
This feature requires special permissions to perform successfully.
86+
See our [documented permissions](permissions.md)
7487
required: false
7588
default: true
89+
minimum-version: '1.3.0'
90+
required-permission: 'content: read #file-changes'
7691
ignore:
77-
description: >
92+
description: |
7893
Set this option with string of path(s) to ignore.
7994
80-
- In the case of multiple paths, you can use a pipe character ('|')
81-
to separate the multiple paths. Multiple lines are forbidden as input to this option.
95+
- In the case of multiple paths, you can use a pipe character (`|`)
96+
to separate the multiple paths. Multiple lines are forbidden as an input to this option;
97+
it must be a single string.
8298
- This can also have files, but the file's relative path has to be specified
8399
as well.
84-
- There is no need to use './' for each entry; a blank string ('') represents
85-
the repo-root path (specified by the `repo-root` input option).
86-
- Path(s) containing a space should be inside single quotes.
87-
- Submodules are automatically ignored.
88-
- Prefix a path with a bang (`!`) to make it explicitly not ignored - order of
89-
multiple paths does take precedence. The `!` prefix can be applied to
90-
submodules if desired.
91-
- Glob patterns are not supported here. All asterisk characters ('*') are literal.
92-
required: false
93-
default: ".github"
100+
- There is no need to use `./` for each entry; a blank string (`''`) represents
101+
the [`repo-root`](#repo-root) path.
102+
- Submodules are automatically ignored. Hidden directories (beginning with a `.`) are also ignored
103+
automatically.
104+
- Prefix a path with a bang (`!`) to make it explicitly _not_ ignored. The order of
105+
multiple paths does _not_ take precedence. The `!` prefix can be applied to
106+
a submodule's path (if desired) but not hidden directories.
107+
- Glob patterns are not supported here. All asterisk characters (`*`) are literal.
108+
required: false
109+
default: '.github'
110+
minimum-version: '1.3.0'
111+
thread-comments:
112+
description: |
113+
This controls the behavior of posted thread comments as feedback. The following options are supported:
114+
115+
- `true`: enable the use of thread comments. This will always delete an outdated thread comment and post a new comment (triggering a notification for every comment).
116+
- `update`: update an existing thread comment if one already exists. This option does not trigger a new notification for every thread comment update.
117+
- `false`: disable the use of thread comments.
118+
119+
!!! info "Important"
120+
This feature requires special permissions to perform successfully.
121+
See our [documented permissions](permissions.md)
122+
123+
> [!NOTE]
124+
> If run on a private repository, then this feature is disabled because the GitHub REST API behaves differently for thread comments on a private repository.
125+
required: false
126+
default: 'false'
127+
minimum-version: '2.6.2'
128+
required-permission: 'issues: write #thread-comments'
129+
no-lgtm:
130+
description: |
131+
Set this option to true or false to enable or disable the use of a
132+
thread comment or pull request review that basically says 'Looks Good To Me' (when all checks pass).
133+
The default value, `true` means no LGTM comment posted.
134+
135+
See [`thread-comments`](#thread-comments), [`tidy-review`](#tidy-review),
136+
and [`format-review`](#format-review) options for further details.
137+
required: false
138+
default: true
139+
minimum-version: '2.6.2'
140+
step-summary:
141+
description: |
142+
Set this option to true to append content as part of workflow's job summary.
143+
144+
See implementation details in GitHub's documentation about
145+
[Adding a job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary).
146+
This option is independent of the [`thread-comments`](#thread-comments) option,
147+
rather this option uses the same content that the
148+
[`thread-comments`](#thread-comments) option would use.
149+
150+
> [!NOTE]
151+
> The [`no-lgtm`](#no-lgtm) option is _not_ applied to step summaries.
152+
required: false
153+
default: false
154+
minimum-version: '2.6.0'
155+
file-annotations:
156+
description: |
157+
Set this option to false to disable the use of file annotations as feedback.
158+
required: false
159+
default: true
160+
minimum-version: '1.4.3'
94161
database:
95-
description: The directory containing compile_commands.json file.
162+
description: The directory containing compilation database (like compile_commands.json) file.
96163
required: false
97164
default: ""
165+
minimum-version: '1.4.0'
98166
extra-args:
99-
description: A string of extra arguments passed to clang-tidy for use as compiler arguments. Multiple arguments are separated by spaces so the argument name and value should use an '=' sign instead of a space.
167+
description: |
168+
A string of extra arguments passed to clang-tidy for use as compiler arguments.
169+
Multiple arguments are separated by spaces so the argument name and value should
170+
use an `=` sign instead of a space.
171+
172+
!!! example
173+
174+
``` yaml
175+
extra-args: '-std=c++17 -Wall'
176+
```
177+
This will be passed to clang-tidy as multiple `--extra-arg` options:
178+
```
179+
clang-tidy --extra-arg=-std=c++17 --extra-arg=-Wall
180+
```
100181
required: false
101182
default: ""
183+
minimum-version: '2.1.0'
102184
tidy-review:
103-
description: Set this to true to enable PR reviews from clang-tidy. See also https://cpp-linter.github.io/cpp-linter/pr_review_caveats.html
185+
description: |
186+
Set this option to `true` to enable Pull Request reviews from clang-tidy.
187+
188+
!!! info "Important"
189+
This feature requires special permissions to perform successfully.
190+
See our [documented permissions](permissions.md).
191+
192+
See also [the PR review feature caveats](pr-review-caveats.md).
193+
194+
> [!NOTE]
195+
> The [`no-lgtm`](#no-lgtm) option is applicable to Pull Request reviews.
104196
required: false
105197
default: false
198+
experimental: true
199+
minimum-version: '2.9.0'
200+
required-permission: 'pull_request: write #pull-request-reviews'
106201
format-review:
107-
description: Set this to true to enable PR reviews from clang-format.See also https://cpp-linter.github.io/cpp-linter/pr_review_caveats.html
202+
description: |
203+
Set this option to `true` to enable Pull Request reviews from clang-format.
204+
205+
!!! info "Important"
206+
This feature requires special permissions to perform successfully.
207+
See our [documented permissions](permissions.md).
208+
209+
See also [the PR review feature caveats](pr-review-caveats.md).
210+
211+
> [!NOTE]
212+
> The [`no-lgtm`](#no-lgtm) option is applicable to Pull Request reviews.
108213
required: false
109214
default: false
215+
minimum-version: '2.9.0'
216+
required-permission: 'pull_request: write #pull-request-reviews'
110217
outputs:
111218
checks-failed:
112219
description: An integer that can be used as a boolean value to indicate if any checks failed by clang-tidy and clang-format.
113220
value: ${{ steps.cpp-linter-unix.outputs.checks-failed || steps.cpp-linter-windows.outputs.checks-failed }}
221+
minimum-version: '1.2.0'
114222
clang-tidy-checks-failed:
115223
description: An integer that can be used as a boolean value to indicate if any checks failed by clang-tidy only.
116224
value: ${{ steps.cpp-linter-unix.outputs.clang-tidy-checks-failed || steps.cpp-linter-windows.outputs.clang-tidy-checks-failed }}
225+
minimum-version: '2.7.2'
117226
clang-format-checks-failed:
118227
description: An integer that can be used as a boolean value to indicate if any checks failed by clang-format only.
119228
value: ${{ steps.cpp-linter-unix.outputs.clang-format-checks-failed || steps.cpp-linter-windows.outputs.clang-format-checks-failed }}
229+
minimum-version: '2.7.2'
120230
runs:
121231
using: "composite"
122232
steps:

docs/badge_hook.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def _badge_for_version(text: str, page: Page, files: Files):
5252
icon = "material-tag-outline"
5353
href = f"https://github.com/cpp-linter/cpp-linter-action/releases/v{text}"
5454
return _badge(
55-
icon=f'[:{icon}:]({href} "required version")',
56-
text=f'[{text}]({href} "required version")',
55+
icon=f'[:{icon}:]({href} "minimum version")',
56+
text=f'[{text}]({href} "minimum version")',
5757
)
5858

5959

docs/gen_io_doc.py

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from pathlib import Path
2+
from typing import Union
3+
import yaml
4+
import mkdocs_gen_files
5+
6+
FILENAME = "inputs-outputs.md"
7+
8+
with mkdocs_gen_files.open(FILENAME, "w") as io_doc:
9+
action_yml = Path(__file__).parent.parent / "action.yml"
10+
action_dict = yaml.safe_load(action_yml.read_bytes())
11+
doc = "".join(
12+
[
13+
"---\ntitle: Inputs and Outputs\n---\n\n"
14+
"<!--\n",
15+
" this page was generated from action.yml ",
16+
"using the gen_io_doc.py script.\n",
17+
" CHANGES TO inputs-outputs.md WILL BE LOST & OVERWRITTEN\n-->\n\n",
18+
"# Inputs and Outputs\n\n",
19+
"These are the action inputs and outputs offered by cpp-linter-action.\n",
20+
]
21+
)
22+
assert "inputs" in action_dict
23+
doc += "\n## Inputs\n"
24+
for action_input, input_metadata in action_dict["inputs"].items():
25+
doc += f"### `{action_input}`\n\n"
26+
27+
assert "minimum-version" in input_metadata
28+
min_ver = input_metadata["minimum-version"]
29+
doc += f"<!-- md:version {min_ver} -->\n"
30+
31+
assert "default" in input_metadata
32+
default: Union[str, bool] = input_metadata["default"]
33+
if isinstance(default, bool):
34+
default = str(default).lower()
35+
elif isinstance(default, str):
36+
default = repr(default) # add quotes around value
37+
doc += f"<!-- md:default {default} -->\n"
38+
39+
if "experimental" in input_metadata and input_metadata["experimental"] is True:
40+
doc += "<!-- md:flag experimental -->\n"
41+
42+
if "required-permission" in input_metadata:
43+
permission = input_metadata["required-permission"]
44+
doc += f"<!-- md:permission {permission} -->\n"
45+
46+
assert "description" in input_metadata
47+
doc += "\n" + input_metadata["description"] + "\n"
48+
49+
assert "outputs" in action_dict
50+
doc += (
51+
"\n## Outputs\n\nThis action creates 3 output variables. Even if the linting "
52+
"checks fail for source files this action will still pass, but users' CI "
53+
"workflows can use this action's outputs to exit the workflow early if that is "
54+
"desired.\n"
55+
)
56+
for action_output, output_metadata in action_dict["outputs"].items():
57+
doc += f"\n### `{action_output}`\n\n"
58+
59+
assert "minimum-version" in output_metadata
60+
min_ver = output_metadata["minimum-version"]
61+
doc += f"<!-- md:version {min_ver} -->\n"
62+
63+
64+
assert "description" in output_metadata
65+
doc += "\n" + output_metadata["description"] + "\n"
66+
67+
print(doc, file=io_doc)
68+
69+
mkdocs_gen_files.set_edit_path(FILENAME, "gen_io_doc.py")

0 commit comments

Comments
 (0)