Skip to content

Commit

Permalink
fix: newline problem
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Nov 2, 2023
1 parent 3b31813 commit 48ff29b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions hooks/gen_docs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def copy_file(
:param dest: Path to new file
:param add_header: Whether to add header, defaults to True
:param header: Will be placed at the top of the file, defaults to
``f"<!-- This file is autogenerated by {Path(__file__).relative_to(ROOT)}. -->\n\n"``
``f"<!-- This file is autogenerated by {Path(__file__).relative_to(ROOT)}. -->"``
NOTE: The default header will only contain correct information if the caller of
this function is the one which should be referenced in the header
"""
Expand All @@ -28,11 +28,10 @@ def copy_file(
shutil.copyfileobj(file_source, file_dest)
return
if header is None:
header_encoded = f"<!-- This file is autogenerated by {Path(inspect.stack()[1].filename).relative_to(ROOT)}. -->\n\n"
else:
header_encoded = header
header = f"<!-- This file is autogenerated by {Path(inspect.stack()[1].filename).relative_to(ROOT)}. -->"
with TemporaryFile(mode="w+") as file_header:
file_header.write(header_encoded)
file_header.write(header)
file_header.write("\n\n")
file_header.seek(0)
shutil.copyfileobj(file_header, file_dest)
shutil.copyfileobj(file_source, file_dest)

0 comments on commit 48ff29b

Please sign in to comment.