-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrapedocs
executable file
·44 lines (41 loc) · 1.37 KB
/
scrapedocs
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
#!/bin/bash
#Syntax:
# scrapedocs <DIRECTORY> [DIRECTORY] ...
#
# This tool removes all files in directories that are not in DIRECTORY and are not referenced by any of the files located in DIRECTORY.
# This command has the effect of removing unnecessary files and minimizing the creation of docs related to source directories outside of the DIRECTORY or DIRECTORIES specified.
cd sources
if [ -f mainsources ]; then rm mainsources; fi
while [ $# -gt 0 ]; do
mainsource=$1
echo "./$mainsource" >> mainsources
echo Scanning $mainsource for references
shift
referencefunctions=`grep -r "@copy.*()" $mainsource | grep -e "\.h:" -e "\.cpp:" | awk '{ print $NF }' | sort -u`
for reffunc in $referencefunctions
do
grep -r "@brief.*$reffunc" * | grep -v "$mainsource/" | awk -F: '{ print $1" " }' >> reffiles.$$
done
done
if [ -f reffiles.$$ ]; then
cat reffiles.$$ | sort -u > rfiles.$$
rm reffiles.$$
reffiles=""
reffiles=`cat rfiles.$$`
rm rfiles.$$
fi
echo Removing files
for delfiles in `find . -type f | grep -v -f mainsources -e "./syndicate-storage.github.io/"`
do
remove=true
for reffile in $reffiles
do
if [[ "$delfiles" == "./$reffile" ]]; then
remove=false
fi
done
if [ $remove == true ]; then
rm -f $delfiles
fi
done
if [ -f mainsources ]; then rm mainsources; fi