diff --git a/scripts/update-checks-doc/README.md b/scripts/update-checks-doc/README.md index 8471f0766..63448ecc3 100644 --- a/scripts/update-checks-doc/README.md +++ b/scripts/update-checks-doc/README.md @@ -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 diff --git a/scripts/update-checks-doc/main.go b/scripts/update-checks-doc/main.go index c22232a20..dc8fb43ed 100644 --- a/scripts/update-checks-doc/main.go +++ b/scripts/update-checks-doc/main.go @@ -113,6 +113,9 @@ func Update(in []byte) ([]byte, error) { } if strings.HasPrefix(l, ``) { anchor = strings.TrimSuffix(strings.TrimPrefix(l, ``) + if len(anchor) == 0 { + return nil, fmt.Errorf("id for tag is empty at line %d", lnum) + } } if l == "Example input:" { log.Printf("Found example input header for %q at line %d", section, lnum) diff --git a/scripts/update-checks-doc/testdata/err/empty_anchor_id.md b/scripts/update-checks-doc/testdata/err/empty_anchor_id.md new file mode 100644 index 000000000..3fcf1e9fa --- /dev/null +++ b/scripts/update-checks-doc/testdata/err/empty_anchor_id.md @@ -0,0 +1,23 @@ + +## 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 `` is an empty string.