Skip to content

Commit 7ed20c1

Browse files
committed
Allow python script to reformat in place
1 parent 3e623f6 commit 7ed20c1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

scripts/reformat_docs.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def replace_block(
217217
return ''
218218

219219

220-
def convert_file(file):
220+
def convert_file(file, inplace):
221221
""" Replace documentation in file with doxygen-styled comments. """
222222
with open(file) as f:
223223
contents = f.read()
@@ -241,16 +241,22 @@ def convert_file(file):
241241
if not re.search(FILE_HEADER, new_contents):
242242
new_contents = FILE_HEADER + '\n\n' + new_contents
243243

244-
sys.stdout.write(new_contents)
244+
if inplace:
245+
with open(file, 'w') as f:
246+
f.write(new_contents)
247+
else:
248+
sys.stdout.write(new_contents)
245249

246250

247251
def main():
248252
""" Run convert_file from the command-line. """
249253
parser = argparse.ArgumentParser()
250254
parser.add_argument('file', type=str, help='The file to process')
255+
parser.add_argument('-i', '--inplace', action='store_true',
256+
help='Process in place')
251257
args = parser.parse_args()
252258

253-
convert_file(args.file)
259+
convert_file(args.file, args.inplace)
254260

255261
return 0
256262

scripts/reformat_docs_in_place.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)