Show More
@@ -0,0 +1,61 b'' | |||||
|
1 | .. _extensions_overview: | |||
|
2 | ||||
|
3 | ================== | |||
|
4 | IPython extensions | |||
|
5 | ================== | |||
|
6 | ||||
|
7 | Configuration files are just the first level of customization that IPython | |||
|
8 | supports. The next level is that of extensions. An IPython extension is an | |||
|
9 | importable Python module that has a a few special function. By defining these | |||
|
10 | functions, users can customize IPython by accessing the actual runtime objects | |||
|
11 | of IPython. Here is a sample extension:: | |||
|
12 | ||||
|
13 | # myextension.py | |||
|
14 | ||||
|
15 | def load_ipython_extension(ipython): | |||
|
16 | # The ``ipython`` argument is the currently active | |||
|
17 | # :class:`InteractiveShell` instance that can be used in any way. | |||
|
18 | # This allows you do to things like register new magics, plugins or | |||
|
19 | # aliases. | |||
|
20 | ||||
|
21 | def unload_ipython_extension(ipython): | |||
|
22 | # If you want your extension to be unloadable, put that logic here. | |||
|
23 | ||||
|
24 | This :func:`load_ipython_extension` function is called after your extension is | |||
|
25 | imported and the currently active :class:`InteractiveShell` instance is passed | |||
|
26 | as the only argument. You can do anything you want with IPython at that point. | |||
|
27 | ||||
|
28 | The :func:`load_ipython_extension` will be called again is you load or reload | |||
|
29 | the extension again. It is up to the extension author to add code to manage | |||
|
30 | that. | |||
|
31 | ||||
|
32 | You can put your extension modules anywhere you want, as long as they can be | |||
|
33 | imported by Python's standard import mechanism. However, to make it easy to | |||
|
34 | write extensions, you can also put your extensions in | |||
|
35 | ``os.path.join(self.ipython_dir, 'extensions')``. This directory is added to | |||
|
36 | ``sys.path`` automatically. | |||
|
37 | ||||
|
38 | Using extensions | |||
|
39 | ================ | |||
|
40 | ||||
|
41 | There are two ways you can tell IPython to use your extension: | |||
|
42 | ||||
|
43 | 1. Listing it in a configuration file. | |||
|
44 | 2. Using the ``%load_ext`` magic function. | |||
|
45 | ||||
|
46 | To load an extension called :file:`myextension.py` add the following logic | |||
|
47 | to your configuration file:: | |||
|
48 | ||||
|
49 | c.Global.extensions = [ | |||
|
50 | 'myextension' | |||
|
51 | ] | |||
|
52 | ||||
|
53 | To load that same extension at runtime, use the ``%load_ext`` magic:: | |||
|
54 | ||||
|
55 | .. sourcecode:: ipython | |||
|
56 | ||||
|
57 | In [1]: %load_ext myextension | |||
|
58 | ||||
|
59 | To summarize, in conjunction with configuration files and profiles, IPython | |||
|
60 | extensions give you complete and flexible control over your IPython | |||
|
61 | setup. |
@@ -0,0 +1,23 b'' | |||||
|
1 | .. _plugins_overview: | |||
|
2 | ||||
|
3 | =============== | |||
|
4 | IPython plugins | |||
|
5 | =============== | |||
|
6 | ||||
|
7 | IPython has a plugin mechanism that allows users to create new and custom | |||
|
8 | runtime components for IPython. Plugins are different from extensions: | |||
|
9 | ||||
|
10 | * Extensions are used to load plugins. | |||
|
11 | * Extensions are a more advanced configuration system that gives you access | |||
|
12 | to the running IPython instance. | |||
|
13 | * Plugins add entirely new capabilities to IPython. | |||
|
14 | * Plugins are traited and configurable. | |||
|
15 | ||||
|
16 | At this point, our plugin system is brand new and the documentation is | |||
|
17 | minimal. If you are interested in creating a new plugin, see the following | |||
|
18 | files: | |||
|
19 | ||||
|
20 | * :file:`IPython/extensions/parallemagic.py` | |||
|
21 | * :file:`IPython/extensions/pretty.` | |||
|
22 | ||||
|
23 | As well as our documentation on the configuration system and extensions. |
@@ -8,6 +8,8 b' Configuration and customization' | |||||
8 | :maxdepth: 2 |
|
8 | :maxdepth: 2 | |
9 |
|
9 | |||
10 | overview.txt |
|
10 | overview.txt | |
|
11 | extensions.txt | |||
|
12 | plugins.txt | |||
11 | ipython.txt |
|
13 | ipython.txt | |
12 | editors.txt |
|
14 | editors.txt | |
13 | old.txt |
|
15 | old.txt |
@@ -133,4 +133,4 b' attributes::' | |||||
133 |
|
133 | |||
134 | c.AliasManager.user_aliases = [ |
|
134 | c.AliasManager.user_aliases = [ | |
135 | ('la', 'ls -al') |
|
135 | ('la', 'ls -al') | |
136 | ] No newline at end of file |
|
136 | ] |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now