Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4a3f46

Browse files
committed
Update docs about kernelspecs and kernel_info_reply
1 parent 7ab9aa6 commit b4a3f46

3 files changed

Lines changed: 36 additions & 21 deletions

File tree

docs/source/development/kernels.rst

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,34 +112,16 @@ JSON serialised dictionary containing the following keys and values:
112112
- **display_name**: The kernel's name as it should be displayed in the UI.
113113
Unlike the kernel name used in the API, this can contain arbitrary unicode
114114
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*.
126115
- **env** (optional): A dictionary of environment variables to set for the kernel.
127116
These will be added to the current environment variables before the kernel is
128117
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.
131118

132119
For example, the kernel.json file for IPython looks like this::
133120

134121
{
135122
"argv": ["python3", "-c", "from IPython.kernel.zmq.kernelapp import main; main()",
136-
"-f", "{connection_file}"],
137-
"codemirror_mode": {
138-
"version": 3,
139-
"name": "ipython"
140-
},
123+
"-f", "{connection_file}"],
141124
"display_name": "IPython (Python 3)",
142-
"language": "python"
143125
}
144126

145127
To see the available kernel specs, run::

docs/source/development/messaging.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,11 +685,33 @@ Message type: ``kernel_info_reply``::
685685
# included in IPython.
686686
'language_version': 'X.Y.Z',
687687

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+
688701
# A banner of information about the kernel,
689702
# which may be desplayed in console environments.
690703
'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+
],
691710
}
692711

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+
693715
.. versionchanged:: 5.0
694716

695717
Versions changed from lists of integers to strings.
@@ -700,7 +722,8 @@ Message type: ``kernel_info_reply``::
700722

701723
.. versionchanged:: 5.0
702724

703-
``implementation``, ``implementation_version``, and ``banner`` keys are added.
725+
``language_info``, ``implementation``, ``implementation_version``, ``banner``
726+
and ``help_links`` keys are added.
704727

705728
.. _msging_shutdown:
706729

docs/source/development/wrapperkernels.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ following methods and attributes:
3434
interprets (e.g. Python). The 'banner' is displayed to the user in console
3535
UIs before the first prompt. All of these values are strings.
3636

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+
3747
.. method:: do_execute(code, silent, store_history=True, user_expressions=None, allow_stdin=False)
3848

3949
Execute user code.
@@ -71,6 +81,7 @@ Example
7181
implementation_version = '1.0'
7282
language = 'no-op'
7383
language_version = '0.1'
84+
language_info = {'mimetype': 'text/plain'}
7485
banner = "Echo kernel - as useful as a parrot"
7586

7687
def do_execute(self, code, silent, store_history=True, user_expressions=None,
@@ -94,7 +105,6 @@ Here's the Kernel spec ``kernel.json`` file for this::
94105

95106
{"argv":["python","-m","echokernel", "-f", "{connection_file}"],
96107
"display_name":"Echo",
97-
"language":"no-op"
98108
}
99109

100110

0 commit comments

Comments
 (0)