Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update read_text to use specified encoding (self._encoding|encoding) #17

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion handsdown/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def cleanup_old_docs(self) -> None:
if doc_path in preserve_paths:
continue

file_content = doc_path.read_text()
file_content = doc_path.read_text(encoding=self._encoding)
is_autogenerated = "> Auto-generated documentation" in file_content
if not is_autogenerated:
continue
Expand Down
2 changes: 1 addition & 1 deletion handsdown/md_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MDDocument:
md_doc.write()

# output is indented for readability
Path('output.md').read_text()
Path('output.md').read_text(encoding=self._encoding)
'''# My doc

- [My doc](#my-doc)
Expand Down
2 changes: 1 addition & 1 deletion handsdown/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def render_asset(name: str, target_path: Path, format_dict: Dict[str, str], enco
format_dict -- Format asset with values from the dict before writing.
encoding -- File encoding.
"""
content = pkg_resources.files(assets_resource).joinpath(name).read_text()
content = pkg_resources.files(assets_resource).joinpath(name).read_text(encoding=encoding)
content = content.format(**format_dict)
target_path.write_text(content, encoding=encoding)

Expand Down
2 changes: 1 addition & 1 deletion tests/processors/test_pep257.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TestLoader(unittest.TestCase):
def test_init(self):
pep257_docstring = (
Path(__file__).parent.parent / "static" / "pep257_docstring.txt"
).read_text()
).read_text(encoding="utf-8")
processor = PEP257DocstringProcessor()
sections = processor.build_sections(pep257_docstring)
self.assertEqual(sections[""].title, "")
Expand Down