Skip to content

Commit

Permalink
open with explicit utf-8 encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
benmaddison committed Jun 10, 2021
1 parent f2ceb78 commit 1a6c3d5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sphinx_xml2rfc/autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,23 @@ def gen_docs(self) -> None:
"""Generate markdown sources for building by sphinx."""
if not self.versions:
return
with open(os.path.join(self.base_dir, "toc.md"), "w") as toc_fd:
with open(os.path.join(self.base_dir, "toc.md"), "w",
encoding="utf-8") as toc_fd:
toc_fd.write("# Internet Drafts\n\n"
":::{toctree}\n"
":maxdepth: 3\n\n")
for draft, ref_types in self.version_items():
draft_toc = f"toc-{draft}"
toc_fd.write(f"{draft_toc}\n")
with open(os.path.join(self.base_dir, f"{draft_toc}.md"),
"w") as draft_toc_fd:
"w", encoding="utf-8") as draft_toc_fd:
draft_toc_fd.write(f"# `{draft}`\n\n"
f":::{{toctree}}\n\n")
for ref_type, versions in ref_types.items():
ref_type_toc = f"{draft_toc}-{ref_type}"
draft_toc_fd.write(f"{ref_type_toc}\n")
with open(os.path.join(self.base_dir, f"{ref_type_toc}.md"), # noqa: E501
"w") as ref_type_toc_fd:
"w", encoding="utf-8") as ref_type_toc_fd:
ref_type_toc_fd.write(f"# {ref_type}\n\n"
f":::{{toctree}}\n\n")
for version in versions:
Expand All @@ -184,7 +185,7 @@ def gen_docs(self) -> None:
)
ref_type_toc_fd.write(f"{draft_doc}\n")
with open(os.path.join(self.base_dir, f"{draft_doc}.md"), # noqa: E501
"w") as draft_fd:
"w", encoding="utf-8") as draft_fd:
draft_fd.write(f"# {version.ref_type}: {version.ref_name}\n\n" # noqa: E501
f":::{{xml2rfc:version}} {draft}\n" # noqa: E501
f":ref_type: {version.ref_type}\n" # noqa: E501
Expand All @@ -195,7 +196,7 @@ def gen_docs(self) -> None:
changes_toc = f"{draft_toc}-diffs"
draft_toc_fd.write(f"{changes_toc}\n")
with open(os.path.join(self.base_dir, f"{changes_toc}.md"),
"w") as changes_toc_fd:
"w", encoding="utf-8") as changes_toc_fd:
changes_toc_fd.write("# changes\n\n"
":::{toctree}\n\n")
for to_ver in self.sorted_versions(draft):
Expand All @@ -207,7 +208,7 @@ def gen_docs(self) -> None:
)
changes_toc_fd.write(f"{changes_doc}\n")
with open(os.path.join(self.base_dir, f"{changes_doc}.md"), # noqa: E501
"w") as changes_doc_fd:
"w", encoding="utf-8") as changes_doc_fd: # noqa: E501
changes_doc_fd.write(f"# {from_ver.ref.path}{to_ver.ref.path}\n\n" # noqa: E501
f":::{{xml2rfc:diff}} {draft}\n" # noqa: E501
f":from: {from_ver.ref.path}\n" # noqa: E501
Expand Down

0 comments on commit 1a6c3d5

Please sign in to comment.