From a4a16b62c7a1ccb8d8d6679c318846e9472f634d Mon Sep 17 00:00:00 2001 From: Jack Baldry Date: Fri, 16 Jun 2023 18:45:44 +0100 Subject: [PATCH] Update make-docs procedure (#70265) ## 4.1.0 (2023-06-16) ### Added - Mounts of `layouts` and `config` directories for the `website` project. Ensures that local changes to mounts or shortcodes are reflected in the development server. ### Fixed - Version inference for versioned docs pages. Pages in versioned projects now have the `versioned: true` front matter set to ensure that "version" in $.Page.Scratch is set on builds. ## 4.0.0 (2023-06-06) ### Removed - `doc-validator/%` target. The behavior of the target was not as described. Instead, to limit `doc-validator` to only specific files, refer to https://grafana.com/docs/writers-toolkit/writing-guide/tooling-and-workflows/validate-technical-documentation/#run-on-specific-files. ## 3.0.0 (2023-05-18) ### Fixed - Compatibility with the updated Make targets in the `website` repository. `docs` now runs this script itself, `server-docs` builds the site with the `docs` Hugo environment. Signed-off-by: Jack Baldry --- docs/docs.mk | 7 +------ docs/make-docs | 53 +++++++++++++++++++++++++++++++++-------------- docs/variables.mk | 3 +++ 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/docs/docs.mk b/docs/docs.mk index 932b84facb3..4c729c57d7c 100644 --- a/docs/docs.mk +++ b/docs/docs.mk @@ -1,5 +1,5 @@ # The source of this file is https://raw.githubusercontent.com/grafana/writers-toolkit/main/docs/docs.mk. -# 2.0.0 (2023-05-18) +# 4.0.0 (2023-06-06) include variables.mk -include variables.mk.local @@ -105,11 +105,6 @@ doc-validator: ## Run doc-validator on the entire docs folder. doc-validator: make-docs DOCS_IMAGE=$(DOC_VALIDATOR_IMAGE) $(PWD)/make-docs $(PROJECTS) -.PHONY: doc-validator/% -doc-validator/%: ## Run doc-validator on a specific path. To lint the path /docs/sources/administration, run 'make doc-validator/administration'. -doc-validator/%: make-docs - DOCS_IMAGE=$(DOC_VALIDATOR_IMAGE) DOC_VALIDATOR_INCLUDE=$(subst doc-validator/,,$@) $(PWD)/make-docs $(PROJECTS) - .PHONY: vale vale: ## Run vale on the entire docs folder. vale: make-docs diff --git a/docs/make-docs b/docs/make-docs index e5dca68a151..3942bf483c3 100755 --- a/docs/make-docs +++ b/docs/make-docs @@ -1,6 +1,6 @@ #!/bin/sh # The source of this file is https://raw.githubusercontent.com/grafana/writers-toolkit/main/docs/make-docs. -# 2.0.0 (2023-05-18) +# 4.1.0 (2023-06-16) set -ef @@ -13,7 +13,7 @@ readonly DOC_VALIDATOR_SKIP_CHECKS="${DOC_VALIDATOR_SKIP_CHECKS:-^image-}" readonly HUGO_REFLINKSERRORLEVEL="${HUGO_REFLINKSERRORLEVEL:-WARNING}" readonly VALE_MINALERTLEVEL="${VALE_MINALERTLEVEL:-error}" -readonly WEBSITE_EXEC="${WEBSITE_EXEC:-make docs}" +readonly WEBSITE_EXEC="${WEBSITE_EXEC:-make server-docs}" # If set, the docs-base image will run a prebuild script that sets up Hugo mounts. readonly WEBSITE_MOUNTS="${WEBSITE_MOUNTS:-}" @@ -200,18 +200,14 @@ POSIX_HERESTRING unset _project _version } -# proj_src returns the host path to content source for a project. -# It expects a complete project structure as input. +# repo_path returns the host path to the project repository. # It looks for the provided repository name in each of the paths specified in the REPOS_PATH environment variable. -proj_src() { - IFS=: read -r _ _ _repo _path <&2 echo "NOTE: you must have a checkout of the project '${_repo}' at '${REPOS_PATH##:*}/${_repo}'." >&2 echo "NOTE: if you have cloned the repository into a directory with a different name, consider changing it to ${_repo}." >&2 - unset _path _repo + unset _repo exit 1 } +# proj_src returns the host path to content source for a project. +# It expects a complete project structure as input. +# It looks for the provided repository name in each of the paths specified in the REPOS_PATH environment variable. +proj_src() { + IFS=: read -r _ _ _repo _path < "\${path/\${ver}/_index.md}" + echo -e "---\\nredirectURL: \"\${path/\/hugo\/content/}\"\\ntype: redirect\\nversioned: true\\n---\\n" > "\${path/\${ver}/_index.md}" done for x in "${url_src_dst_vers}"; do diff --git a/docs/variables.mk b/docs/variables.mk index 9dd53a26b18..2dfa301900c 100644 --- a/docs/variables.mk +++ b/docs/variables.mk @@ -6,3 +6,6 @@ export DOC_VALIDATOR_IMAGE := $(shell sed -En 's, *image: "(grafana/doc-validato # Skip some doc-validator checks. export DOC_VALIDATOR_SKIP_CHECKS := ^(?:image.+|canonical-does-not-match-pretty-URL)$ + +# Use alternative image until make-docs 3.0.0 is rolled out. +export DOCS_IMAGE := grafana/docs-base:dbd975af06