Skip to content

Commit 56b47ba

Browse files
committed
Handle UTF-8 encoding issues in reference page generation
Updated the gen_ref_pages.py script to include error handling for UTF-8 encoding when reading markdown files. Files that cannot be decoded are skipped, and a warning is printed to inform the user.
1 parent b1872ee commit 56b47ba

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/gen_ref_pages.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,10 @@
3535
nav_file.writelines(nav.build_literate_nav())
3636

3737
for md in Path(".").glob("*.md"):
38-
with mkdocs_gen_files.open(md, "w") as f:
39-
f.write(Path(md).read_text())
38+
try:
39+
with mkdocs_gen_files.open(md, "w") as f:
40+
f.write(Path(md).read_text(encoding='utf-8', errors='replace'))
41+
except UnicodeDecodeError:
42+
# Skip files that can't be decoded as UTF-8
43+
print(f"Warning: Skipping {md} due to encoding issues")
44+
continue

0 commit comments

Comments
 (0)