Avoid breaking already fixed headers

This commit is contained in:
Richard Berger
2020-09-02 10:51:47 -04:00
parent 3c60a9e08e
commit e479033109

View File

@ -4,6 +4,7 @@ import shutil
import re
import argparse
index_pattern = re.compile(r"^.. index:: (fix|pair_style)\s+([a-zA-Z0-9/_]+)$")
pattern = re.compile(r"^(fix|pair_style)\s+([a-zA-Z0-9/_]+)\s+command$")
parser = argparse.ArgumentParser(description='Fixup headers in docs')
@ -21,19 +22,25 @@ for orig_file in args.files:
if line.startswith("Syntax"):
break
m = index_pattern.match(line)
if not m:
m = pattern.match(line)
if m:
command_type = m.group(1)
style = m.group(2)
if style not in styles:
styles.append(style)
base_name = '/'.join(style.split('/')[0:-1])
ext = style.split('/')[-1]
if ext not in ('omp', 'intel', 'kk', 'gpu', 'opt'):
if style not in headings:
headings[style] = []
else:
elif style not in headings[base_name]:
headings[base_name].append(style)
# write new header
@ -49,7 +56,7 @@ for orig_file in args.files:
print(file=writer)
if len(variants) > 0:
print("Accelerator Styles: ", end="", file=writer)
print("Accelerator Variants: ", end="", file=writer)
print(", ".join([f"*{v}*" for v in variants]), file=writer)
print(file=writer)