@@ -43,6 +43,11 @@ tasks:
4343 -s "{{.WORKFLOW_SCHEMA_PATH}}" \
4444 -d "{{.WORKFLOWS_DATA_PATH}}"
4545
46+ docs:generate :
47+ desc : Create all generated documentation content
48+ # This is an "umbrella" task used to call any documentation generation processes the project has.
49+ # It can be left empty if there are none.
50+
4651 # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml
4752 general:cache-dep-licenses :
4853 desc : Cache dependency license metadata
@@ -118,6 +123,81 @@ tasks:
118123 cmds :
119124 - go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
120125
126+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
127+ markdown:check-links :
128+ desc : Check for broken links
129+ deps :
130+ - task : docs:generate
131+ - task : npm:install-deps
132+ cmds :
133+ - |
134+ if [[ "{{.OS}}" == "Windows_NT" ]]; then
135+ # npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows,
136+ # so the Windows user is required to have markdown-link-check installed and in PATH.
137+ if ! which markdown-link-check &>/dev/null; then
138+ echo "markdown-link-check not found or not in PATH."
139+ echo "Please install: https://github.com/tcort/markdown-link-check#readme"
140+ exit 1
141+ fi
142+ # Default behavior of the task on Windows is to exit the task when the first broken link causes a non-zero
143+ # exit status, but it's better to check all links before exiting.
144+ set +o errexit
145+ STATUS=0
146+ # Using -regex instead of -name to avoid Task's behavior of globbing even when quoted on Windows
147+ # The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives
148+ # \ characters special treatment on Windows in an attempt to support them as path separators.
149+ for file in $(
150+ find . \
151+ -type d -name '.git' -prune -o \
152+ -type d -name '.licenses' -prune -o \
153+ -type d -name '__pycache__' -prune -o \
154+ -type d -name 'node_modules' -prune -o \
155+ -regex ".*[.]md" -print
156+ ); do
157+ markdown-link-check \
158+ --quiet \
159+ --config "./.markdown-link-check.json" \
160+ "$file"
161+ STATUS=$(( $STATUS + $? ))
162+ done
163+ exit $STATUS
164+ else
165+ npx --package=markdown-link-check --call='
166+ STATUS=0
167+ for file in $(
168+ find . \
169+ -type d -name '.git' -prune -o \
170+ -type d -name '.licenses' -prune -o \
171+ -type d -name '__pycache__' -prune -o \
172+ -type d -name 'node_modules' -prune -o \
173+ -regex ".*[.]md" -print
174+ ); do
175+ markdown-link-check \
176+ --quiet \
177+ --config "./.markdown-link-check.json" \
178+ "$file"
179+ STATUS=$(( $STATUS + $? ))
180+ done
181+ exit $STATUS
182+ '
183+ fi
184+
185+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
186+ markdown:fix :
187+ desc : Automatically correct linting violations in Markdown files where possible
188+ deps :
189+ - task : npm:install-deps
190+ cmds :
191+ - npx markdownlint-cli --fix "**/*.md"
192+
193+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
194+ markdown:lint :
195+ desc : Check for problems in Markdown files
196+ deps :
197+ - task : npm:install-deps
198+ cmds :
199+ - npx markdownlint-cli "**/*.md"
200+
121201 # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
122202 npm:install-deps :
123203 desc : Install dependencies managed by npm
0 commit comments