##// END OF EJS Templates
Warn that blck transformer will break complete-input detection....
Matthias Bussonnier -
Show More
@@ -24,6 +24,7 b' import sys'
24 import tokenize
24 import tokenize
25 import warnings
25 import warnings
26
26
27 from IPython.utils.py3compat import cast_unicode
27 from IPython.core.inputtransformer import (leading_indent,
28 from IPython.core.inputtransformer import (leading_indent,
28 classic_prompt,
29 classic_prompt,
29 ipy_prompt,
30 ipy_prompt,
@@ -686,6 +687,7 b' class IPythonInputSplitter(InputSplitter):'
686 """
687 """
687
688
688 # We must ensure all input is pure unicode
689 # We must ensure all input is pure unicode
690 lines = cast_unicode(lines, self.encoding)
689 # ''.splitlines() --> [], but we need to push the empty line to transformers
691 # ''.splitlines() --> [], but we need to push the empty line to transformers
690 lines_list = lines.splitlines()
692 lines_list = lines.splitlines()
691 if not lines_list:
693 if not lines_list:
@@ -74,6 +74,13 b' function.'
74 Transforming a full block
74 Transforming a full block
75 -------------------------
75 -------------------------
76
76
77 .. warning::
78
79 Transforming a full block at once will break the automatic detection of
80 wether a block of code is complete in interface relying on this
81 functionality, as for example terminal IPython. You will need to use a
82 shortcut to force-execute your cells.
83
77 Transforming a full block of python code is possible by implementing a
84 Transforming a full block of python code is possible by implementing a
78 :class:`~IPython.core.inputtransformer.Inputtransformer` and overwriting the
85 :class:`~IPython.core.inputtransformer.Inputtransformer` and overwriting the
79 ``push`` and ``reset`` methods. The reset method should send the full block of
86 ``push`` and ``reset`` methods. The reset method should send the full block of
@@ -108,9 +115,11 b' should give up any code it has accumulated.'
108 You may use :meth:`CoroutineInputTransformer.wrap` to simplify the creation of
115 You may use :meth:`CoroutineInputTransformer.wrap` to simplify the creation of
109 such a transformer.
116 such a transformer.
110
117
111 Here is a simple :class:`CoroutineInputTransformer` that can be though of be
118 Here is a simple :class:`CoroutineInputTransformer` that can be thought of
112 being the identity::
119 being the identity::
113
120
121 from IPython.core.inputtransformer import CoroutineInputTransformer
122
114 @CoroutineInputTransformer.wrap
123 @CoroutineInputTransformer.wrap
115 def noop():
124 def noop():
116 line = ''
125 line = ''
General Comments 0
You need to be logged in to leave comments. Login now