|
| 1 | +# See: https://taskfile.dev/#/usage |
| 2 | +version: "3" |
| 3 | + |
| 4 | +tasks: |
| 5 | + docs:generate: |
| 6 | + desc: Create all generated documentation content |
| 7 | + |
| 8 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 9 | + markdown:check-links: |
| 10 | + desc: Check for broken links |
| 11 | + deps: |
| 12 | + - task: docs:generate |
| 13 | + - task: npm:install-deps |
| 14 | + cmds: |
| 15 | + - | |
| 16 | + if [[ "{{.OS}}" == "Windows_NT" ]]; then |
| 17 | + # npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows, |
| 18 | + # so the Windows user is required to have markdown-link-check installed and in PATH. |
| 19 | + if ! which markdown-link-check &>/dev/null; then |
| 20 | + echo "markdown-link-check not found or not in PATH. Please install: https://github.com/tcort/markdown-link-check#readme" |
| 21 | + exit 1 |
| 22 | + fi |
| 23 | + # Default behavior of the task on Windows is to exit the task when the first broken link causes a non-zero |
| 24 | + # exit status, but it's better to check all links before exiting. |
| 25 | + set +o errexit |
| 26 | + STATUS=0 |
| 27 | + # Using -regex instead of -name to avoid Task's behavior of globbing even when quoted on Windows |
| 28 | + # The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives |
| 29 | + # \ characters special treatment on Windows in an attempt to support them as path separators. |
| 30 | + for file in $( |
| 31 | + find . \ |
| 32 | + -type d -name '.git' -prune -o \ |
| 33 | + -type d -name '.licenses' -prune -o \ |
| 34 | + -type d -name '__pycache__' -prune -o \ |
| 35 | + -type d -name 'node_modules' -prune -o \ |
| 36 | + -regex ".*[.]md" -print |
| 37 | + ); do |
| 38 | + markdown-link-check \ |
| 39 | + --quiet \ |
| 40 | + --config "./.markdown-link-check.json" \ |
| 41 | + "$file" |
| 42 | + STATUS=$(( $STATUS + $? )) |
| 43 | + done |
| 44 | + exit $STATUS |
| 45 | + else |
| 46 | + npx --package=markdown-link-check --call=' |
| 47 | + STATUS=0 |
| 48 | + for file in $( |
| 49 | + find . \ |
| 50 | + -type d -name '.git' -prune -o \ |
| 51 | + -type d -name '.licenses' -prune -o \ |
| 52 | + -type d -name '__pycache__' -prune -o \ |
| 53 | + -type d -name 'node_modules' -prune -o \ |
| 54 | + -regex ".*[.]md" -print |
| 55 | + ); do |
| 56 | + markdown-link-check \ |
| 57 | + --quiet \ |
| 58 | + --config "./.markdown-link-check.json" \ |
| 59 | + "$file" |
| 60 | + STATUS=$(( $STATUS + $? )) |
| 61 | + done |
| 62 | + exit $STATUS |
| 63 | + ' |
| 64 | + fi |
| 65 | +
|
| 66 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 67 | + markdown:fix: |
| 68 | + desc: Automatically correct linting violations in Markdown files where possible |
| 69 | + deps: |
| 70 | + - task: npm:install-deps |
| 71 | + cmds: |
| 72 | + - npx markdownlint-cli --fix "**/*.md" |
| 73 | + |
| 74 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 75 | + markdown:lint: |
| 76 | + desc: Check for problems in Markdown files |
| 77 | + deps: |
| 78 | + - task: npm:install-deps |
| 79 | + cmds: |
| 80 | + - npx markdownlint-cli "**/*.md" |
| 81 | + |
| 82 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml |
| 83 | + npm:install-deps: |
| 84 | + desc: Install dependencies managed by npm |
| 85 | + cmds: |
| 86 | + - npm install |
0 commit comments