summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/documentation-file-ref-check15
-rwxr-xr-xscripts/find-unused-docs.sh62
-rwxr-xr-xscripts/kernel-doc17
3 files changed, 90 insertions, 4 deletions
diff --git a/scripts/documentation-file-ref-check b/scripts/documentation-file-ref-check
new file mode 100755
index 000000000000..bc1659900e89
--- /dev/null
+++ b/scripts/documentation-file-ref-check
@@ -0,0 +1,15 @@
1#!/bin/sh
2# Treewide grep for references to files under Documentation, and report
3# non-existing files in stderr.
4
5for f in $(git ls-files); do
6 for ref in $(grep -ho "Documentation/[A-Za-z0-9_.,~/*+-]*" "$f"); do
7 # presume trailing . and , are not part of the name
8 ref=${ref%%[.,]}
9
10 # use ls to handle wildcards
11 if ! ls $ref >/dev/null 2>&1; then
12 echo "$f: $ref" >&2
13 fi
14 done
15done
diff --git a/scripts/find-unused-docs.sh b/scripts/find-unused-docs.sh
new file mode 100755
index 000000000000..3f46f8977dc4
--- /dev/null
+++ b/scripts/find-unused-docs.sh
@@ -0,0 +1,62 @@
1#!/bin/bash
2# (c) 2017, Jonathan Corbet <corbet@lwn.net>
3# sayli karnik <karniksayli1995@gmail.com>
4#
5# This script detects files with kernel-doc comments for exported functions
6# that are not included in documentation.
7#
8# usage: Run 'scripts/find-unused-docs.sh directory' from top level of kernel
9# tree.
10#
11# example: $scripts/find-unused-docs.sh drivers/scsi
12#
13# Licensed under the terms of the GNU GPL License
14
15if ! [ -d "Documentation" ]; then
16 echo "Run from top level of kernel tree"
17 exit 1
18fi
19
20if [ "$#" -ne 1 ]; then
21 echo "Usage: scripts/find-unused-docs.sh directory"
22 exit 1
23fi
24
25if ! [ -d "$1" ]; then
26 echo "Directory $1 doesn't exist"
27 exit 1
28fi
29
30cd "$( dirname "${BASH_SOURCE[0]}" )"
31cd ..
32
33cd Documentation/
34
35echo "The following files contain kerneldoc comments for exported functions \
36that are not used in the formatted documentation"
37
38# FILES INCLUDED
39
40files_included=($(grep -rHR ".. kernel-doc" --include \*.rst | cut -d " " -f 3))
41
42declare -A FILES_INCLUDED
43
44for each in "${files_included[@]}"; do
45 FILES_INCLUDED[$each]="$each"
46 done
47
48cd ..
49
50# FILES NOT INCLUDED
51
52for file in `find $1 -name '*.c'`; do
53
54 if [[ ${FILES_INCLUDED[$file]+_} ]]; then
55 continue;
56 fi
57 str=$(scripts/kernel-doc -text -export "$file" 2>/dev/null)
58 if [[ -n "$str" ]]; then
59 echo "$file"
60 fi
61 done
62
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 9d3eafea58f0..67d051edd615 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2168,7 +2168,7 @@ sub dump_struct($$) {
2168 my $nested; 2168 my $nested;
2169 2169
2170 if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) { 2170 if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) {
2171 #my $decl_type = $1; 2171 my $decl_type = $1;
2172 $declaration_name = $2; 2172 $declaration_name = $2;
2173 my $members = $3; 2173 my $members = $3;
2174 2174
@@ -2194,7 +2194,7 @@ sub dump_struct($$) {
2194 $members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos; 2194 $members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
2195 2195
2196 create_parameterlist($members, ';', $file); 2196 create_parameterlist($members, ';', $file);
2197 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); 2197 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual, $nested);
2198 2198
2199 output_declaration($declaration_name, 2199 output_declaration($declaration_name,
2200 'struct', 2200 'struct',
@@ -2226,6 +2226,8 @@ sub dump_enum($$) {
2226 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { 2226 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
2227 $declaration_name = $1; 2227 $declaration_name = $1;
2228 my $members = $2; 2228 my $members = $2;
2229 my %_members;
2230
2229 $members =~ s/\s+$//; 2231 $members =~ s/\s+$//;
2230 2232
2231 foreach my $arg (split ',', $members) { 2233 foreach my $arg (split ',', $members) {
@@ -2236,9 +2238,16 @@ sub dump_enum($$) {
2236 print STDERR "${file}:$.: warning: Enum value '$arg' ". 2238 print STDERR "${file}:$.: warning: Enum value '$arg' ".
2237 "not described in enum '$declaration_name'\n"; 2239 "not described in enum '$declaration_name'\n";
2238 } 2240 }
2239 2241 $_members{$arg} = 1;
2240 } 2242 }
2241 2243
2244 while (my ($k, $v) = each %parameterdescs) {
2245 if (!exists($_members{$k})) {
2246 print STDERR "${file}:$.: warning: Excess enum value " .
2247 "'$k' description in '$declaration_name'\n";
2248 }
2249 }
2250
2242 output_declaration($declaration_name, 2251 output_declaration($declaration_name,
2243 'enum', 2252 'enum',
2244 {'enum' => $declaration_name, 2253 {'enum' => $declaration_name,
@@ -2506,7 +2515,7 @@ sub check_sections($$$$$$) {
2506 } else { 2515 } else {
2507 if ($nested !~ m/\Q$sects[$sx]\E/) { 2516 if ($nested !~ m/\Q$sects[$sx]\E/) {
2508 print STDERR "${file}:$.: warning: " . 2517 print STDERR "${file}:$.: warning: " .
2509 "Excess struct/union/enum/typedef member " . 2518 "Excess $decl_type member " .
2510 "'$sects[$sx]' " . 2519 "'$sects[$sx]' " .
2511 "description in '$decl_name'\n"; 2520 "description in '$decl_name'\n";
2512 ++$warnings; 2521 ++$warnings;