From 346a0bd00904822531cf4300b1050b5f164718a0 Mon Sep 17 00:00:00 2001 From: Shahrad Zomorrodi <264690209+shahradzomorrodi@users.noreply.github.com> Date: Mon, 31 Aug 2026 13:11:07 -0700 Subject: [PATCH] [bugfix] Write generated documentation as UTF-8 --- docs/generate_examples.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/generate_examples.py b/docs/generate_examples.py index a84ad0c75c..c2d72c6835 100644 --- a/docs/generate_examples.py +++ b/docs/generate_examples.py @@ -586,7 +586,7 @@ def generate_flat_examples(examples: list[Example], category_indices: dict[str, # Generate the example documentation doc_path = index.path.parent / f"{example.path.stem}.md" - with open(doc_path, "w+") as f: + with open(doc_path, "w+", encoding="utf-8") as f: f.write(example.generate()) index.documents.append(example.path.stem) @@ -613,7 +613,7 @@ def generate_nested_examples(nested_structures: dict[str, dict[str, dict[str, di # Generate dataset examples using the Example class for dataset, nested_struct in datasets.items(): doc_path = category_base_dir / f"{nested_struct.filename}.md" - with open(doc_path, "w+") as f: + with open(doc_path, "w+", encoding="utf-8") as f: f.write(nested_struct.example.generate()) # Create model-level index @@ -628,14 +628,14 @@ def generate_nested_examples(nested_structures: dict[str, dict[str, dict[str, di model_index.documents.append(nested_struct.filename) # Write model index - with open(model_index.path, "w+") as f: + with open(model_index.path, "w+", encoding="utf-8") as f: f.write(model_index.generate()) # Add model to method index method_index.documents.append(model) # Write method index - with open(method_index.path, "w+") as f: + with open(method_index.path, "w+", encoding="utf-8") as f: f.write(method_index.generate()) # Add method to main category index @@ -688,12 +688,12 @@ def generate_examples(generate_main_index: bool = False) -> None: examples_index.documents.insert(0, str(rel_path).replace("\\", "/").replace(".md", "")) # Write the category index file - with open(category_index.path, "w+") as f: + with open(category_index.path, "w+", encoding="utf-8") as f: f.write(category_index.generate()) # Write the main index file if requested if generate_main_index and examples_index: - with open(examples_index.path, "w+") as f: + with open(examples_index.path, "w+", encoding="utf-8") as f: f.write(examples_index.generate())