From c8073d5070a0c6f00e2fa0e237877b1b7d34a988 Mon Sep 17 00:00:00 2001 From: Samuel GOUGEON Date: Sat, 23 May 2020 19:15:45 +0200 Subject: [PATCH] * Bugs 9909 12889 fixed: helpbrowser improved (LANG, www, issues) http://bugzilla.scilab.org/9909 http://bugzilla.scilab.org/12889 Change-Id: I519a07a2a6af29f446c09db648a1ffd7f8a47e08 --- scilab/CHANGES.md | 2 + scilab/modules/gui/etc/helpbrowser_menubar.xml | 33 +++++++ .../helptools/macros/helpbrowser_menus_cb.sci | 98 ++++++++++++++++++++ .../helptools/tests/unit_tests/helpbrowser.tst | 88 ++++++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 scilab/modules/helptools/macros/helpbrowser_menus_cb.sci create mode 100644 scilab/modules/helptools/tests/unit_tests/helpbrowser.tst diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 8d830e8..040adfc 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -266,6 +266,8 @@ Bug Fixes ### Bugs fixed in 6.1.1: * [#3188](https://bugzilla.scilab.org/3188): `part()` was slower than in Scilab 4.1.2. * [#8059](https://bugzilla.scilab.org/8059): A local `.wgetrc` config file could make troubles in `atomsDownload`. +* [#9909](https://bugzilla.scilab.org/9909): In the help browser, add a way to open the online version of the current page. +* [#12889](https://bugzilla.scilab.org/12889): In the help browser, add a menu allowing to select the language of help pages, regardless of the language of the session. * [#16106](https://bugzilla.scilab.org/16106): Xcos sciblk4 user-defined blocks did not handle opar and odstate/oz correctly. * [#16342](https://bugzilla.scilab.org/16342): `strcat()` was much slower in Scilab 6.0.2. * [#16350](https://bugzilla.scilab.org/16350): in if/while conditions, the empty sparse boolean was considered as TRUE. diff --git a/scilab/modules/gui/etc/helpbrowser_menubar.xml b/scilab/modules/gui/etc/helpbrowser_menubar.xml index a6030a4..83cc218 100644 --- a/scilab/modules/gui/etc/helpbrowser_menubar.xml +++ b/scilab/modules/gui/etc/helpbrowser_menubar.xml @@ -22,6 +22,39 @@ and is replaced by the good key (control for Unix/Windows OS and meta for Mac) - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scilab/modules/helptools/macros/helpbrowser_menus_cb.sci b/scilab/modules/helptools/macros/helpbrowser_menus_cb.sci new file mode 100644 index 0000000..bfc1028 --- /dev/null +++ b/scilab/modules/helptools/macros/helpbrowser_menus_cb.sci @@ -0,0 +1,98 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2020 - Samuel GOUGEON +// +// This file is hereby licensed under the terms of the GNU GPL v2.0, +// pursuant to article 5.3.4 of the CeCILL v.2.1. +// This file was originally licensed under the terms of the CeCILL v2.1, +// and continues to be available under such terms. +// For more information, see the COPYING file which you should have received +// along with this program. + +function helpbrowser_menus_cb(action, param) + // PRIVATE function used by the help browser + + jimport org.scilab.modules.gui.helpbrowser.ScilabHelpBrowser + hb = ScilabHelpBrowser.getHelpBrowserWithoutCreation() + url = hb.getCurrentURL() + [?,?,?, currentLang] = regexp(url, "/scilab_(.+?)_help.jar/") + id = hb.getCurrentID() + isSection = grep(id, "/^section_/", "r") <> [] + tmp = msprintf("#^jar:file:/%s/modules/helptools/jar#", SCI) + isExternal = grep(url, tmp, "r") == [] + + select action + case "changeLang" + if currentLang == param then + return + else + hb.close() + global %helps + helpbrowser(%helps(:,1), id, param, %f); + end + case "online" + if isExternal + msg = _("Help browser: Pages of external modules can''t be viewed online") + messagebox(msg, "modal") + return + end + if isSection + msg = _("Help browser: Tables of contents can''t be targeted online") + messagebox(msg, "modal") + return + end + v = getversion("scilab") + v = msprintf("%d.%d.%d", v(1),v(2),v(3)) + url = "https://help.scilab.org/docs/%s/%s/%s.html" + url = msprintf(url,v, currentLang, id) + openURL(url) + + case "bugs" + if isExternal + msg = _("Help browser: Bugs of external modules can''t be listed.") + messagebox(msg, "modal") + return + end + if isSection + msg = _("Help browser: Table of contents can''t be targeted in Bugzilla") + messagebox(msg, "modal") + return + end + BugzillaSearch = "http://bugzilla.scilab.org/buglist.cgi" + .. + "?product=Scilab software&query_format=advanced" + .. + "&short_desc_type=regexp&short_desc=£"+.. + "&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED" + .. + "&order=resolution,bug_id DESC" + if ~isdef("param","l") | type(param)<>10 | param(1)<>"unresolved" + BugzillaSearch = BugzillaSearch + "&bug_status=RESOLVED" + end + prepend = "(^|[^a-zA-Z_])" + append = "([^0-9a-zA-Z_%3B]|$)" + url = strsubst(BugzillaSearch, "£", prepend+"("+id+")"+append) + openURL(url) + end +endfunction + +// --------------------------------------------------------------------------- + +function openURL(url) + v = xmlGetValues("//web/body/web", ["default-browser" "command-browser"]) + [default, cmd] = (v(1)=="true", v(2)) + + select getos() + case "Windows" + if default + winopen(url) + else + unix(msprintf("start """" %s ""%s""", v(2), url)) + end + + case "Linux" + if default, cmd = "xdg-open ", end + unix(cmd + """" + url + """") + + case "Darwin" + if default, cmd = "open ", end + unix(cmd + """" + url + """") + end +endfunction + diff --git a/scilab/modules/helptools/tests/unit_tests/helpbrowser.tst b/scilab/modules/helptools/tests/unit_tests/helpbrowser.tst new file mode 100644 index 0000000..fcd0420 --- /dev/null +++ b/scilab/modules/helptools/tests/unit_tests/helpbrowser.tst @@ -0,0 +1,88 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2020 - Samuel GOUGEON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- INTERACTIVE TEST --> + +// help browser + +// ---------------------------------------- +// Switching the language: Menu "Languages" +// ---------------------------------------- +help ones +// - Switch the language. +// - CHECK that the same page is displayed in the help browser in the +// required language, for the main 5 supported languages. + +// ------------------------------------- +// Seeing the page online: Menu "Online" +// ------------------------------------- +// - Be sure to have an active internet connexion + +// Page of a native function +// ......................... +help ones +// - Select "See this page online" +// - CHECK: +// - Your web browser must open +// - The online version of the page must be displayed +// - for the current helpbrowser language +// - for the current Scilab version + +// Page of a section summary +// ......................... +// - In the help browser, display a section summary +// - Select the "Online" menu +// - CHECK: a modal messagebox must open, saying +// "Help browser: Tables of contents can't be displayed online" +// The box is modal: you must click "OK" to close it and unlock Scilab + +// Plain page from an external module +// .................................. +// Be sure that an external module with help pages is loaded +// - In the help browser, display a plain page of the external module +// - Select the "Online" menu +// - CHECK: a modal messagebox must open, saying +// "Help browser: Pages of external modules can't be viewed online" +// The box is modal: you must click "OK" to close it and unlock Scilab + +// ----------------------------------------------------- +// List related bugs declared on bugzilla: Menu "Issues" +// ----------------------------------------------------- +// - Be sure to have an active internet connexion +// +// Issues about a native function +// .............................. +help plot2d +// a) Select the menu "Issues => List ALL issues declared for this item (online)" +// CHECK: +// * Your web browser must open +// * The listed items must all have "plot2d" in their summary +// * Unresolved issues must be listed first, sorted by decreasing bug_id +// * Resolved issues must then be listed. Their list is sorted +// a) by resolution status b) by decreasing bug_id +// b) Select the menu "Issues => List only UNRESOLVED issues declared for this item (online)" +// CHECK: +// * Your web browser must open +// * The listed items must all have "plot2d" in their summary +// * Only UNRESOLVED issues must be listed, sorted by decreasing bug_id +// This includes NEW, ASSIGNED, and REOPENED issues + +// Issues about a section summary +// .............................. +// * Display a section summary in the help browser +// * Select any item in the "Issues" menu +// * CHECK: a modal messagebox must open, saying +// "Help browser: Tables of contents can't be displayed online" + +// Issues about an external feature +// ................................ +// Be sure that an external module with help pages is loaded +// * Display a section summary in the help browser +// * In the help browser, display a plain page of the external module +// * Select any item in the "Issues" menu +// * CHECK: a modal messagebox must open, saying +// "Help browser: Bugs of external modules can't be listed" -- 1.7.9.5