From d7dee9bcfe0aa2eed5da558fe6717881d76a78d1 Mon Sep 17 00:00:00 2001 From: grafanabot Date: Wed, 29 May 2024 07:01:54 +0000 Subject: [PATCH] Update `make docs` procedure --- docs/make-docs | 84 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/docs/make-docs b/docs/make-docs index 0a1730e6c6fe..f531df2ebb17 100755 --- a/docs/make-docs +++ b/docs/make-docs @@ -6,6 +6,17 @@ # [Semantic versioning](https://semver.org/) is used to help the reader identify the significance of changes. # Changes are relevant to this script and the support docs.mk GNU Make interface. # +# ## 8.0.0 (2024-05-28) +# +# ### Changed +# +# - Add environment variable `OUTPUT_FORMAT` to control the output of commands. +# +# The default value is `human` and means the output format is human readable. +# The value `json` is also supported and outputs JSON. +# +# Note that the `json` format isn't supported by `make docs`, only `make doc-validator` and `make vale`. +# # ## 7.0.0 (2024-05-03) # # ### Changed @@ -255,6 +266,8 @@ readonly HUGO_REFLINKSERRORLEVEL="${HUGO_REFLINKSERRORLEVEL:-WARNING}" readonly VALE_MINALERTLEVEL="${VALE_MINALERTLEVEL:-error}" readonly WEBSITE_EXEC="${WEBSITE_EXEC:-make server-docs}" +readonly OUTPUT_FORMAT="${OUTPUT_FORMAT:-human}" + PODMAN="$(if command -v podman >/dev/null 2>&1; then echo podman; else echo docker; fi)" if ! command -v curl >/dev/null 2>&1; then @@ -748,45 +761,74 @@ POSIX_HERESTRING case "${image}" in 'grafana/doc-validator') - if ! command -v jq >/dev/null 2>&1; then - errr '`jq` must be installed for the `doc-validator` target to work.' - note 'To install `jq`, refer to https://jqlang.github.io/jq/download/,' - - exit 1 - fi - proj="$(new_proj "$1")" printf '\r\n' - "${PODMAN}" run \ + + IFS='' read -r cmd </dev/null 2>&1; then + errr '`jq` must be installed for the `doc-validator` target to work.' + note 'To install `jq`, refer to https://jqlang.github.io/jq/download/,' + + exit 1 + fi + + ${cmd} \ + | jq -r '"ERROR: \(.location.path):\(.location.range.start.line // 1):\(.location.range.start.column // 1): \(.message)" + if .suggestions[0].text then "\nSuggestion: \(.suggestions[0].text)" else "" end' + ;; + json) + ${cmd} + ;; + *) # default + errr "Invalid output format '${OUTPUT_FORMAT}'" + esac ;; 'grafana/vale') proj="$(new_proj "$1")" printf '\r\n' - "${PODMAN}" run \ + IFS='' read -r cmd <