Show More
@@ -146,7 +146,7 b' class DisplayHook(Configurable):' | |||
|
146 | 146 | MIME type representation of the object. |
|
147 | 147 | md_dict is a :class:`dict` with the same MIME type keys |
|
148 | 148 | of metadata associated with each output. |
|
149 | ||
|
149 | ||
|
150 | 150 | """ |
|
151 | 151 | return self.shell.display_formatter.format(result) |
|
152 | 152 |
@@ -94,11 +94,11 b' class DisplayPublisher(Configurable):' | |||
|
94 | 94 | the data itself. |
|
95 | 95 | source : str, deprecated |
|
96 | 96 | Unused. |
|
97 | transient: dict, keyword-only | |
|
97 | transient : dict, keyword-only | |
|
98 | 98 | A dictionary for transient data. |
|
99 | 99 | Data in this dictionary should not be persisted as part of saving this output. |
|
100 | 100 | Examples include 'display_id'. |
|
101 | update: bool, keyword-only, default: False | |
|
101 | update : bool, keyword-only, default: False | |
|
102 | 102 | If True, only update existing outputs with the same display_id, |
|
103 | 103 | rather than creating a new output. |
|
104 | 104 | """ |
@@ -28,34 +28,34 b' class EventManager(object):' | |||
|
28 | 28 | """ |
|
29 | 29 | def __init__(self, shell, available_events): |
|
30 | 30 | """Initialise the :class:`CallbackManager`. |
|
31 | ||
|
31 | ||
|
32 | 32 | Parameters |
|
33 | 33 | ---------- |
|
34 | 34 | shell |
|
35 | The :class:`~IPython.core.interactiveshell.InteractiveShell` instance | |
|
36 |
available_ |
|
|
37 | An iterable of names for callback events. | |
|
35 | The :class:`~IPython.core.interactiveshell.InteractiveShell` instance | |
|
36 | available_events | |
|
37 | An iterable of names for callback events. | |
|
38 | 38 | """ |
|
39 | 39 | self.shell = shell |
|
40 | 40 | self.callbacks = {n:[] for n in available_events} |
|
41 | 41 | |
|
42 | 42 | def register(self, event, function): |
|
43 | 43 | """Register a new event callback. |
|
44 | ||
|
44 | ||
|
45 | 45 | Parameters |
|
46 | 46 | ---------- |
|
47 | 47 | event : str |
|
48 | The event for which to register this callback. | |
|
48 | The event for which to register this callback. | |
|
49 | 49 | function : callable |
|
50 | A function to be called on the given event. It should take the same | |
|
51 | parameters as the appropriate callback prototype. | |
|
52 | ||
|
50 | A function to be called on the given event. It should take the same | |
|
51 | parameters as the appropriate callback prototype. | |
|
52 | ||
|
53 | 53 | Raises |
|
54 | 54 | ------ |
|
55 | 55 | TypeError |
|
56 | If ``function`` is not callable. | |
|
56 | If ``function`` is not callable. | |
|
57 | 57 | KeyError |
|
58 | If ``event`` is not one of the known events. | |
|
58 | If ``event`` is not one of the known events. | |
|
59 | 59 | """ |
|
60 | 60 | if not callable(function): |
|
61 | 61 | raise TypeError('Need a callable, got %r' % function) |
@@ -80,7 +80,7 b' class EventManager(object):' | |||
|
80 | 80 | |
|
81 | 81 | def trigger(self, event, *args, **kwargs): |
|
82 | 82 | """Call callbacks for ``event``. |
|
83 | ||
|
83 | ||
|
84 | 84 | Any additional arguments are passed to all callbacks registered for this |
|
85 | 85 | event. Exceptions raised by callbacks are caught, and a message printed. |
|
86 | 86 | """ |
@@ -109,7 +109,7 b' def _define_event(callback_function):' | |||
|
109 | 109 | @_define_event |
|
110 | 110 | def pre_execute(): |
|
111 | 111 | """Fires before code is executed in response to user/frontend action. |
|
112 | ||
|
112 | ||
|
113 | 113 | This includes comm and widget messages and silent execution, as well as user |
|
114 | 114 | code cells. |
|
115 | 115 | """ |
@@ -122,14 +122,14 b' def pre_run_cell(info):' | |||
|
122 | 122 | Parameters |
|
123 | 123 | ---------- |
|
124 | 124 | info : :class:`~IPython.core.interactiveshell.ExecutionInfo` |
|
125 | An object containing information used for the code execution. | |
|
125 | An object containing information used for the code execution. | |
|
126 | 126 | """ |
|
127 | 127 | pass |
|
128 | 128 | |
|
129 | 129 | @_define_event |
|
130 | 130 | def post_execute(): |
|
131 | 131 | """Fires after code is executed in response to user/frontend action. |
|
132 | ||
|
132 | ||
|
133 | 133 | This includes comm and widget messages and silent execution, as well as user |
|
134 | 134 | code cells. |
|
135 | 135 | """ |
@@ -142,20 +142,20 b' def post_run_cell(result):' | |||
|
142 | 142 | Parameters |
|
143 | 143 | ---------- |
|
144 | 144 | result : :class:`~IPython.core.interactiveshell.ExecutionResult` |
|
145 | The object which will be returned as the execution result. | |
|
145 | The object which will be returned as the execution result. | |
|
146 | 146 | """ |
|
147 | 147 | pass |
|
148 | 148 | |
|
149 | 149 | @_define_event |
|
150 | 150 | def shell_initialized(ip): |
|
151 | 151 | """Fires after initialisation of :class:`~IPython.core.interactiveshell.InteractiveShell`. |
|
152 | ||
|
152 | ||
|
153 | 153 | This is before extensions and startup scripts are loaded, so it can only be |
|
154 | 154 | set by subclassing. |
|
155 | ||
|
155 | ||
|
156 | 156 | Parameters |
|
157 | 157 | ---------- |
|
158 | 158 | ip : :class:`~IPython.core.interactiveshell.InteractiveShell` |
|
159 | The newly initialised shell. | |
|
159 | The newly initialised shell. | |
|
160 | 160 | """ |
|
161 | 161 | pass |
@@ -94,7 +94,7 b' class ExtensionManager(Configurable):' | |||
|
94 | 94 | |
|
95 | 95 | This function looks up the extension's name in ``sys.modules`` and |
|
96 | 96 | simply calls ``mod.unload_ipython_extension(self)``. |
|
97 | ||
|
97 | ||
|
98 | 98 | Returns the string "no unload function" if the extension doesn't define |
|
99 | 99 | a function to unload itself, "not loaded" if the extension isn't loaded, |
|
100 | 100 | otherwise None. |
@@ -121,19 +121,17 b' class DisplayFormatter(Configurable):' | |||
|
121 | 121 | Returns |
|
122 | 122 | ------- |
|
123 | 123 | (format_dict, metadata_dict) : tuple of two dicts |
|
124 | ||
|
125 | 124 | format_dict is a dictionary of key/value pairs, one of each format that was |
|
126 | 125 | generated for the object. The keys are the format types, which |
|
127 | 126 | will usually be MIME type strings and the values and JSON'able |
|
128 | 127 | data structure containing the raw data for the representation in |
|
129 | 128 | that format. |
|
130 | ||
|
129 | ||
|
131 | 130 | metadata_dict is a dictionary of metadata about each mime-type output. |
|
132 | 131 | Its keys will be a strict subset of the keys in format_dict. |
|
133 | 132 | |
|
134 | 133 | Notes |
|
135 | 134 | ----- |
|
136 | ||
|
137 | 135 | If an object implement `_repr_mimebundle_` as well as various |
|
138 | 136 | `_repr_*_`, the data returned by `_repr_mimebundle_` will take |
|
139 | 137 | precedence and the corresponding `_repr_*_` for this mimetype will |
@@ -263,7 +261,7 b' class FormatterABC(metaclass=abc.ABCMeta):' | |||
|
263 | 261 | |
|
264 | 262 | def _mod_name_key(typ): |
|
265 | 263 | """Return a (__module__, __name__) tuple for a type. |
|
266 | ||
|
264 | ||
|
267 | 265 | Used as key in Formatter.deferred_printers. |
|
268 | 266 | """ |
|
269 | 267 | module = getattr(typ, '__module__', None) |
@@ -358,7 +356,7 b' class BaseFormatter(Configurable):' | |||
|
358 | 356 | |
|
359 | 357 | def _check_return(self, r, obj): |
|
360 | 358 | """Check that a return value is appropriate |
|
361 | ||
|
359 | ||
|
362 | 360 | Return the value if so, None otherwise, warning if invalid. |
|
363 | 361 | """ |
|
364 | 362 | if r is None or isinstance(r, self._return_type) or \ |
@@ -373,10 +371,10 b' class BaseFormatter(Configurable):' | |||
|
373 | 371 | |
|
374 | 372 | def lookup(self, obj): |
|
375 | 373 | """Look up the formatter for a given instance. |
|
376 | ||
|
374 | ||
|
377 | 375 | Parameters |
|
378 | 376 | ---------- |
|
379 |
obj |
|
|
377 | obj : object instance | |
|
380 | 378 | |
|
381 | 379 | Returns |
|
382 | 380 | ------- |
@@ -399,7 +397,7 b' class BaseFormatter(Configurable):' | |||
|
399 | 397 | |
|
400 | 398 | Parameters |
|
401 | 399 | ---------- |
|
402 |
typ |
|
|
400 | typ : type or '__module__.__name__' string for a type | |
|
403 | 401 | |
|
404 | 402 | Returns |
|
405 | 403 | ------- |
@@ -430,7 +428,7 b' class BaseFormatter(Configurable):' | |||
|
430 | 428 | |
|
431 | 429 | def for_type(self, typ, func=None): |
|
432 | 430 | """Add a format function for a given type. |
|
433 | ||
|
431 | ||
|
434 | 432 | Parameters |
|
435 | 433 | ---------- |
|
436 | 434 | typ : type or '__module__.__name__' string for a type |
@@ -441,10 +439,10 b' class BaseFormatter(Configurable):' | |||
|
441 | 439 | and will return the raw data in this formatter's format. |
|
442 | 440 | Subclasses may use a different call signature for the |
|
443 | 441 | `func` argument. |
|
444 | ||
|
442 | ||
|
445 | 443 | If `func` is None or not specified, there will be no change, |
|
446 | 444 | only returning the current value. |
|
447 | ||
|
445 | ||
|
448 | 446 | Returns |
|
449 | 447 | ------- |
|
450 | 448 | oldfunc : callable |
@@ -484,10 +482,10 b' class BaseFormatter(Configurable):' | |||
|
484 | 482 | and will return the raw data in this formatter's format. |
|
485 | 483 | Subclasses may use a different call signature for the |
|
486 | 484 | `func` argument. |
|
487 | ||
|
485 | ||
|
488 | 486 | If `func` is None or unspecified, there will be no change, |
|
489 | 487 | only returning the current value. |
|
490 | ||
|
488 | ||
|
491 | 489 | Returns |
|
492 | 490 | ------- |
|
493 | 491 | oldfunc : callable |
@@ -827,7 +825,7 b' class JSONFormatter(BaseFormatter):' | |||
|
827 | 825 | |
|
828 | 826 | def _check_return(self, r, obj): |
|
829 | 827 | """Check that a return value is appropriate |
|
830 | ||
|
828 | ||
|
831 | 829 | Return the value if so, None otherwise, warning if invalid. |
|
832 | 830 | """ |
|
833 | 831 | if r is None: |
General Comments 0
You need to be logged in to leave comments.
Login now