-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-readme.sh
executable file
·45 lines (31 loc) · 1.04 KB
/
generate-readme.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
set -eof pipefail
go test -v .
cp ./examples_test.go tmp/examples.go
go build -o ./bin/dochelp ./cmd/dochelp/main.go
example_functions=$(go doc tmp | ./bin/dochelp fnname)
echo "# fn\n" > tmp/readme.md
go doc fn | grep -ve "^func.*" | grep -ve "^type.*" | tail -n +3 >> tmp/readme.md
cat >> tmp/readme.md <<- EOF
## Installation
\`\`\`
go get github.com/sdcoffey/fn
\`\`\`
EOF
echo "## In this package" >> tmp/readme.md
for example_name in ${example_functions}; do
src_name=$(echo $example_name | sed -e "s/^Example//")
echo "* [$src_name](#$src_name)" >> tmp/readme.md
done
echo "\n" >> tmp/readme.md
echo "Generating documentation for:"
for example_name in ${example_functions}; do
src_name=$(echo $example_name | sed -e "s/^Example//")
echo "### $src_name" >> tmp/readme.md
go doc $src_name | ./bin/dochelp extract-doc >> tmp/readme.md
echo "\n\`\`\`go" >> tmp/readme.md
go doc -src tmp $example_name | tail -n +3 >> tmp/readme.md
echo "\`\`\`\n" >> tmp/readme.md
echo "- $src_name"
done
mv tmp/readme.md ./README.md
echo "\ndone"