mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-22 17:55:57 +01:00
51 lines
1.4 KiB
Python
Executable File
51 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import re
|
|
|
|
import common
|
|
from shell_helpers import LF
|
|
import os
|
|
import subprocess
|
|
|
|
class Main(common.LkmcCliFunction):
|
|
def __init__(self):
|
|
super().__init__(
|
|
defaults = {
|
|
'show_time': False,
|
|
},
|
|
description='''\
|
|
https://github.com/cirosantilli/linux-kernel-module-cheat#build-the-documentation
|
|
''',
|
|
)
|
|
|
|
def timed_main(self):
|
|
self.sh.run_cmd(
|
|
[
|
|
'asciidoctor', LF,
|
|
'-o', self.env['readme_out'], LF,
|
|
'-v', self.env['readme'], LF,
|
|
],
|
|
out_file=self.env['build_doc_log'],
|
|
)
|
|
error_re = re.compile('^asciidoctor: WARNING: ')
|
|
exit_status = 0
|
|
if not self.env['dry_run']:
|
|
with open(self.env['build_doc_log']) as f:
|
|
for line in f:
|
|
if error_re.search(line):
|
|
exit_status = 1
|
|
break
|
|
external_link_re = re.compile('^https?://')
|
|
for link in subprocess.check_output([
|
|
os.path.join(self.env['root_dir'], 'asciidoctor-extract-links'),
|
|
self.env['readme']
|
|
]).decode().splitlines():
|
|
if not external_link_re.match(link):
|
|
if not os.path.lexists(link):
|
|
print('error: broken link: ' + link)
|
|
exit_status = 1
|
|
return exit_status
|
|
|
|
if __name__ == '__main__':
|
|
Main().cli()
|