This repository was archived by the owner on Jul 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmkdocs.sh
More file actions
executable file
·42 lines (36 loc) · 1.42 KB
/
mkdocs.sh
File metadata and controls
executable file
·42 lines (36 loc) · 1.42 KB
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
#!/bin/bash
## This scripts generates Markdown formatted documentation of all packages in
## the project, using 'go doc' and 'godoc2markdown' tools.
## Change these variables...
# This shall be the module name of the project.
module="github.com/Nacdlow/iglu-server"
# This shall be the path of the wiki site.
docpath="../nacdlow-server.wiki"
mkdir -p $docpath
# Generate documentation/markdown of project
for fullpkg in $(go list ./...)
do
package=$(echo $fullpkg | rev | cut -d"/" -f1 | rev)
path=$(echo $fullpkg | sed "s#$module##")
mkdir -p $docpath/$path
echo "Generating $path..."
echo "[< Go back to docs listing](/home)" > $docpath/$path/$package.md
go doc -all $fullpkg | godoc2markdown >> $docpath/$path/$package.md
done
# Generate home wiki page with navigation listing
docs=$(cd $docpath && find -L . | grep \\.md)
echo -e "# Welcome to the documentation wiki\n\n" > $docpath/home.md
echo -e "This documentation is generated for commit
$(git rev-parse --short HEAD) (*$(git log -1 --pretty=%B)*). \n\n" >> $docpath/home.md
echo "### Documentation listing" >> $docpath/home.md
echo
for item in $docs
do
propername=$(echo $item | sed "s#./##" | sed "s#\\.md##")
if [ $propername != "home" ]; then
echo "- [$propername]($propername)" >> $docpath/home.md
fi
done
echo -e "\n\n> Generated using [godoc2markdown](https://humaidq.ae/projects/godoc2markdown/)
and a script." >> $docpath/home.md
echo "Done. Wiki generated at $docpath"