From 7522845dfe8851b7b4f3e9924810b9ccf282bb6e Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Wed, 2 Feb 2022 14:21:00 -0700 Subject: spell check docs with spellintian (#1223) Fix spelling errors - Add Makefile target that checks for spelling errors - Add Makefile target that fixes spelling errors - Add spelling check to travis doc tests - Fix various spelling errors in the docs --- Makefile | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0c015dae..4ead786f 100644 --- a/Makefile +++ b/Makefile @@ -83,6 +83,43 @@ deb-src: doc: tox -e doc +# Spell check && filter false positives +_CHECK_SPELLING := find doc -type f -exec spellintian {} + | \ + grep -v -e 'doc/rtd/topics/cli.rst: modules modules' \ + -e 'doc/examples/cloud-config-mcollective.txt: WARNING WARNING' \ + -e 'doc/examples/cloud-config-power-state.txt: Bye Bye' \ + -e 'doc/examples/cloud-config.txt: Bye Bye' + + +# For CI we require a failing return code when spellintian finds spelling errors +check_spelling: + @! $(_CHECK_SPELLING) + +# Manipulate the output of spellintian into a valid "sed" command which is run +# to fix the error +# +# Example spellintian output: +# +# doc/examples/kernel-cmdline.txt: everthing -> everything +# +# The "fix_spelling" target manipulates the above output into the following command +# and runs that command. +# +# sed -i "s/everthing/everything/g" doc/examples/kernel-cmdline.txt +# +# awk notes: +# +# -F ': | -> ' means use the strings ": " or " -> " as field delimeters +# \046 is octal for double quote +# $$2 will contain the second field, ($ must be escaped because this is in a Makefile) +# +# Limitation: duplicate words with newline between them are not automatically fixed +fix_spelling: + @$(_CHECK_SPELLING) | \ + sed 's/ (duplicate word)//g' | \ + awk -F ': | -> ' '{printf "sed -i \047s/%s/%s/g\047 %s\n", $$2, $$3, $$1}' | \ + sh + .PHONY: test flake8 clean rpm srpm deb deb-src yaml .PHONY: check_version pip-test-requirements pip-requirements clean_pyc -.PHONY: unittest style-check doc +.PHONY: unittest style-check doc fix_spelling check_spelling -- cgit v1.2.3