zephyr/doc/scripts/fix_tex.py
Ulf Magnusson 0aeba398fb doc: fix_tex: Remove redundant 'return'
Making a clean slate for some pylint CI tests.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-26 07:47:20 -05:00

43 lines
982 B
Python

#!/usr/bin/env python3
#
# Copyright (c) 2018, Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
# Fix the .tex file produced by doxygen
# before feeding to pdflatex or latexmk.
import argparse
import re
def regex_replace(tex_file):
patterns = [
# runaway argument
("}}\r?\n=\r?\n\r?\n\t{6}", "}} = ")
]
f = open(tex_file, mode='r', encoding="utf-8")
content = f.read()
f.close()
for p in patterns:
content = re.sub(p[0], p[1], content)
f = open(tex_file, mode='w', encoding="utf-8")
f.write(content)
f.close()
def main():
parser = argparse.ArgumentParser(description='Fix the .tex file produced '
'by doxygen before feeding it to '
'latexmk (or pdflatex).')
parser.add_argument('tex_file', nargs=1)
args = parser.parse_args()
regex_replace(args.tex_file[0])
if __name__ == "__main__":
main()