starpu_check_documented.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/python3
  2. import os
  3. import sys
  4. class bcolors:
  5. FAILURE = '\033[91m'
  6. NORMAL = '\033[0m'
  7. def list_files(directory):
  8. return list(map(lambda a : directory+a, list(filter(lambda a:a.count(".h") and not a.count("starpu_deprecated_api.h"),os.listdir(directory)))))
  9. def loadFunctionsAndDatatypes(flist, dtlist, file_name):
  10. f = open(file_name, 'r')
  11. for line in f:
  12. mline = line[:-1]
  13. if mline.count("\\fn"):
  14. if mline.count("fft") == 0:
  15. func = mline.replace("\\fn ", "")
  16. l = func.split("(")[0].split()
  17. func_name = l[len(l)-1].replace("*", "")
  18. flist.append(list([func, func_name, file_name]))
  19. if mline.count("\\struct ") or mline.count("\\def ") or mline.count("\\typedef ") or mline.count("\\enum "):
  20. datatype = mline.replace("\\struct ", "").replace("\\def ", "").replace("\\typedef ", "").replace("\\enum ","")
  21. l = datatype.split("(")
  22. if len(l) > 1:
  23. datatype_name = l[0]
  24. else:
  25. datatype_name = datatype
  26. dtlist.append(list([datatype, datatype_name, file_name]))
  27. f.close()
  28. functions = []
  29. datatypes = []
  30. dirname=os.path.dirname(sys.argv[0])
  31. docfile_dir=dirname+"/../chapters/api/"
  32. for docfile in os.listdir(docfile_dir):
  33. if docfile.count(".doxy"):
  34. loadFunctionsAndDatatypes(functions, datatypes, docfile_dir+docfile)
  35. list_incfiles = [dirname + "/../../../include/starpu_config.h.in"]
  36. for d in [dirname+"/../../../include/", dirname + "/../../../mpi/include/", dirname + "/../../../starpufft/include/", dirname + "/../../../sc_hypervisor/include/"]:
  37. list_incfiles.extend(list_files(d))
  38. incfiles=" ".join(list_incfiles)
  39. for function in functions:
  40. x = os.system("sed 's/ *STARPU_ATTRIBUTE_UNUSED *//g' " + incfiles + "| sed 's/ STARPU_WARN_UNUSED_RESULT//g' | fgrep \"" + function[0] + "\" > /dev/null")
  41. if x != 0:
  42. print("Function <" + bcolors.FAILURE + function[0] + bcolors.NORMAL + "> documented in <" + function[2] + "> does not exist in StarPU's API")
  43. os.system("grep " + function[1] + " " + dirname+"/../../../include/starpu_deprecated_api.h")
  44. for datatype in datatypes:
  45. x = os.system("fgrep -l \"" + datatype[0] + "\" " + incfiles + " > /dev/null")
  46. if x != 0:
  47. print("Datatype <" + bcolors.FAILURE + datatype[0] + bcolors.NORMAL + "> documented in <" + datatype[2] + "> does not exist in StarPU's API")
  48. os.system("grep " + datatype[1] + " " + dirname+"/../../../include/starpu_deprecated_api.h")