Show More
@@ -87,13 +87,13 b' class FileContentsManager(FileManagerMixin, ContentsManager):' | |||||
87 | This can be used to process the file on disk, |
|
87 | This can be used to process the file on disk, | |
88 | such as converting the notebook to a script or HTML via nbconvert. |
|
88 | such as converting the notebook to a script or HTML via nbconvert. | |
89 |
|
89 | |||
90 | It will be called as (all arguments passed by keyword): |
|
90 | It will be called as (all arguments passed by keyword):: | |
91 |
|
91 | |||
92 | hook(os_path=os_path, model=model, contents_manager=instance) |
|
92 | hook(os_path=os_path, model=model, contents_manager=instance) | |
93 |
|
93 | |||
94 | path: the filesystem path to the file just written |
|
94 | - path: the filesystem path to the file just written | |
95 | model: the model representing the file |
|
95 | - model: the model representing the file | |
96 | contents_manager: this ContentsManager instance |
|
96 | - contents_manager: this ContentsManager instance | |
97 | """ |
|
97 | """ | |
98 | ) |
|
98 | ) | |
99 | def _post_save_hook_changed(self, name, old, new): |
|
99 | def _post_save_hook_changed(self, name, old, new): |
@@ -81,14 +81,14 b' class ContentsManager(LoggingConfigurable):' | |||||
81 | such as removing notebook outputs or other side effects that |
|
81 | such as removing notebook outputs or other side effects that | |
82 | should not be saved. |
|
82 | should not be saved. | |
83 |
|
83 | |||
84 | It will be called as (all arguments passed by keyword): |
|
84 | It will be called as (all arguments passed by keyword):: | |
85 |
|
85 | |||
86 | hook(path=path, model=model, contents_manager=self) |
|
86 | hook(path=path, model=model, contents_manager=self) | |
87 |
|
87 | |||
88 | model: the model to be saved. Includes file contents. |
|
88 | - model: the model to be saved. Includes file contents. | |
89 |
|
|
89 | Modifying this dict will affect the file that is stored. | |
90 | path: the API path of the save destination |
|
90 | - path: the API path of the save destination | |
91 | contents_manager: this ContentsManager instance |
|
91 | - contents_manager: this ContentsManager instance | |
92 | """ |
|
92 | """ | |
93 | ) |
|
93 | ) | |
94 | def _pre_save_hook_changed(self, name, old, new): |
|
94 | def _pre_save_hook_changed(self, name, old, new): |
@@ -171,7 +171,7 b' def interactive(__interact_f, **kwargs):' | |||||
171 | Parameters |
|
171 | Parameters | |
172 | ---------- |
|
172 | ---------- | |
173 | __interact_f : function |
|
173 | __interact_f : function | |
174 | The function to which the interactive widgets are tied. The **kwargs |
|
174 | The function to which the interactive widgets are tied. The `**kwargs` | |
175 | should match the function signature. |
|
175 | should match the function signature. | |
176 | **kwargs : various, optional |
|
176 | **kwargs : various, optional | |
177 | An interactive widget is created for each keyword argument that is a |
|
177 | An interactive widget is created for each keyword argument that is a | |
@@ -246,7 +246,7 b' def interact(__interact_f=None, **kwargs):' | |||||
246 | """ |
|
246 | """ | |
247 | Displays interactive widgets which are tied to a function. |
|
247 | Displays interactive widgets which are tied to a function. | |
248 | Expects the first argument to be a function. Parameters to this function are |
|
248 | Expects the first argument to be a function. Parameters to this function are | |
249 | widget abbreviations passed in as keyword arguments (**kwargs). Can be used |
|
249 | widget abbreviations passed in as keyword arguments (`**kwargs`). Can be used | |
250 | as a decorator (see examples). |
|
250 | as a decorator (see examples). | |
251 |
|
251 | |||
252 | Returns |
|
252 | Returns | |
@@ -256,7 +256,7 b' def interact(__interact_f=None, **kwargs):' | |||||
256 | Parameters |
|
256 | Parameters | |
257 | ---------- |
|
257 | ---------- | |
258 | __interact_f : function |
|
258 | __interact_f : function | |
259 | The function to which the interactive widgets are tied. The **kwargs |
|
259 | The function to which the interactive widgets are tied. The `**kwargs` | |
260 | should match the function signature. Passed to :func:`interactive()` |
|
260 | should match the function signature. Passed to :func:`interactive()` | |
261 | **kwargs : various, optional |
|
261 | **kwargs : various, optional | |
262 | An interactive widget is created for each keyword argument that is a |
|
262 | An interactive widget is created for each keyword argument that is a | |
@@ -264,37 +264,37 b' def interact(__interact_f=None, **kwargs):' | |||||
264 |
|
264 | |||
265 | Examples |
|
265 | Examples | |
266 | -------- |
|
266 | -------- | |
267 |
Render |
|
267 | Render an interactive text field that shows the greeting with the passed in | |
268 |
text |
|
268 | text:: | |
269 |
|
269 | |||
270 |
|
|
270 | # 1. Using interact as a function | |
271 | def greeting(text="World"): |
|
271 | def greeting(text="World"): | |
272 | print "Hello {}".format(text) |
|
272 | print "Hello {}".format(text) | |
273 | interact(greeting, text="IPython Widgets") |
|
273 | interact(greeting, text="IPython Widgets") | |
274 |
|
274 | |||
275 |
|
|
275 | # 2. Using interact as a decorator | |
276 | @interact |
|
276 | @interact | |
277 | def greeting(text="World"): |
|
277 | def greeting(text="World"): | |
278 | print "Hello {}".format(text) |
|
278 | print "Hello {}".format(text) | |
279 |
|
279 | |||
280 |
|
|
280 | # 3. Using interact as a decorator with named parameters | |
281 | @interact(text="IPython Widgets") |
|
281 | @interact(text="IPython Widgets") | |
282 | def greeting(text="World"): |
|
282 | def greeting(text="World"): | |
283 | print "Hello {}".format(text) |
|
283 | print "Hello {}".format(text) | |
284 |
|
284 | |||
285 |
Render |
|
285 | Render an interactive slider widget and prints square of number:: | |
286 |
|
286 | |||
287 |
|
|
287 | # 1. Using interact as a function | |
288 | def square(num=1): |
|
288 | def square(num=1): | |
289 | print "{} squared is {}".format(num, num*num) |
|
289 | print "{} squared is {}".format(num, num*num) | |
290 | interact(square, num=5) |
|
290 | interact(square, num=5) | |
291 |
|
291 | |||
292 |
|
|
292 | # 2. Using interact as a decorator | |
293 | @interact |
|
293 | @interact | |
294 | def square(num=2): |
|
294 | def square(num=2): | |
295 | print "{} squared is {}".format(num, num*num) |
|
295 | print "{} squared is {}".format(num, num*num) | |
296 |
|
296 | |||
297 |
|
|
297 | # 3. Using interact as a decorator with named parameters | |
298 | @interact(num=5) |
|
298 | @interact(num=5) | |
299 | def square(num=2): |
|
299 | def square(num=2): | |
300 | print "{} squared is {}".format(num, num*num) |
|
300 | print "{} squared is {}".format(num, num*num) |
@@ -1,6 +1,6 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 |
|
2 | |||
3 |
from IPython.utils.text import indent, |
|
3 | from IPython.utils.text import indent, dedent | |
4 |
|
4 | |||
5 | from IPython.terminal.ipapp import TerminalIPythonApp |
|
5 | from IPython.terminal.ipapp import TerminalIPythonApp | |
6 | from IPython.kernel.zmq.kernelapp import IPKernelApp |
|
6 | from IPython.kernel.zmq.kernelapp import IPKernelApp | |
@@ -34,13 +34,12 b' def document_config_options(classes):' | |||||
34 | dvr = dvr[:61]+'...' |
|
34 | dvr = dvr[:61]+'...' | |
35 | # Double up backslashes, so they get to the rendered docs |
|
35 | # Double up backslashes, so they get to the rendered docs | |
36 | dvr = dvr.replace('\\n', '\\\\n') |
|
36 | dvr = dvr.replace('\\n', '\\\\n') | |
37 |
lines.append(' Default: ' |
|
37 | lines.append(' Default: `%s`' % dvr) | |
38 | lines.append('') |
|
38 | lines.append('') | |
39 |
|
39 | |||
40 | help = trait.get_metadata('help') |
|
40 | help = trait.get_metadata('help') | |
41 | if help is not None: |
|
41 | if help is not None: | |
42 | help = '\n\n'.join(wrap_paragraphs(help, 76)) |
|
42 | lines.append(indent(dedent(help), 4)) | |
43 | lines.append(indent(help, 4)) |
|
|||
44 | else: |
|
43 | else: | |
45 | lines.append(' No description') |
|
44 | lines.append(' No description') | |
46 |
|
45 | |||
@@ -72,8 +71,7 b" if __name__ == '__main__':" | |||||
72 | write_doc('kernel', 'IPython kernel options', kernel_classes, |
|
71 | write_doc('kernel', 'IPython kernel options', kernel_classes, | |
73 | preamble="These options can be used in :file:`ipython_kernel_config.py`", |
|
72 | preamble="These options can be used in :file:`ipython_kernel_config.py`", | |
74 | ) |
|
73 | ) | |
75 | nbclasses = set(NotebookApp().classes) - set(kernel_classes) |
|
74 | write_doc('notebook', 'IPython notebook options', NotebookApp().classes, | |
76 | write_doc('notebook', 'IPython notebook options', nbclasses, |
|
|||
77 | preamble="To configure the IPython kernel, see :doc:`kernel`." |
|
75 | preamble="To configure the IPython kernel, see :doc:`kernel`." | |
78 | ) |
|
76 | ) | |
79 |
|
77 | |||
@@ -83,8 +81,7 b" if __name__ == '__main__':" | |||||
83 | print("WARNING: Could not import qtconsoleapp. Config options for the " |
|
81 | print("WARNING: Could not import qtconsoleapp. Config options for the " | |
84 | "Qt Console will not be documented.") |
|
82 | "Qt Console will not be documented.") | |
85 | else: |
|
83 | else: | |
86 | qtclasses = set(IPythonQtConsoleApp().classes) - set(kernel_classes) |
|
84 | write_doc('qtconsole', 'IPython Qt console options', IPythonQtConsoleApp().classes, | |
87 | write_doc('qtconsole', 'IPython Qt console options', qtclasses, |
|
|||
88 | preamble="To configure the IPython kernel, see :doc:`kernel`." |
|
85 | preamble="To configure the IPython kernel, see :doc:`kernel`." | |
89 | ) |
|
86 | ) | |
90 |
|
87 |
General Comments 0
You need to be logged in to leave comments.
Login now