Skip to content

Commit

Permalink
Merge pull request #61 from iamdbychkov/encoding_option
Browse files Browse the repository at this point in the history
New option "encoding" for parsing schemas from file.
  • Loading branch information
lnoor committed Jun 27, 2021
2 parents 6dcce53 + 00d54dd commit 095c64d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sphinx-jsonschema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class JsonSchema(Directive):
'lift_definitions': flag,
'auto_reference': flag,
'auto_target': flag,
'timeout': float}
'timeout': float,
'encoding': directives.encoding}

def run(self):
try:
Expand Down Expand Up @@ -159,7 +160,7 @@ def from_file(self, filename):
source = filename

try:
with open(source) as file:
with open(source, encoding=self.options.get('encoding')) as file:
data = file.read()
except IOError as error:
raise self.error(u'"%s" directive encountered an IOError while loading file: %s\n%s'
Expand Down

0 comments on commit 095c64d

Please sign in to comment.