Show More
@@ -208,9 +208,9 b' define([' | |||||
208 |
|
208 | |||
209 | this.events.on('spec_changed.Kernel', function(event, data) { |
|
209 | this.events.on('spec_changed.Kernel', function(event, data) { | |
210 | that.set_kernelspec_metadata(data); |
|
210 | that.set_kernelspec_metadata(data); | |
211 | if (data.codemirror_mode) { |
|
211 | // Mode 'null' should be plain, unhighlighted text. | |
212 | that.set_codemirror_mode(data.codemirror_mode); |
|
212 | cm_mode = data.codemirror_mode || data.language || 'null' | |
213 | } |
|
213 | that.set_codemirror_mode(cm_mode); | |
214 | }); |
|
214 | }); | |
215 |
|
215 | |||
216 | var collapse_time = function (time) { |
|
216 | var collapse_time = function (time) { |
@@ -38,11 +38,15 b' class KernelSpec(HasTraits):' | |||||
38 | display_name = Unicode() |
|
38 | display_name = Unicode() | |
39 | language = Unicode() |
|
39 | language = Unicode() | |
40 | codemirror_mode = Any() # can be unicode or dict |
|
40 | codemirror_mode = Any() # can be unicode or dict | |
|
41 | pygments_lexer = Unicode() | |||
41 | env = Dict() |
|
42 | env = Dict() | |
42 | resource_dir = Unicode() |
|
43 | resource_dir = Unicode() | |
43 |
|
44 | |||
44 | def _codemirror_mode_default(self): |
|
45 | def _codemirror_mode_default(self): | |
45 | return self.language |
|
46 | return self.language | |
|
47 | ||||
|
48 | def _pygments_lexer_default(self): | |||
|
49 | return self.language | |||
46 |
|
50 | |||
47 | @classmethod |
|
51 | @classmethod | |
48 | def from_resource_dir(cls, resource_dir): |
|
52 | def from_resource_dir(cls, resource_dir): | |
@@ -56,12 +60,17 b' class KernelSpec(HasTraits):' | |||||
56 | return cls(resource_dir=resource_dir, **kernel_dict) |
|
60 | return cls(resource_dir=resource_dir, **kernel_dict) | |
57 |
|
61 | |||
58 | def to_dict(self): |
|
62 | def to_dict(self): | |
59 |
|
|
63 | d = dict(argv=self.argv, | |
60 |
|
|
64 | env=self.env, | |
61 |
|
|
65 | display_name=self.display_name, | |
62 |
|
|
66 | language=self.language, | |
63 | codemirror_mode=self.codemirror_mode, |
|
67 | ) | |
64 | ) |
|
68 | if self.codemirror_mode != self.language: | |
|
69 | d['codemirror_mode'] = self.codemirror_mode | |||
|
70 | if self.pygments_lexer != self.language: | |||
|
71 | d['pygments_lexer'] = self.pygment_lexer | |||
|
72 | ||||
|
73 | return d | |||
65 |
|
74 | |||
66 | def to_json(self): |
|
75 | def to_json(self): | |
67 | return json.dumps(self.to_dict()) |
|
76 | return json.dumps(self.to_dict()) | |
@@ -114,6 +123,7 b' class KernelSpecManager(HasTraits):' | |||||
114 | 'language': 'python', |
|
123 | 'language': 'python', | |
115 | 'codemirror_mode': {'name': 'ipython', |
|
124 | 'codemirror_mode': {'name': 'ipython', | |
116 | 'version': sys.version_info[0]}, |
|
125 | 'version': sys.version_info[0]}, | |
|
126 | 'pygments_lexer': 'ipython' | |||
117 | } |
|
127 | } | |
118 |
|
128 | |||
119 | @property |
|
129 | @property |
@@ -120,6 +120,9 b' JSON serialised dictionary containing the following keys and values:' | |||||
120 | to use for code in this language. This can be a string or a dictionary, as |
|
120 | to use for code in this language. This can be a string or a dictionary, as | |
121 | passed to codemirror config. The string from *language* will be used if this is |
|
121 | passed to codemirror config. The string from *language* will be used if this is | |
122 | not provided. |
|
122 | not provided. | |
|
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. The value of *language* will be | |||
|
125 | used if this is not provided. | |||
123 | - **env** (optional): A dictionary of environment variables to set for the kernel. |
|
126 | - **env** (optional): A dictionary of environment variables to set for the kernel. | |
124 | These will be added to the current environment variables before the kernel is |
|
127 | These will be added to the current environment variables before the kernel is | |
125 | started. |
|
128 | started. |
General Comments 0
You need to be logged in to leave comments.
Login now