Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Add utf-8 encoding
  • Loading branch information
fuzzythecat authored Sep 23, 2019
commit 5b053a9a388a59627fd58e86dbb8d41821a18482
12 changes: 6 additions & 6 deletions docs/autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def add_np_implementation(function, docstring):


def read_file(path):
with open(path) as f:
with open(path, encoding='utf-8') as f:
return f.read()


Expand Down Expand Up @@ -326,7 +326,7 @@ def get_module_docstring(filepath):

Also finds the line at which the docstring ends.
"""
co = compile(open(filepath).read(), filepath, 'exec')
co = compile(open(filepath, encoding='utf-8').read(), filepath, 'exec')
if co.co_consts and isinstance(co.co_consts[0], six.string_types):
docstring = co.co_consts[0]
else:
Expand All @@ -347,8 +347,8 @@ def copy_examples(examples_dir, destination_dir):
module_path = os.path.join(examples_dir, file)
docstring, starting_line = get_module_docstring(module_path)
destination_file = os.path.join(destination_dir, file[:-2] + 'md')
with open(destination_file, 'w+') as f_out, \
open(os.path.join(examples_dir, file), 'r+') as f_in:
with open(destination_file, 'w+', encoding='utf-8') as f_out, \
open(os.path.join(examples_dir, file), 'r+', encoding='utf-8') as f_in:

f_out.write(docstring + '\n\n')

Expand Down Expand Up @@ -391,7 +391,7 @@ def generate(sources_dir):
readme = read_file(os.path.join(str(keras_dir), 'README.md'))
index = read_file(os.path.join(template_dir, 'index.md'))
index = index.replace('{{autogenerated}}', readme[readme.find('##'):])
with open(os.path.join(sources_dir, 'index.md'), 'w') as f:
with open(os.path.join(sources_dir, 'index.md'), 'w', encoding='utf-8') as f:
f.write(index)

print('Generating docs for Keras %s.' % keras.__version__)
Expand Down Expand Up @@ -457,7 +457,7 @@ def generate(sources_dir):
subdir = os.path.dirname(path)
if not os.path.exists(subdir):
os.makedirs(subdir)
with open(path, 'w') as f:
with open(path, 'w', encoding='utf-8') as f:
f.write(mkdown)

shutil.copyfile(os.path.join(str(keras_dir), 'CONTRIBUTING.md'),
Expand Down