-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: publish static pkg-site generated docs for this repo on GH pages (
- Loading branch information
Showing
6 changed files
with
62 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
install: | ||
go install mvdan.cc/gofumpt | ||
go install google.golang.org/protobuf/cmd/protoc-gen-go | ||
go install golang.org/x/tools/cmd/godoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
all: clean gen | ||
|
||
install: | ||
go install golang.org/x/pkgsite/cmd/pkgsite@latest | ||
|
||
gen: | ||
./gendocs.sh | ||
|
||
clean: | ||
rm -rf godoc | ||
|
||
kill_zombies: | ||
kill -9 `lsof -t -i tcp:6060 -s TCP:LISTEN` || true | ||
kill -9 `lsof -t -i tcp:8080 -s TCP:LISTEN` || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,51 @@ | ||
#!/bin/sh | ||
|
||
GODOC_PORT=${GODOC_PORT:-6060} | ||
GO_MODULE=${GO_MODULE:-github.com/gnolang/gno} | ||
GODOC_OUT=${GODOC_OUT:-godoc} | ||
URL=http://localhost:${GODOC_PORT}/pkg/github.com/gnolang/gno/ | ||
|
||
echo "[+] Starting godoc server..." | ||
go run \ | ||
-modfile ../devdeps/go.mod \ | ||
golang.org/x/tools/cmd/godoc \ | ||
-http="localhost:${GODOC_PORT}" & | ||
PID=$! | ||
# Waiting for godoc server | ||
while ! curl --fail --silent "$URL" > /dev/null 2>&1; do | ||
sleep 0.1 | ||
#!/bin/bash | ||
# Heavily modified version of the following script: | ||
# https://gist.github.com/Kegsay/84ce060f237cb9ab4e0d2d321a91d920 | ||
set -u | ||
|
||
DOC_DIR=godoc | ||
PKG=github.com/gnolang/gno | ||
|
||
# Run a pkgsite server which we will scrape. Use env to run it from our repo's root directory. | ||
env -C ../.. pkgsite & | ||
DOC_PID=$! | ||
|
||
# Wait for the server to init | ||
while : | ||
do | ||
curl -s "http://localhost:8080" > /dev/null | ||
if [ $? -eq 0 ] # exit code is 0 if we connected | ||
then | ||
break | ||
fi | ||
done | ||
|
||
echo "[+] Downloading godoc pages..." | ||
# Scrape the pkg directory for the API docs. Scrap lib for the CSS/JS. Ignore everything else. | ||
wget \ | ||
--recursive \ | ||
--no-verbose \ | ||
--convert-links \ | ||
--page-requisites \ | ||
--adjust-extension \ | ||
--execute=robots=off \ | ||
--include-directories="/lib,/pkg/$GO_MODULE,/src/$GO_MODULE" \ | ||
--exclude-directories="*" \ | ||
--directory-prefix="${GODOC_OUT}" \ | ||
--no-host-directories \ | ||
"$URL?m=all" | ||
|
||
echo "[+] Killing godoc server..." | ||
kill -9 "$PID" | ||
--verbose \ | ||
--recursive \ | ||
--mirror \ | ||
--convert-links \ | ||
--adjust-extension \ | ||
--page-requisites \ | ||
-erobots=off \ | ||
--accept-regex='8080/((search|license-policy|about|)$|(static|images)/|github.com/gnolang/)' \ | ||
http://localhost:8080/ | ||
|
||
# Stop the pkgsite server | ||
kill -9 $DOC_PID | ||
|
||
# Delete the old directory or else mv will put the localhost dir into | ||
# the DOC_DIR if it already exists. | ||
rm -rf $DOC_DIR | ||
mv localhost\:8080 $DOC_DIR | ||
|
||
# Perform various replacements to fix broken links/UI. | ||
# /files/ will point to their github counterparts; we make links to importedby/version go nowhere; | ||
# any other link will point to pkg.go.dev, and fix the /files/... text when viewing a pkg. | ||
find godoc -type f -exec sed -ri 's#http://localhost:8080/files/[^"]*/github.com/gnolang/([^/"]+)/([^"]*)#https://github.com/gnolang/\1/blob/master/\2#g | ||
s#http://localhost:8080/[^"?]*\?tab=(importedby|versions)#\##g | ||
s#http://localhost:8080([^")]*)#https://pkg.go.dev\1#g | ||
s#/files/[^" ]*/(github.com/[^" ]*)/#\1#g' {} + | ||
|
||
echo "Docs can be found in $DOC_DIR" |