From c8e14bbd2451d2c5b7a7ab6de1d0e52ad2a10692 Mon Sep 17 00:00:00 2001 From: Furkat Gofurov Date: Fri, 1 Sep 2023 12:53:07 +0300 Subject: [PATCH] Add doctoc script and Makefile targets Signed-off-by: Furkat Gofurov --- Makefile | 14 ++++++++++++++ hack/generate-doctoc.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 hack/generate-doctoc.sh diff --git a/Makefile b/Makefile index ed16e79d9..2b43c74b0 100644 --- a/Makefile +++ b/Makefile @@ -461,6 +461,20 @@ test-e2e: $(GINKGO) $(HELM) $(CAPI_OPERATOR) kubectl ## Run the end-to-end tests -e2e.skip-resource-cleanup=$(SKIP_RESOURCE_CLEANUP) \ -e2e.use-existing-cluster=$(USE_EXISTING_CLUSTER) +## -------------------------------------- +## Documentation +## -------------------------------------- + +.PHONY: generate-doctoc +generate-doctoc: + TRACE=$(TRACE) ./hack/generate-doctoc.sh + +.PHONY: verify-doctoc +verify-doctoc: generate-doctoc + @if !(git diff --quiet HEAD); then \ + git diff; \ + echo "doctoc is out of date, run make generate-doctoc"; exit 1; \ + fi ## -------------------------------------- ## Cleanup / Verification diff --git a/hack/generate-doctoc.sh b/hack/generate-doctoc.sh new file mode 100755 index 000000000..2c7131ad8 --- /dev/null +++ b/hack/generate-doctoc.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Copyright 2023 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +if [[ "${TRACE-0}" == "1" ]]; then + set -o xtrace +fi + +if [[ -z "$(command -v doctoc)" ]]; then + echo "doctoc is not available on your system, skipping verification" + echo "Note: The doctoc module can be installed via npm (https://www.npmjs.com/package/doctoc)" + exit 0 +fi + +doctoc ./CONTRIBUTING.md \ No newline at end of file