mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
commit
157619c4e3
2
CHANGES
2
CHANGES
@ -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
|
||||
----------
|
||||
|
@ -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)]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user