^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/bash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # (c) 2017, Jonathan Corbet <corbet@lwn.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) # sayli karnik <karniksayli1995@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # This script detects files with kernel-doc comments for exported functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # that are not included in documentation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # usage: Run 'scripts/find-unused-docs.sh directory' from top level of kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # example: $scripts/find-unused-docs.sh drivers/scsi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) # Licensed under the terms of the GNU GPL License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) if ! [ -d "Documentation" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) echo "Run from top level of kernel tree"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) if [ "$#" -ne 1 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) echo "Usage: scripts/find-unused-docs.sh directory"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) if ! [ -d "$1" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) echo "Directory $1 doesn't exist"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) cd "$( dirname "${BASH_SOURCE[0]}" )"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) cd ..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) cd Documentation/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) echo "The following files contain kerneldoc comments for exported functions \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) that are not used in the formatted documentation"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) # FILES INCLUDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) files_included=($(grep -rHR ".. kernel-doc" --include \*.rst | cut -d " " -f 3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) declare -A FILES_INCLUDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) for each in "${files_included[@]}"; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) FILES_INCLUDED[$each]="$each"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) cd ..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) # FILES NOT INCLUDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) for file in `find $1 -name '*.c'`; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) if [[ ${FILES_INCLUDED[$file]+_} ]]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) str=$(scripts/kernel-doc -export "$file" 2>/dev/null)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) if [[ -n "$str" ]]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) echo "$file"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)