Skip to content

Commit

Permalink
Add docscheck make target/script for website docs
Browse files Browse the repository at this point in the history
  • Loading branch information
findkim committed Nov 1, 2019
1 parent 08309cb commit 9f7bc14
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ install:
- make tools

script:
- make docscheck
- make lint
- make test
- make website-test
Expand Down
5 changes: 4 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

.PHONY: build test testacc vet fmt fmtcheck lint tools errcheck test-compile website website-test
docscheck:
@sh -c "'$(CURDIR)/scripts/docscheck.sh'"

.PHONY: build test testacc vet fmt fmtcheck lint tools errcheck test-compile website website-test docscheck

39 changes: 39 additions & 0 deletions scripts/docscheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

docs=$(ls website/docs/**/*.markdown)
error=false

for doc in $docs; do
dirname=$(dirname "$doc")
category=$(basename "$dirname")

case "$category" in
"guides")
# Guides require a page_title
if ! grep "^page_title: " "$doc" > /dev/null; then
echo "Guide is missing a page_title: $doc"
error=true
fi
;;

"d" | "r")
# Resources and data sources require a subcategory
if ! grep "^subcategory: " "$doc" > /dev/null; then
echo "Doc is missing a subcategory: $doc"
error=true
fi
;;

*)
error=true
echo "Unknown category \"$category\". " \
"Docs can only exist in r/, d/, or guides/ folders."
;;
esac
done

if $error; then
exit 1
fi

exit 0

0 comments on commit 9f7bc14

Please sign in to comment.