-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen-descriptions
executable file
·55 lines (50 loc) · 1.08 KB
/
gen-descriptions
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
#!/bin/bash
echo "| | |"
echo "|---|---|"
for filepath in admin-tools/* compiled-tools/*.pod crawler-bin/* root-tools/* user-tools/* xwin-tools/*
do
if [ -f "$filepath" ]
then
echo $'=pod\n\n=head1 FILEPATH '"$filepath"$'\n\n=cut\n\n'
cat "$filepath"
echo $'=pod\n\n=head1 EOF '"$filepath"$'\n\n=cut\n\n'
fi
done |\
pod2text -w 10000 --utf8 |\
while IFS=$'\n' read line
do
if [[ $line =~ ^FILEPATH[\ \ ]+(.+) ]]
then
filepath=${BASH_REMATCH[1]}
dirpath=${filepath%/*}
elif [ "$line" = NAME ]
then
while IFS=$'\n' read line2
do
if [[ $line2 =~ ^[\ ]+([^ ]+)[\ ]+-[\ ]+(.+) ]]
then
name=${BASH_REMATCH[1]}
description=${BASH_REMATCH[2]}
filelink=$dirpath/$name
if [ "${filepath: -4}" = .pod ]
then
filelink=$dirpath/$name.c
fi
if [ ! -e "$filelink" ]
then
filelink=($dirpath/*/$name.*)
filelink=${filelink[0]}
fi
if [ ! -e "$filelink" ]
then
filelink=$filepath
fi
echo "| [$name]($filelink) | $description"
elif [[ $line2 =~ ^[^\ \ ] ]]
then
break
fi
done
fi
done |\
sort -u