Skip to content

Commit f15c323

Browse files
mchehabJonathan Corbet
authored andcommitted
scripts: add a script to check if Documentation/00-INDEX is sane
It is easy to forget adding/removing entries at the Documentation/00-INDEX file. In a matter of fact, even before ReST conversion, people use to forget adding things here, as there are lots of missing stuff out there. Now that we're doing a hard work converting entries to ReST, and while this hole file is not outdated, it is good to have some tool that would help to verify that this file is kept updated. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 20b786e commit f15c323

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

scripts/check_00index.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
cd Documentation/
4+
5+
# Check entries that should be removed
6+
7+
obsolete=""
8+
for i in $(tail -n +12 00-INDEX |grep -E '^[a-zA-Z0-9]+'); do
9+
if [ ! -e $i ]; then
10+
obsolete="$obsolete $i"
11+
fi
12+
done
13+
14+
# Check directory entries that should be added
15+
search=""
16+
dir=""
17+
for i in $(find . -maxdepth 1 -type d); do
18+
if [ "$i" != "." ]; then
19+
new=$(echo $i|perl -ne 's,./(.*),$1/,; print $_')
20+
search="$search $new"
21+
fi
22+
done
23+
24+
for i in $search; do
25+
if [ "$(grep -P "^$i" 00-INDEX)" == "" ]; then
26+
dir="$dir $i"
27+
fi
28+
done
29+
30+
# Check file entries that should be added
31+
search=""
32+
file=""
33+
for i in $(find . -maxdepth 1 -type f); do
34+
if [ "$i" != "./.gitignore" ]; then
35+
new=$(echo $i|perl -ne 's,./(.*),$1,; print $_')
36+
search="$search $new"
37+
fi
38+
done
39+
40+
for i in $search; do
41+
if [ "$(grep -P "^$i\$" 00-INDEX)" == "" ]; then
42+
file="$file $i"
43+
fi
44+
done
45+
46+
# Output its findings
47+
48+
echo -e "Documentation/00-INDEX check results:\n"
49+
50+
if [ "$obsolete" != "" ]; then
51+
echo -e "- Should remove those entries:\n\t$obsolete\n"
52+
else
53+
echo -e "- No obsolete entries\n"
54+
fi
55+
56+
if [ "$dir" != "" ]; then
57+
echo -e "- Should document those directories:\n\t$dir\n"
58+
else
59+
echo -e "- No new directories to add\n"
60+
fi
61+
62+
if [ "$file" != "" ]; then
63+
echo -e "- Should document those files:\n\t$file"
64+
else
65+
echo "- No new files to add"
66+
fi

0 commit comments

Comments
 (0)