summaryrefslogtreecommitdiff
path: root/sphinx/directives/code.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-05-22 23:42:56 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2018-05-22 23:45:58 +0900
commitdec671abd953dd2a4baa5839763d0be381685342 (patch)
tree4ae96af9756587117273d3692fd4a045346cc991 /sphinx/directives/code.py
parent94cd25f885767a58c7e889de96434333ab0e05aa (diff)
downloadsphinx-git-dec671abd953dd2a4baa5839763d0be381685342.tar.gz
Fix #4927: Display a warning when invalid values are passed to linenothreshold option of highlight directive
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r--sphinx/directives/code.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py
index 713e5ad0c..20ad5a20c 100644
--- a/sphinx/directives/code.py
+++ b/sphinx/directives/code.py
@@ -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)]