Show More
@@ -112,34 +112,16 b' JSON serialised dictionary containing the following keys and values:' | |||||
112 | - **display_name**: The kernel's name as it should be displayed in the UI. |
|
112 | - **display_name**: The kernel's name as it should be displayed in the UI. | |
113 | Unlike the kernel name used in the API, this can contain arbitrary unicode |
|
113 | Unlike the kernel name used in the API, this can contain arbitrary unicode | |
114 | characters. |
|
114 | characters. | |
115 | - **language**: The programming language which this kernel runs. This will be |
|
|||
116 | stored in notebook metadata. This may be used by syntax highlighters to guess |
|
|||
117 | how to parse code in a notebook, and frontends may eventually use it to |
|
|||
118 | identify alternative kernels that can run some code. |
|
|||
119 | - **codemirror_mode** (optional): The `codemirror mode <http://codemirror.net/mode/index.html>`_ |
|
|||
120 | to use for code in this language. This can be a string or a dictionary, as |
|
|||
121 | passed to codemirror config. This only needs to be specified if it does not |
|
|||
122 | match the value in *language*. |
|
|||
123 | - **pygments_lexer** (optional): The name of a `Pygments lexer <http://pygments.org/docs/lexers/>`_ |
|
|||
124 | to use for code in this language, as a string. This only needs to be specified |
|
|||
125 | if it does not match the value in *language*. |
|
|||
126 | - **env** (optional): A dictionary of environment variables to set for the kernel. |
|
115 | - **env** (optional): A dictionary of environment variables to set for the kernel. | |
127 | These will be added to the current environment variables before the kernel is |
|
116 | These will be added to the current environment variables before the kernel is | |
128 | started. |
|
117 | started. | |
129 | - **help_links** (optional): A list of dictionaries, each with keys 'text' and |
|
|||
130 | 'url'. These will be displayed in the help menu in the notebook UI. |
|
|||
131 |
|
118 | |||
132 | For example, the kernel.json file for IPython looks like this:: |
|
119 | For example, the kernel.json file for IPython looks like this:: | |
133 |
|
120 | |||
134 | { |
|
121 | { | |
135 | "argv": ["python3", "-c", "from IPython.kernel.zmq.kernelapp import main; main()", |
|
122 | "argv": ["python3", "-c", "from IPython.kernel.zmq.kernelapp import main; main()", | |
136 |
"-f", "{connection_file}"], |
|
123 | "-f", "{connection_file}"], | |
137 | "codemirror_mode": { |
|
|||
138 | "version": 3, |
|
|||
139 | "name": "ipython" |
|
|||
140 | }, |
|
|||
141 | "display_name": "IPython (Python 3)", |
|
124 | "display_name": "IPython (Python 3)", | |
142 | "language": "python" |
|
|||
143 | } |
|
125 | } | |
144 |
|
126 | |||
145 | To see the available kernel specs, run:: |
|
127 | To see the available kernel specs, run:: |
@@ -685,11 +685,33 b' Message type: ``kernel_info_reply``::' | |||||
685 | # included in IPython. |
|
685 | # included in IPython. | |
686 | 'language_version': 'X.Y.Z', |
|
686 | 'language_version': 'X.Y.Z', | |
687 |
|
687 | |||
|
688 | # Information about the language of code for the kernel | |||
|
689 | 'language_info': { | |||
|
690 | 'mimetype': str, | |||
|
691 | ||||
|
692 | # Pygments lexer, for highlighting | |||
|
693 | # Only needed if it differs from the top level 'language' field. | |||
|
694 | 'pygments_lexer': str, | |||
|
695 | ||||
|
696 | # Codemirror mode, for for highlighting in the notebook. | |||
|
697 | # Only needed if it differs from the top level 'language' field. | |||
|
698 | 'codemirror_mode': str or dict, | |||
|
699 | }, | |||
|
700 | ||||
688 | # A banner of information about the kernel, |
|
701 | # A banner of information about the kernel, | |
689 | # which may be desplayed in console environments. |
|
702 | # which may be desplayed in console environments. | |
690 | 'banner' : str, |
|
703 | 'banner' : str, | |
|
704 | ||||
|
705 | # Optional: A list of dictionaries, each with keys 'text' and 'url'. | |||
|
706 | # These will be displayed in the help menu in the notebook UI. | |||
|
707 | 'help_links': [ | |||
|
708 | {'text': str, 'url': str} | |||
|
709 | ], | |||
691 | } |
|
710 | } | |
692 |
|
711 | |||
|
712 | Refer to the lists of available `Pygments lexers <http://pygments.org/docs/lexers/>`_ | |||
|
713 | and `codemirror modes <http://codemirror.net/mode/index.html>`_ for those fields. | |||
|
714 | ||||
693 | .. versionchanged:: 5.0 |
|
715 | .. versionchanged:: 5.0 | |
694 |
|
716 | |||
695 | Versions changed from lists of integers to strings. |
|
717 | Versions changed from lists of integers to strings. | |
@@ -700,7 +722,8 b' Message type: ``kernel_info_reply``::' | |||||
700 |
|
722 | |||
701 | .. versionchanged:: 5.0 |
|
723 | .. versionchanged:: 5.0 | |
702 |
|
724 | |||
703 |
``implementation``, ``implementation_version``, |
|
725 | ``language_info``, ``implementation``, ``implementation_version``, ``banner`` | |
|
726 | and ``help_links`` keys are added. | |||
704 |
|
727 | |||
705 | .. _msging_shutdown: |
|
728 | .. _msging_shutdown: | |
706 |
|
729 |
@@ -34,6 +34,16 b' following methods and attributes:' | |||||
34 | interprets (e.g. Python). The 'banner' is displayed to the user in console |
|
34 | interprets (e.g. Python). The 'banner' is displayed to the user in console | |
35 | UIs before the first prompt. All of these values are strings. |
|
35 | UIs before the first prompt. All of these values are strings. | |
36 |
|
36 | |||
|
37 | .. attribute:: language_info | |||
|
38 | ||||
|
39 | Language information for :ref:`msging_kernel_info` replies, in a dictionary. | |||
|
40 | This should contain the key ``mimetype`` with the mimetype of code in the | |||
|
41 | target language (e.g. ``'text/x-python'``). It may also contain keys | |||
|
42 | ``codemirror_mode`` and ``pygments_lexer`` if they need to differ from | |||
|
43 | :attr:`language`. | |||
|
44 | ||||
|
45 | Other keys may be added to this later. | |||
|
46 | ||||
37 | .. method:: do_execute(code, silent, store_history=True, user_expressions=None, allow_stdin=False) |
|
47 | .. method:: do_execute(code, silent, store_history=True, user_expressions=None, allow_stdin=False) | |
38 |
|
48 | |||
39 | Execute user code. |
|
49 | Execute user code. | |
@@ -71,6 +81,7 b' Example' | |||||
71 | implementation_version = '1.0' |
|
81 | implementation_version = '1.0' | |
72 | language = 'no-op' |
|
82 | language = 'no-op' | |
73 | language_version = '0.1' |
|
83 | language_version = '0.1' | |
|
84 | language_info = {'mimetype': 'text/plain'} | |||
74 | banner = "Echo kernel - as useful as a parrot" |
|
85 | banner = "Echo kernel - as useful as a parrot" | |
75 |
|
86 | |||
76 | def do_execute(self, code, silent, store_history=True, user_expressions=None, |
|
87 | def do_execute(self, code, silent, store_history=True, user_expressions=None, | |
@@ -94,7 +105,6 b" Here's the Kernel spec ``kernel.json`` file for this::" | |||||
94 |
|
105 | |||
95 | {"argv":["python","-m","echokernel", "-f", "{connection_file}"], |
|
106 | {"argv":["python","-m","echokernel", "-f", "{connection_file}"], | |
96 | "display_name":"Echo", |
|
107 | "display_name":"Echo", | |
97 | "language":"no-op" |
|
|||
98 | } |
|
108 | } | |
99 |
|
109 | |||
100 |
|
110 |
General Comments 0
You need to be logged in to leave comments.
Login now