Merge pull request #5003 from tk0miya/4927_warning_invalid_linenothreshold

Fix #4927: Display a warning when invalid values are passed to linenothreshold option of highlight directive
This commit is contained in:
Takeshi KOMIYA 2018-05-24 01:53:53 +09:00 committed by GitHub
commit 157619c4e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -114,6 +114,8 @@ Features added
* #4866: Wrap graphviz diagrams in ``<div>`` tag
* Add :event:`viewcode-find-source` event to viewcode extension.
* #4785: napoleon: Add strings to translation file for localisation
* #4927: Display a warning when invalid values are passed to linenothreshold
option of highlight directive
Bugs fixed
----------

View File

@ -45,18 +45,12 @@ class Highlight(SphinxDirective):
optional_arguments = 0
final_argument_whitespace = False
option_spec = {
'linenothreshold': directives.unchanged,
'linenothreshold': directives.positive_int,
}
def run(self):
# type: () -> List[nodes.Node]
if 'linenothreshold' in self.options:
try:
linenothreshold = int(self.options['linenothreshold'])
except Exception:
linenothreshold = 10
else:
linenothreshold = sys.maxsize
linenothreshold = self.options.get('linenothreshold', sys.maxsize)
return [addnodes.highlightlang(lang=self.arguments[0].strip(),
linenothreshold=linenothreshold)]