check_chevron_links.py 818 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python3
  2. import glob
  3. import re
  4. nav_file = open('nav.adoc', 'r')
  5. nav_string = nav_file.read()
  6. adoc_files = glob.glob('pages/**/*.adoc', recursive=True)
  7. filelist = dict()
  8. for file in adoc_files:
  9. with open(file, 'r') as handle:
  10. content = handle.read()
  11. matches = re.findall(r'<<(.*?),?([\w\- ]+)>>', content)
  12. for match in matches:
  13. m = match
  14. if match[0] == "":
  15. m = match[1]
  16. else:
  17. m = match[0]
  18. if content.count("#" + m) != 1:
  19. if file not in filelist:
  20. filelist[file] = list()
  21. filelist[file].append(m)
  22. print("Files:", len(filelist))
  23. for file in filelist.keys():
  24. print(file)
  25. for match in filelist[file]:
  26. print("\t", match)