From e03e0d2d9bcf894a0449bab74e0e92a0ad409827 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Mon, 7 Mar 2022 01:35:04 -0500 Subject: [PATCH] Update link checking scripts / targets (#696) --- .htmltest.yml | 4 +++- Makefile | 33 +++++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.htmltest.yml b/.htmltest.yml index 5aeb69f9dff..2cec9828f2e 100644 --- a/.htmltest.yml +++ b/.htmltest.yml @@ -2,4 +2,6 @@ DirectoryPath: public IgnoreDirectoryMissingTrailingSlash: true CheckExternal: false IgnoreAltMissing: true -IgnoreEmptyHref: true \ No newline at end of file +IgnoreEmptyHref: true +IgnoreInternalURLs: + - /docs/2.6/scalers/solace-pub-sub/ # Due to https://github.com/kedacore/keda-docs/issues/693 diff --git a/Makefile b/Makefile index d4f3d19ccf7..b4806002cff 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,24 @@ +HTMLTEST_DIR=tmp +HTMLTEST?=htmltest # Specify as make arg if different +HTMLTEST_ARGS?=--skip-external + +DOCS=public/docs +LATEST_VERSION=$(shell grep -e '^docs' config.toml | grep -oe '\d\.\d' | head -1) +LATEST_VERSION2=`grep -e '^docs' config.toml | grep -oe '\d\.\d' | head -1` + +# Use $(HTMLTEST) in PATH, if available; otherwise, we'll get a copy +ifeq (, $(shell which $(HTMLTEST))) +override HTMLTEST=$(HTMLTEST_DIR)/bin/htmltest +ifeq (, $(shell which $(HTMLTEST))) +GET_LINK_CHECKER_IF_NEEDED=get-link-checker +endif +endif + build: clean hugo -e development -DFE clean: - rm -rf public/* resources + rm -rf $(HTMLTEST_DIR) public/* resources serve: hugo server \ @@ -23,10 +39,15 @@ preview-build: clean open: open https://keda.sh -link-checker-setup: - curl https://htmltest.wjdp.uk | bash +check-links: $(GET_LINK_CHECKER_IF_NEEDED) make-redirects-for-checking + $(HTMLTEST) $(HTMLTEST_ARGS) + find public/* -type l -ls -exec rm -f {} \; -run-link-checker: - bin/htmltest +make-redirects-for-checking: + @echo "Creating symlinks of 'latest' to $(LATEST_VERSION) for the purpose of link checking" + (cd public && rm -f scalers && ln -s docs/$(LATEST_VERSION)/scalers scalers) + (cd public/docs && rm -f latest && ln -s $(LATEST_VERSION) latest) -check-links: link-checker-setup run-link-checker +get-link-checker: + rm -Rf $(HTMLTEST_DIR)/bin + curl https://htmltest.wjdp.uk | bash -s -- -b $(HTMLTEST_DIR)/bin