1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2008 - INRIA - Vincent COUVERT
3 // Copyright (C) 2012 - 2016 - Scilab Enterprises
4 // Copyright (C) 2020 - 2021 - Samuel GOUGEON
6 // This file is hereby licensed under the terms of the GNU GPL v2.0,
7 // pursuant to article 5.3.4 of the CeCILL v.2.1.
8 // This file was originally licensed under the terms of the CeCILL v2.1,
9 // and continues to be available under such terms.
10 // For more information, see the COPYING file which you should have received
11 // along with this program.
13 function help(varargin)
15 if findfiles("SCI/modules/helptools/jar","*_help.jar") == [] then
16 error(msprintf(gettext("%s: help file(.jar) is not installed.\n"), "help"));
18 if getscilabmode() == "NWNI" then
19 error(msprintf(gettext("%s: The help browser is disabled in %s mode.\n"), "help", getscilabmode()));
24 if type(key) <> 10 then
25 error(msprintf(_("%s: Wrong type for input argument #%d: string expected.\n"),"help",1));
32 // Retrieving the browser language and former page:
33 filename = SCIHOME + filesep() + "configuration.xml"
34 res = xmlGetValues("//Setting/Profile/HelpBrowser", ["index" "lang"], filename);
44 key = stripblanks(key)
46 symbols = strsplit("()[]{}%''"":*/\.<>&^|~+-")';
47 exceptions = ["%t" "%T" "%f" "%F" "%onprompt"]; // http://bugzilla.scilab.org/15356
48 if or(part(key,1)==symbols) & exists(key)==0 & and(key~=exceptions) then
52 // Treat "$" apart because contrarily to the previous symbols, "$" is an existing variable in Scilab
53 if part(key,1)=="$" & (exists(key)==0 | length(key)==1) then
56 // Possible key redirection to Scilab's closest equivalent
57 key = helpRedirectExternal2Scilab(key)
59 // Calling the browser
60 helpbrowser(%helps(:,1), key, lang, %f);
61 // If the key is not a xml:id, then full-text search is done (See Java code)
65 // ============================================================================
67 function sciterm = helpRedirectExternal2Scilab(exterm)
69 filename = SCIHOME + filesep() + "XConfiguration.xml"
70 res = xmlGetValues("//general/documentation/body/help", "redirectMatlab2Scilab", filename);
71 if res=="checked" then
72 filename = SCI + "/modules/helptools/data/external2scilab_equiv.csv"
73 tmp = csvRead(filename,";",[],"string",[]);
74 k = find(tmp(:,1)==exterm)