This repository has been archived by the owner on Jun 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build markdown API docs for JS and Go packages
- Loading branch information
Lars Gierth
committed
Nov 17, 2017
1 parent
fff3e07
commit 320198c
Showing
1 changed file
with
52 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
usage() { | ||
echo "Usage: package.sh github.com/some-org/some-repo v1.2.3 path/to/destination/" | ||
exit 1 | ||
} | ||
|
||
[ "$1" ] || usage | ||
[ "$2" ] || usage | ||
[ "$3" ] || usage | ||
|
||
repo="$(echo "$1" | sed -e 's/^https:\/\///' -e 's/git:\/\///' -e 's/git@github.com:/github.com\//' -e 's/\.git$//')" | ||
name="$(echo "$repo" | sed -e 's/.*\///')" | ||
ref="$2" | ||
dest="$3" | ||
|
||
if echo "$name" | grep -P '^go-' > /dev/null; then | ||
|
||
# Go: get the source, run godoc2md | ||
export GOPATH="$(pwd)/tmp/gopath" | ||
go get -d -u -v "$repo" | ||
(cd "$GOPATH/src/$repo" && git reset --hard HEAD && git fetch && git checkout "$ref") | ||
mkdir -vp "$dest/$name" | ||
cat <<EOF > "$dest/$name/index.md" | ||
+++ | ||
title = "$name" | ||
description = "Reference for $name package" | ||
+++ | ||
$(godoc2md -v "$repo") | ||
EOF | ||
else | ||
|
||
# JS: clone repo, npm install, run aegir docs | ||
tmpdir="tmp/js" | ||
mkdir -vp "$tmpdir" | ||
if [ ! -d "$tmpdir/$name" ]; then | ||
git clone -q "https://$repo" "$tmpdir/$name" | ||
else | ||
(cd "$tmpdir/$name" && git reset --hard HEAD && git fetch && git checkout "$ref") | ||
fi | ||
|
||
cd "$tmpdir/$name" | ||
npm install --save | ||
# npm link aegir | ||
node_modules/.bin/aegir docs -m | ||
cd - | ||
mkdir -vp "$dest/$name" | ||
cat "$tmpdir/$name/docs/index.md" | sed -e 's/^<!--.*$//' > "$dest/$name/index.md" | ||
fi |