Add makefile targets for doc8 lint, fix formatting/spelling issues

Change-Id: I0f45ffe0ba94fab89f9b38c9b73ed7b9091f1795
diff --git a/docs/Makefile b/docs/Makefile
index 379e0e2..13176dc 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -1,5 +1,7 @@
 # Minimal makefile for Sphinx documentation
-#
+
+# use bash safe mode, fail quickly
+SHELL = bash -e -o pipefail
 
 # You can set these variables from the command line.
 SPHINXOPTS    =
@@ -7,19 +9,32 @@
 SOURCEDIR     = source
 BUILDDIR      = build
 
-# Put it first so that "make" without argument is like "make help".
-help:
-	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+.PHONY: help Makefile lint
 
-.PHONY: help Makefile
+# Put it first so that "make" without argument is like "make help".
+help: doc_venv
+	source $</bin/activate ; set -u ;\
+	$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
 
 doc_venv:
-	virtualenv doc_venv ;\
-	source ./doc_venv/bin/activate ;\
+	virtualenv $@ ;\
+	source $@/bin/activate ;\
 	pip install livereload ;\
 	pip install -r requirements.txt
 
+lint: doc8
+
+doc8: doc_venv
+	source $</bin/activate ; set -u ;\
+	doc8 --max-line-length 119 \
+	     $$(find . -name \*.rst ! -path "*doc_venv*")
+
+clean:
+	rm -rf doc_venv build
+
 # Catch-all target: route all unknown targets to Sphinx using the new
 # "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
-%: Makefile
-	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
+%: doc_venv Makefile
+	source $</bin/activate ; set -u ;\
+	$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+