Skip to content

Commit

Permalink
test error from empty id attribute in update-checks-doc script
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Oct 21, 2024
1 parent d32b16e commit 141b363
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scripts/update-checks-doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@ This script does:
- update the outputs of the example inputs; the code blocks after `Output:` header
- update the links to the [playground](https://rhysd.github.io/actionlint/) for the example inputs

For making the implementation simple, this script does not support Windows. Please run this script
on Linux or macOS.
For making the implementation simple, this script does not support Windows.

## Prerequisites

- Go
- Linux or macOS
- `shellcheck` command
- `pyflakes` command

## Usage

```
go run ./scripts/update-checks-doc [-check] FILE
```

Update the document. This command directly modifies the file.

```sh
Expand Down
3 changes: 3 additions & 0 deletions scripts/update-checks-doc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ func Update(in []byte) ([]byte, error) {
}
if strings.HasPrefix(l, `<a id="`) && strings.HasSuffix(l, `"></a>`) {
anchor = strings.TrimSuffix(strings.TrimPrefix(l, `<a id="`), `"></a>`)
if len(anchor) == 0 {
return nil, fmt.Errorf("id for <a> tag is empty at line %d", lnum)
}
}
if l == "Example input:" {
log.Printf("Found example input header for %q at line %d", section, lnum)
Expand Down
23 changes: 23 additions & 0 deletions scripts/update-checks-doc/testdata/err/empty_anchor_id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<a id=""></a>
## Hello

Example input:

```yaml
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: echo ${{ unknown }}
```
Output:
```
This section will be generated
```

[Playground](https://rhysd.github.io/actionlint/#THIS_URL_WILL_BE_UPDATED)

The `id` attribute of the `<a>` is an empty string.

0 comments on commit 141b363

Please sign in to comment.