-
Notifications
You must be signed in to change notification settings - Fork 183
/
docscov.sh
executable file
·35 lines (27 loc) · 1.04 KB
/
docscov.sh
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
#!/usr/bin/env bash
undocumented_functions=0
if [[ ! -f src/luv.c ]] ; then
echo "Missing src/luv.c"
exit 1
fi
func_definitions=$(sed -n '/luaL_Reg luv_functions\[\] = {$/,/^};$/{p;/^\};$/q}' src/luv.c)
funcs_start_line_number=$(awk '/luaL_Reg luv_functions\[\] = \{/ {print FNR}' src/luv.c)
after_funcs=$((funcs_start_line_number+1))
method_definitions=$(tail -n +$after_funcs src/luv.c | sed -n '/luaL_Reg/,/^\};$/p')
for fn in `echo "$func_definitions" | grep -oP "\s+ \{\"\K([^\"]+)(?=\",)"`; do
# count instances of '### `uv.fn_name' in the docs
count=$(grep -oPc "^#+\s+\`uv\.$fn\b" docs.md)
if [ $count -eq 0 ] ; then
echo $fn
undocumented_functions=$((undocumented_functions+1))
fi
done
for fn in `echo "$method_definitions" | grep -oP "\s+ \{\"\K([^\"]+)(?=\",)"`; do
# count instances of '> method form something:fn_name' in the docs
count=$(grep -oPc "^> method form [^:]+:$fn\b" docs.md)
if [ $count -eq 0 ] ; then
echo "$fn (method form)"
undocumented_functions=$((undocumented_functions+1))
fi
done
exit $undocumented_functions