Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # (c) 2017, Jonathan Corbet <corbet@lwn.net>
0003 #           sayli karnik <karniksayli1995@gmail.com>
0004 #
0005 # This script detects files with kernel-doc comments for exported functions
0006 # that are not included in documentation.
0007 #
0008 # usage: Run 'scripts/find-unused-docs.sh directory' from top level of kernel
0009 #        tree.
0010 #
0011 # example: $scripts/find-unused-docs.sh drivers/scsi
0012 #
0013 # Licensed under the terms of the GNU GPL License
0014 
0015 if ! [ -d "Documentation" ]; then
0016         echo "Run from top level of kernel tree"
0017         exit 1
0018 fi
0019 
0020 if [ "$#" -ne 1 ]; then
0021         echo "Usage: scripts/find-unused-docs.sh directory"
0022         exit 1
0023 fi
0024 
0025 if ! [ -d "$1" ]; then
0026         echo "Directory $1 doesn't exist"
0027         exit 1
0028 fi
0029 
0030 cd "$( dirname "${BASH_SOURCE[0]}" )"
0031 cd ..
0032 
0033 cd Documentation/
0034 
0035 echo "The following files contain kerneldoc comments for exported functions \
0036 that are not used in the formatted documentation"
0037 
0038 # FILES INCLUDED
0039 
0040 files_included=($(grep -rHR ".. kernel-doc" --include \*.rst | cut -d " " -f 3))
0041 
0042 declare -A FILES_INCLUDED
0043 
0044 for each in "${files_included[@]}"; do
0045         FILES_INCLUDED[$each]="$each"
0046         done
0047 
0048 cd ..
0049 
0050 # FILES NOT INCLUDED
0051 
0052 for file in `find $1 -name '*.c'`; do
0053 
0054         if [[ ${FILES_INCLUDED[$file]+_} ]]; then
0055         continue;
0056         fi
0057         str=$(scripts/kernel-doc -export "$file" 2>/dev/null)
0058         if [[ -n "$str" ]]; then
0059         echo "$file"
0060         fi
0061         done
0062