build-doc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python3
  2. import re
  3. import common
  4. from shell_helpers import LF
  5. class Main(common.LkmcCliFunction):
  6. def __init__(self):
  7. super().__init__(
  8. defaults = {
  9. 'show_time': False,
  10. },
  11. description='''\
  12. https://github.com/cirosantilli/linux-kernel-module-cheat#build-the-documentation
  13. ''',
  14. )
  15. def timed_main(self):
  16. self.sh.run_cmd(
  17. [
  18. 'asciidoctor', LF,
  19. '-o', self.env['readme_out'], LF,
  20. '-v', self.env['readme'], LF,
  21. ],
  22. out_file=self.env['build_doc_log'],
  23. )
  24. error_re = re.compile('^asciidoctor: WARNING: ')
  25. exit_status = 0
  26. if not self.env['dry_run']:
  27. with open(self.env['build_doc_log']) as f:
  28. for line in f:
  29. if error_re.search(line):
  30. exit_status = 1
  31. break
  32. return exit_status
  33. if __name__ == '__main__':
  34. Main().cli()