Skip to content

Commit bc17532

Browse files
authored
Add check for docs (grpc-ecosystem#138)
* Travis will now check to see if the docs have correctly been updated
1 parent c7eebe4 commit bc17532

File tree

5 files changed

+47
-8
lines changed

5 files changed

+47
-8
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ install:
1515
- dep ensure
1616

1717
script:
18-
- make test
18+
- make checkdocs
19+
- make test
1920

2021
after_success:
2122
- bash <(curl -s https://codecov.io/bash)

CONTRIBUTING.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Contributing
2+
3+
We would love to have people submit pull requests and help make `grpc-ecosystem/go-grpc-middleware` even better 👍.
4+
5+
Fork, then clone the repo:
6+
7+
```bash
8+
git clone [email protected]:your-username/go-grpc-middleware.git
9+
```
10+
11+
Before checking in please run the following:
12+
13+
```bash
14+
make all
15+
```
16+
17+
This will `vet`, `fmt`, regenerate documentation and run all tests.
18+
19+
20+
Push to your fork and open a pull request.

makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ GOFILES_NOVENDOR = $(shell go list ./... | grep -v /vendor/)
55
all: vet fmt docs test
66

77
docs:
8-
./scripts/fixup.sh
8+
./scripts/docs.sh generate
9+
10+
checkdocs:
11+
./scripts/docs.sh check
912

1013
fmt:
1114
go fmt $(GOFILES_NOVENDOR)

scripts/fixup.sh scripts/docs.sh

+20-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ function generate_markdown {
1111
echo "Generating Github markdown"
1212
oldpwd=$(pwd)
1313
for i in $(find . -iname 'doc.go' -not -path "*vendor/*"); do
14-
dir=${i%/*}
15-
realdir=$(realpath $dir)
14+
realdir=$(cd $(dirname ${i}) && pwd -P)
1615
package=${realdir##${GOPATH}/src/}
1716
echo "$package"
1817
cd ${dir}
@@ -22,6 +21,22 @@ function generate_markdown {
2221
done;
2322
}
2423

25-
go get github.com/devnev/godoc2ghmd
26-
generate_markdown
27-
echo "returning $?"
24+
function generate {
25+
go get github.com/devnev/godoc2ghmd
26+
generate_markdown
27+
echo "returning $?"
28+
}
29+
30+
function check {
31+
generate
32+
count=$(git diff --numstat | wc -l | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
33+
echo $count
34+
if [ "$count" = "0" ]; then
35+
return 0
36+
else
37+
echo "Your markdown docs seem to be out of sync with the package docs. Please run make and consult CONTRIBUTING.MD"
38+
return 1
39+
fi
40+
}
41+
42+
"$@"

tracing/opentracing/DOC.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ func WithTracer(tracer opentracing.Tracer) Option
115115
WithTracer sets a custom tracer to be used for this middleware, otherwise the opentracing.GlobalTracer is used.
116116

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

0 commit comments

Comments
 (0)