diff options
Diffstat (limited to 'contrib/python/ipython/py3/IPython/sphinxext')
| -rw-r--r-- | contrib/python/ipython/py3/IPython/sphinxext/custom_doctests.py | 4 | ||||
| -rw-r--r-- | contrib/python/ipython/py3/IPython/sphinxext/ipython_directive.py | 18 |
2 files changed, 15 insertions, 7 deletions
diff --git a/contrib/python/ipython/py3/IPython/sphinxext/custom_doctests.py b/contrib/python/ipython/py3/IPython/sphinxext/custom_doctests.py index 7678fd6801a..75c2a25ccb7 100644 --- a/contrib/python/ipython/py3/IPython/sphinxext/custom_doctests.py +++ b/contrib/python/ipython/py3/IPython/sphinxext/custom_doctests.py @@ -107,10 +107,10 @@ def float_doctest(sphinx_shell, args, input_lines, found, submitted): try: rtol = float(args[2]) atol = float(args[3]) - except IndexError: + except IndexError as e: e = ("Both `rtol` and `atol` must be specified " "if either are specified: {0}".format(args)) - raise IndexError(e) + raise IndexError(e) from e try: submitted = str_to_array(submitted) diff --git a/contrib/python/ipython/py3/IPython/sphinxext/ipython_directive.py b/contrib/python/ipython/py3/IPython/sphinxext/ipython_directive.py index ac0964032a5..18bdfcae993 100644 --- a/contrib/python/ipython/py3/IPython/sphinxext/ipython_directive.py +++ b/contrib/python/ipython/py3/IPython/sphinxext/ipython_directive.py @@ -220,6 +220,8 @@ except Exception: # for tokenizing blocks COMMENT, INPUT, OUTPUT = range(3) +PSEUDO_DECORATORS = ["suppress", "verbatim", "savefig", "doctest"] + #----------------------------------------------------------------------------- # Functions and class declarations #----------------------------------------------------------------------------- @@ -263,11 +265,17 @@ def block_parser(part, rgxin, rgxout, fmtin, fmtout): block.append((COMMENT, line)) continue - if line_stripped.startswith('@'): - # Here is where we assume there is, at most, one decorator. - # Might need to rethink this. - decorator = line_stripped - continue + if any( + line_stripped.startswith("@" + pseudo_decorator) + for pseudo_decorator in PSEUDO_DECORATORS + ): + if decorator: + raise RuntimeError( + "Applying multiple pseudo-decorators on one line is not supported" + ) + else: + decorator = line_stripped + continue # does this look like an input line? matchin = rgxin.match(line) |
