-
Notifications
You must be signed in to change notification settings - Fork 0
/
scaladoc
executable file
·73 lines (65 loc) · 1.52 KB
/
scaladoc
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
usage() {
echo 'Usage: scaladoc [library] [term]'
echo ''
echo 'library Defaults to scala-lang. Can be a handful of useful libraries, '
echo ' eg. akka (or akka-actor), akka-http, spray-json, etc'
echo ''
echo 'term An optional term to search for in the docs'
}
if [[ "$1" == '--help' ]]; then
usage
exit 0
fi
_open() {
if which xdg-open &> /dev/null; then
xdg-open "$@"
return
fi
if which open &> /dev/null; then
open "$@"
return
fi
}
_urlencode() {
python -c "from urllib.parse import quote_plus;print(quote_plus('''$1'''))"
}
DOCROOT=''
VERSION=current
LANDING=''
SEARCH_TERM=$(_urlencode "$2")
SUPPORTS_SEARCH=1
case "$1" in
scala|scala-lang|stdlib|std|'')
DOCROOT='https://www.scala-lang.org/api'
;;
akka|akka-actor)
DOCROOT='https://doc.akka.io/api/akka'
LANDING='akka/actor/index.html'
;;
akka-stream|akka-streams)
DOCROOT='https://doc.akka.io/api/akka'
LANDING='akka/stream/index.html'
;;
akka-http)
DOCROOT='https://doc.akka.io/api/akka-http'
LANDING='akka/http/scaladsl/index.html'
;;
alpakka)
DOCROOT='https://developer.lightbend.com/docs/api/alpakka'
LANDING='akka/stream/alpakka/index.html'
;;
spray-json)
DOCROOT='https://www.javadoc.io/doc/io.spray/spray-json_2.12'
VERSION='1.3.4'
;;
scalatest)
DOCROOT='http://doc.scalatest.org/'
VERSION='1.8'
;;
*)
echo "Unrecognised library $1" >&2
exit 1
;;
esac
_open "$DOCROOT/$VERSION/$LANDING?search=$SEARCH_TERM"