find-unused-docs.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. if ! [ -d "Documentation" ]; then
  15. echo "Run from top level of kernel tree"
  16. exit 1
  17. fi
  18. if [ "$#" -ne 1 ]; then
  19. echo "Usage: scripts/find-unused-docs.sh directory"
  20. exit 1
  21. fi
  22. if ! [ -d "$1" ]; then
  23. echo "Directory $1 doesn't exist"
  24. exit 1
  25. fi
  26. cd "$( dirname "${BASH_SOURCE[0]}" )"
  27. cd ..
  28. cd Documentation/
  29. echo "The following files contain kerneldoc comments for exported functions \
  30. that are not used in the formatted documentation"
  31. # FILES INCLUDED
  32. files_included=($(grep -rHR ".. kernel-doc" --include \*.rst | cut -d " " -f 3))
  33. declare -A FILES_INCLUDED
  34. for each in "${files_included[@]}"; do
  35. FILES_INCLUDED[$each]="$each"
  36. done
  37. cd ..
  38. # FILES NOT INCLUDED
  39. for file in `find $1 -name '*.c'`; do
  40. if [[ ${FILES_INCLUDED[$file]+_} ]]; then
  41. continue;
  42. fi
  43. str=$(scripts/kernel-doc -export "$file" 2>/dev/null)
  44. if [[ -n "$str" ]]; then
  45. echo "$file"
  46. fi
  47. done