Skip to content

Commit 3c9fc86

Browse files
alhridoyalekramelaheehridoy
authored andcommitted
[Doc] Fix UTF-8 encoding issues in documentation generation on Windows (vllm-project#24361)
Signed-off-by: alekramelaheehridoy <aliqramalaheehridoy@gmail.com> Signed-off-by: alekramelaheehridoy <alekramelaheehridoy@gmail.com> Co-authored-by: alekramelaheehridoy <alekramelaheehridoy@gmail.com> Signed-off-by: xuebwang-amd <xuebwang@amd.com>
1 parent 81edff8 commit 3c9fc86

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

docs/mkdocs/hooks/generate_argparse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def on_startup(command: Literal["build", "gh-deploy", "serve"], dirty: bool):
165165
# Generate documentation for each parser
166166
for stem, parser in parsers.items():
167167
doc_path = ARGPARSE_DOC_DIR / f"{stem}.md"
168-
with open(doc_path, "w") as f:
168+
# Specify encoding for building on Windows
169+
with open(doc_path, "w", encoding="utf-8") as f:
169170
f.write(parser.format_help())
170171
logger.info("Argparse generated: %s", doc_path.relative_to(ROOT_DIR))

docs/mkdocs/hooks/generate_examples.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def determine_other_files(self) -> list[Path]:
106106

107107
def determine_title(self) -> str:
108108
if not self.is_code:
109-
with open(self.main_file) as f:
109+
# Specify encoding for building on Windows
110+
with open(self.main_file, encoding="utf-8") as f:
110111
first_line = f.readline().strip()
111112
match = re.match(r'^#\s+(?P<title>.+)$', first_line)
112113
if match:
@@ -174,6 +175,7 @@ def on_startup(command: Literal["build", "gh-deploy", "serve"], dirty: bool):
174175
doc_path = EXAMPLE_DOC_DIR / example.category / example_name
175176
if not doc_path.parent.exists():
176177
doc_path.parent.mkdir(parents=True)
177-
with open(doc_path, "w+") as f:
178+
# Specify encoding for building on Windows
179+
with open(doc_path, "w+", encoding="utf-8") as f:
178180
f.write(example.generate())
179181
logger.debug("Example generated: %s", doc_path.relative_to(ROOT_DIR))

0 commit comments

Comments
 (0)