@@ -11,13 +11,16 @@ tasks:
1111 - task : action:validate
1212 - task : general:check-formatting
1313 - task : general:check-spelling
14+ - task : markdown:check-links
15+ - task : markdown:lint
1416 - task : python:lint
1517 - task : python:test
1618
1719 fix :
1820 desc : Make automated corrections to the project's files
1921 deps :
2022 - task : general:correct-spelling
23+ - task : markdown:fix
2124 - task : python:format
2225
2326 # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-action-metadata-task/Taskfile.yml
@@ -42,6 +45,11 @@ tasks:
4245 -s "{{.ACTION_METADATA_SCHEMA_PATH}}" \
4346 -d "action.yml"
4447
48+ docs:generate :
49+ desc : Create all generated documentation content
50+ # This is an "umbrella" task used to call any documentation generation processes the project has.
51+ # It can be left empty if there are none.
52+
4553 # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-files-task/Taskfile.yml
4654 general:check-filenames :
4755 desc : Check for non-portable filenames
@@ -171,6 +179,81 @@ tasks:
171179 cmds :
172180 - poetry run codespell --write-changes
173181
182+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
183+ markdown:check-links :
184+ desc : Check for broken links
185+ deps :
186+ - task : docs:generate
187+ - task : npm:install-deps
188+ cmds :
189+ - |
190+ if [[ "{{.OS}}" == "Windows_NT" ]]; then
191+ # npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows,
192+ # so the Windows user is required to have markdown-link-check installed and in PATH.
193+ if ! which markdown-link-check &>/dev/null; then
194+ echo "markdown-link-check not found or not in PATH."
195+ echo "Please install: https://github.com/tcort/markdown-link-check#readme"
196+ exit 1
197+ fi
198+ # Default behavior of the task on Windows is to exit the task when the first broken link causes a non-zero
199+ # exit status, but it's better to check all links before exiting.
200+ set +o errexit
201+ STATUS=0
202+ # Using -regex instead of -name to avoid Task's behavior of globbing even when quoted on Windows
203+ # The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives
204+ # \ characters special treatment on Windows in an attempt to support them as path separators.
205+ for file in $(
206+ find . \
207+ -type d -name '.git' -prune -o \
208+ -type d -name '.licenses' -prune -o \
209+ -type d -name '__pycache__' -prune -o \
210+ -type d -name 'node_modules' -prune -o \
211+ -regex ".*[.]md" -print
212+ ); do
213+ markdown-link-check \
214+ --quiet \
215+ --config "./.markdown-link-check.json" \
216+ "$file"
217+ STATUS=$(( $STATUS + $? ))
218+ done
219+ exit $STATUS
220+ else
221+ npx --package=markdown-link-check --call='
222+ STATUS=0
223+ for file in $(
224+ find . \
225+ -type d -name '.git' -prune -o \
226+ -type d -name '.licenses' -prune -o \
227+ -type d -name '__pycache__' -prune -o \
228+ -type d -name 'node_modules' -prune -o \
229+ -regex ".*[.]md" -print
230+ ); do
231+ markdown-link-check \
232+ --quiet \
233+ --config "./.markdown-link-check.json" \
234+ "$file"
235+ STATUS=$(( $STATUS + $? ))
236+ done
237+ exit $STATUS
238+ '
239+ fi
240+
241+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
242+ markdown:fix :
243+ desc : Automatically correct linting violations in Markdown files where possible
244+ deps :
245+ - task : npm:install-deps
246+ cmds :
247+ - npx markdownlint-cli --fix "**/*.md"
248+
249+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
250+ markdown:lint :
251+ desc : Check for problems in Markdown files
252+ deps :
253+ - task : npm:install-deps
254+ cmds :
255+ - npx markdownlint-cli "**/*.md"
256+
174257 # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
175258 npm:install-deps :
176259 desc : Install dependencies managed by npm
0 commit comments