##// END OF EJS Templates
move Python-specific help links to kernel_info...
Min RK -
Show More
@@ -76,7 +76,7 b' define(['
76 76 notebook_path
77 77 ) + "?download=" + download.toString();
78 78
79 var w = window.open()
79 var w = window.open();
80 80 if (this.notebook.dirty) {
81 81 this.notebook.save_notebook().then(function() {
82 82 w.location = url;
@@ -332,6 +332,7 b' define(['
332 332 this.events.on('kernel_ready.Kernel', function(event, data) {
333 333 var langinfo = data.kernel.info_reply.language_info || {};
334 334 that.update_nbconvert_script(langinfo);
335 that.add_kernel_help_links(data.kernel.info_reply.help_links || []);
335 336 });
336 337 };
337 338
@@ -374,11 +375,49 b' define(['
374 375 var that = this;
375 376
376 377 // Set menu entry text to e.g. "Python (.py)"
377 var langname = (langinfo.name || 'Script')
378 langname = langname.charAt(0).toUpperCase()+langname.substr(1) // Capitalise
378 var langname = (langinfo.name || 'Script');
379 langname = langname.charAt(0).toUpperCase()+langname.substr(1); // Capitalise
379 380 el.find('a').text(langname + ' ('+(langinfo.file_extension || 'txt')+')');
380 381 };
381 382
383 MenuBar.prototype.add_kernel_help_links = function(help_links) {
384 /** add links from kernel_info to the help menu */
385 var divider = $("#kernel-help-links");
386 if (divider.length === 0) {
387 // insert kernel help section above about link
388 var about = $("#notebook_about").parent();
389 divider = $("<li>")
390 .attr('id', "kernel-help-links")
391 .addClass('divider');
392 about.prev().before(divider);
393 }
394 // remove previous entries
395 while (!divider.next().hasClass('divider')) {
396 divider.next().remove();
397 }
398 if (help_links.length === 0) {
399 // no help links, remove the divider
400 divider.remove();
401 return;
402 }
403 var cursor = divider;
404 help_links.map(function (link) {
405 cursor.after($("<li>")
406 .append($("<a>")
407 .attr('target', '_blank')
408 .attr('title', 'Opens in a new window')
409 .attr('href', link.url)
410 .text(link.text)
411 .append($("<i>")
412 .addClass("fa fa-external-link menu-icon pull-right")
413 )
414 )
415 );
416 cursor = cursor.next();
417 });
418
419 };
420
382 421 // Backwards compatability.
383 422 IPython.MenuBar = MenuBar;
384 423
@@ -246,17 +246,9 b' class="notebook_app"'
246 246 {% set
247 247 sections = (
248 248 (
249 ("http://ipython.org/documentation.html","IPython Help",True),
250 ("http://nbviewer.ipython.org/github/ipython/ipython/tree/2.x/examples/Index.ipynb", "Notebook Help", True),
251 ),(
252 ("http://docs.python.org","Python",True),
249 ("http://nbviewer.ipython.org/github/ipython/ipython/blob/2.x/examples/Index.ipynb", "Notebook Help", True),
253 250 ("http://help.github.com/articles/github-flavored-markdown","Markdown",True),
254 ("http://docs.scipy.org/doc/numpy/reference/","NumPy",True),
255 ("http://docs.scipy.org/doc/scipy/reference/","SciPy",True),
256 ("http://matplotlib.org/contents.html","Matplotlib",True),
257 ("http://docs.sympy.org/latest/index.html","SymPy",True),
258 ("http://pandas.pydata.org/pandas-docs/stable/","pandas", True)
259 )
251 ),
260 252 )
261 253 %}
262 254
@@ -7,7 +7,7 b' import traceback'
7 7 from IPython.core import release
8 8 from IPython.utils.py3compat import builtin_mod, PY3
9 9 from IPython.utils.tokenutil import token_at_cursor, line_at_cursor
10 from IPython.utils.traitlets import Instance, Type, Any
10 from IPython.utils.traitlets import Instance, Type, Any, List
11 11 from IPython.utils.decorators import undoc
12 12
13 13 from ..comm import CommManager
@@ -71,6 +71,37 b' class IPythonKernel(KernelBase):'
71 71 for msg_type in comm_msg_types:
72 72 self.shell_handlers[msg_type] = getattr(self.comm_manager, msg_type)
73 73
74 help_links = List([
75 {
76 'text': "Python",
77 'url': "http://docs.python.org/%i.%i" % sys.version_info[:2],
78 },
79 {
80 'text': "IPython",
81 'url': "http://ipython.org/documentation.html",
82 },
83 {
84 'text': "NumPy",
85 'url': "http://docs.scipy.org/doc/numpy/reference/",
86 },
87 {
88 'text': "SciPy",
89 'url': "http://docs.scipy.org/doc/scipy/reference/",
90 },
91 {
92 'text': "Matplotlib",
93 'url': "http://matplotlib.org/contents.html",
94 },
95 {
96 'text': "SymPy",
97 'url': "http://docs.sympy.org/latest/index.html",
98 },
99 {
100 'text': "pandas",
101 'url': "http://pandas.pydata.org/pandas-docs/stable/",
102 },
103 ])
104
74 105 # Kernel info fields
75 106 implementation = 'ipython'
76 107 implementation_version = release.version
@@ -64,6 +64,9 b' class Kernel(SingletonConfigurable):'
64 64 # language.
65 65 language_info = {}
66 66
67 # any links that should go in the help menu
68 help_links = List()
69
67 70 # Private interface
68 71
69 72 _darwin_app_nap = Bool(True, config=True,
@@ -457,6 +460,7 b' class Kernel(SingletonConfigurable):'
457 460 'implementation_version': self.implementation_version,
458 461 'language_info': self.language_info,
459 462 'banner': self.banner,
463 'help_links': self.help_links,
460 464 }
461 465
462 466 def kernel_info_request(self, stream, ident, parent):
General Comments 0
You need to be logged in to leave comments. Login now