forked from CalexCore/amity.rpc.php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docgen-explorer
executable file
·60 lines (50 loc) · 1.21 KB
/
docgen-explorer
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
#!/bin/bash
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
html_file=explorer.html
function parse()
{
f=$(basename $1)
echo "<li>" >> ${dir}/${html_file}
echo "<strong><a href=\"api/$f\">$f</a></strong>" >> ${dir}/${html_file}
desc=()
params=()
while IFS= read line; do
if [[ $line = '//*'* ]]; then
if [[ $line = '//*desc:'* ]]; then
desc+="<div>${line:9}</div>" >> ${dir}/${html_file}
else
params+="<li>${line:3}</li>" >> ${dir}/${html_file}
fi
fi
done <"$f"
for d in "${desc[@]}"
do
echo $d >> ${dir}/${html_file}
done
if [ ${#params[@]} -ne 0 ]; then
echo "<ul>" >> ${dir}/${html_file}
for p in "${params[@]}"
do
echo $p >> ${dir}/${html_file}
done
echo "</ul>" >> ${dir}/${html_file}
fi
}
function writeheader()
{
echo "<h4>AMITY Public API</h4>" > ${dir}/${html_file}
echo "<ul class=\"amity-api-links\">" >> ${dir}/${html_file}
}
function writefooter()
{
echo "</ul>" >> ${dir}/${html_file}
}
function parsefiles()
{
for fn in ${dir}/*.php; do
parse "${fn}"
done
}
writeheader
parsefiles
writefooter