Skip to content

Commit

Permalink
Add check for docs (#138)
Browse files Browse the repository at this point in the history
* Travis will now check to see if the docs have correctly been updated
  • Loading branch information
domgreen authored Apr 17, 2018
1 parent c7eebe4 commit bc17532
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ install:
- dep ensure

script:
- make test
- make checkdocs
- make test

after_success:
- bash <(curl -s https://codecov.io/bash)
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Contributing

We would love to have people submit pull requests and help make `grpc-ecosystem/go-grpc-middleware` even better 👍.

Fork, then clone the repo:

```bash
git clone [email protected]:your-username/go-grpc-middleware.git
```

Before checking in please run the following:

```bash
make all
```

This will `vet`, `fmt`, regenerate documentation and run all tests.


Push to your fork and open a pull request.
5 changes: 4 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ GOFILES_NOVENDOR = $(shell go list ./... | grep -v /vendor/)
all: vet fmt docs test

docs:
./scripts/fixup.sh
./scripts/docs.sh generate

checkdocs:
./scripts/docs.sh check

fmt:
go fmt $(GOFILES_NOVENDOR)
Expand Down
25 changes: 20 additions & 5 deletions scripts/fixup.sh → scripts/docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ function generate_markdown {
echo "Generating Github markdown"
oldpwd=$(pwd)
for i in $(find . -iname 'doc.go' -not -path "*vendor/*"); do
dir=${i%/*}
realdir=$(realpath $dir)
realdir=$(cd $(dirname ${i}) && pwd -P)
package=${realdir##${GOPATH}/src/}
echo "$package"
cd ${dir}
Expand All @@ -22,6 +21,22 @@ function generate_markdown {
done;
}

go get github.com/devnev/godoc2ghmd
generate_markdown
echo "returning $?"
function generate {
go get github.com/devnev/godoc2ghmd
generate_markdown
echo "returning $?"
}

function check {
generate
count=$(git diff --numstat | wc -l | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
echo $count
if [ "$count" = "0" ]; then
return 0
else
echo "Your markdown docs seem to be out of sync with the package docs. Please run make and consult CONTRIBUTING.MD"
return 1
fi
}

"$@"
2 changes: 1 addition & 1 deletion tracing/opentracing/DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ func WithTracer(tracer opentracing.Tracer) Option
WithTracer sets a custom tracer to be used for this middleware, otherwise the opentracing.GlobalTracer is used.

- - -
Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd)
Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd)

0 comments on commit bc17532

Please sign in to comment.