diff options
author | Shashank | 2017-05-29 12:40:26 +0530 |
---|---|---|
committer | Shashank | 2017-05-29 12:40:26 +0530 |
commit | 0345245e860375a32c9a437c4a9d9cae807134e9 (patch) | |
tree | ad51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/helptools/macros | |
download | scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2 scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip |
CMSCOPE changed
Diffstat (limited to 'modules/helptools/macros')
41 files changed, 4529 insertions, 0 deletions
diff --git a/modules/helptools/macros/add_help_chapter.bin b/modules/helptools/macros/add_help_chapter.bin Binary files differnew file mode 100755 index 000000000..9d4691122 --- /dev/null +++ b/modules/helptools/macros/add_help_chapter.bin diff --git a/modules/helptools/macros/add_help_chapter.sci b/modules/helptools/macros/add_help_chapter.sci new file mode 100755 index 000000000..31ed91d60 --- /dev/null +++ b/modules/helptools/macros/add_help_chapter.sci @@ -0,0 +1,134 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - INRIA - Pierre MARECHAL +// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +// Parameters +// +// title : A string array - Chapter title +// path : A string array - Chapter path +// modulemode : A boolean - %F by default +// - if TRUE, the chpater is consider as internal module online help, +// otherwise, it's consider as external online help, + +// Description +// +// This function adds a new entry in the helps list. The help chapter files are to +// be located in a single directory. If the given path already exists in the helps +// list, nothing is done. The function checks if the directory exist. + +function ok = add_help_chapter(helptitle,path,modulemode) + + ok = []; + + // Check input arguments + // ========================================================================= + + [lhs,rhs] = argn(0); + + // Input arguments number + // ------------------------------------------------------------------------- + + if rhs < 2 | rhs > 3 then + error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"add_help_chapter",2,3)); + end + + // Input arguments types + // ------------------------------------------------------------------------- + + if type(helptitle) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"add_help_chapter",1)); + end + + if type(path) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"add_help_chapter",2)); + end + + if (rhs>2) & (type(modulemode) <> 4) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean expected.\n"),"add_help_chapter",3)); + end + + // Input arguments dimensions + // ------------------------------------------------------------------------- + + if or( size(helptitle) <> size(path) ) then + error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n"),"add_help_chapter",1,2)); + end + + // Default value + // ========================================================================= + + if rhs < 3 then + modulemode = %F; + end + + if modulemode then + global %helps_modules; + this_help = %helps_modules; + else + global %helps; + this_help = %helps; + end + + // Save the current path + // ========================================================================= + current_directory = pwd(); + + // Loop on "path" + // ========================================================================= + path = pathconvert(path,%F); + + for i=1:size(path,"*") + + ok(i) = %F; + + // Get the absolute path of "path" + // --------------------------------------------------------------------- + + if ~isdir(path(i)) then + chdir(current_directory); + error(msprintf(gettext("%s: Wrong value for input argument #%d: An existing directory expected.\n"),"add_help_chapter",2)); + end + + chdir(path(i)); + + if getos() == "Windows" then + path(i) = getlongpathname(pwd()); + else + path(i) = pwd(); + end + + // Check if the path is already added + // --------------------------------------------------------------------- + + if find( this_help(:,1) == path(i)) <> [] then + continue; + end + + this_help = [ this_help ; path(i) helptitle(i) ]; + + ok(i) = %T; + end + + // Go to the original location + // ========================================================================= + chdir(current_directory); + + // Reshape ok + // ========================================================================= + ok = matrix(ok,size(path)); + + // That's all + // ========================================================================= + if modulemode then + %helps_modules = this_help; + else + %helps = this_help; + end + +endfunction diff --git a/modules/helptools/macros/add_module_help_chapter.bin b/modules/helptools/macros/add_module_help_chapter.bin Binary files differnew file mode 100755 index 000000000..dce019967 --- /dev/null +++ b/modules/helptools/macros/add_module_help_chapter.bin diff --git a/modules/helptools/macros/add_module_help_chapter.sci b/modules/helptools/macros/add_module_help_chapter.sci new file mode 100755 index 000000000..ba70c1596 --- /dev/null +++ b/modules/helptools/macros/add_module_help_chapter.sci @@ -0,0 +1,26 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - INRIA - Allan CORNET <allan.cornet@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function add_module_help_chapter(modulename) + + if and(getscilabmode() <> ["NW";"STD"]) then + return; + end + + path_addchapter = SCI+"/modules/"+modulename+"/help/"+getlanguage()+"/addchapter.sce"; + + if ~isfile(path_addchapter) then + path_addchapter = SCI+"/modules/"+modulename+"/help/"+getdefaultlanguage()+"/addchapter.sce"; + end + + if isfile(path_addchapter) then + exec(path_addchapter); + end + +endfunction diff --git a/modules/helptools/macros/apropos.bin b/modules/helptools/macros/apropos.bin Binary files differnew file mode 100755 index 000000000..ac0c5c3fd --- /dev/null +++ b/modules/helptools/macros/apropos.bin diff --git a/modules/helptools/macros/apropos.sci b/modules/helptools/macros/apropos.sci new file mode 100755 index 000000000..80991b5c7 --- /dev/null +++ b/modules/helptools/macros/apropos.sci @@ -0,0 +1,19 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Vincent COUVERT +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function apropos(key) + + if argn(2)<>1 then + error(msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"), "apropos", 1)); + end + + global %helps + helpbrowser(%helps(:,1), key, getlanguage(), %T); + +endfunction diff --git a/modules/helptools/macros/buildmacros.bat b/modules/helptools/macros/buildmacros.bat new file mode 100755 index 000000000..a73ca67f8 --- /dev/null +++ b/modules/helptools/macros/buildmacros.bat @@ -0,0 +1,11 @@ + +rem Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +rem Copyright (C) 2008 - INRIA +rem +rem This file must be used under the terms of the CeCILL. +rem This source file is licensed as described in the file COPYING, which +rem you should have received as part of this distribution. The terms +rem are also available at +rem http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +@..\..\..\bin\scilex -nwni -ns -e exec('buildmacros.sce');quit; diff --git a/modules/helptools/macros/buildmacros.sce b/modules/helptools/macros/buildmacros.sce new file mode 100755 index 000000000..8c7a0fb0a --- /dev/null +++ b/modules/helptools/macros/buildmacros.sce @@ -0,0 +1,15 @@ + +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +if (isdef("genlib") == %f) then + exec(SCI+"/modules/functions/scripts/buildmacros/loadgenlib.sce"); +end + +genlib("helptoolslib","SCI/modules/helptools/macros",%f,%t); diff --git a/modules/helptools/macros/clean_help.bin b/modules/helptools/macros/clean_help.bin Binary files differnew file mode 100755 index 000000000..01dc4b3de --- /dev/null +++ b/modules/helptools/macros/clean_help.bin diff --git a/modules/helptools/macros/clean_help.sci b/modules/helptools/macros/clean_help.sci new file mode 100755 index 000000000..30fc0522e --- /dev/null +++ b/modules/helptools/macros/clean_help.sci @@ -0,0 +1,337 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function clean_help(dirs) + + // dirs is a set of directories for which html manuals are to be deleted + + lines(0); + + global %helps; + global %helps_modules; + %HELPS=[%helps_modules;%helps]; + + SCI_long = pathconvert(getlongpathname(SCI),%F,%F); + + //-------------------------------------------------------------------------- + // Sauvegarde de l'environnement initial + //-------------------------------------------------------------------------- + + current_directory = pwd(); + saved_helps = %HELPS; + %helps_save = %helps; + %helps_modules_save = %helps_modules; + + //------------------------------------------------------------------ + // Patch because scicos is not written in xml + //------------------------------------------------------------------ + %helps(grep(%helps,filesep()+"modules"+filesep()+"scicos"+filesep()),:) = []; + + all_scilab_help = %F; + + [lhs,rhs] = argn(0); + + // Trop de paramêtres + // --------------------------------------------------------------------- + + if rhs > 1 | rhs < 0 then + error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"),"clean_help",0,1)); + end + + // Cas par défaut : Aide en ligne de Scilab + // --------------------------------------------------------------------- + + if (rhs == 0) | (dirs == []) then + + all_scilab_help = %T; + + dirs_to_build = %HELPS; + dirs_to_build_m = %helps_modules; + dirs_to_build_c = %helps; + + dirs = get_xml_path(dirs_to_build(:,1)); + dirs_m = get_xml_path(dirs_to_build_m(:,1)); + dirs_c = get_xml_path(dirs_to_build_c(:,1)); + + dirs( find(dirs == "")) = []; + dirs_m( find(dirs_m == "")) = []; + dirs_c( find(dirs_c == "")) = []; + end + + // On transforme le ou les chemins donnés en chemin absolu + // --------------------------------------------------------------------- + + for k=1:size(dirs,"*"); + if ~isdir(dirs(k)) then + error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",dirs(k))); + end + + chdir(dirs(k)); + if getos() == "Windows" then + dirs(k) = getlongpathname(pwd()); + else + dirs(k) = pwd(); + end + chdir(current_directory); + end + + if all_scilab_help then + for k=1:size(dirs_m,"*"); + if ~isdir(dirs_m(k)) then + error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",dirs_m(k))); + end + chdir(dirs_m(k)); + if getos() == "Windows" then + dirs_m(k) = getlongpathname(pwd()); + else + dirs_m(k) = pwd(); + end + chdir(current_directory); + end + + for k=1:size(dirs_c,"*"); + if ~isdir(dirs_c(k)) then + error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",dirs_c(k))); + end + chdir(dirs_c(k)); + if getos() == "Windows" then + dirs_c(k) = getlongpathname(pwd()); + else + dirs_c(k) = pwd(); + end + chdir(current_directory); + end + end + + mprintf(gettext("-- Deleting help files --\n")); + + if all_scilab_help then + + // Clean up helptools dir + // --------------------------------------------------------------------- + + if isfile(SCI+pathconvert("/modules/helptools/master_"+getlanguage()+"_help.xml",%f,%f)) then + mprintf("."); + mdelete(SCI+pathconvert("/modules/helptools/master_"+getlanguage()+"_help.xml",%f,%f)); + end + + // Now, remove the generated files + + format_to_test = ["chm";"ps";"pdf";"jar"]; + + for k=1:size(format_to_test,"*") + help_file_to_rm = pathconvert(SCI+"/modules/helptools/"+format_to_test(k)+"/scilab_"+getlanguage()+"_help."+format_to_test(k),%f,%f); + log_file_to_rm = pathconvert(SCI+"/modules/helptools/scilab_"+getlanguage()+"_help."+format_to_test(k)+".log",%f,%f); + + if fileinfo(help_file_to_rm)<>[] then + mprintf("."); + mdelete(help_file_to_rm); + mdelete(log_file_to_rm); + end + end + + html_dir = pathconvert(SCI+"/modules/helptools/html/"+getlanguage()); + + // remove the generated html tree + + if isdir(html_dir) then + mprintf("."); + rmdir(html_dir,"s"); + end + + // Now, remove the temporary files + + format_to_test = ["chm";"ps";"pdf";"javaHelp";"html"]; + + for k=1:size(format_to_test,"*") + dir_to_rm = pathconvert(SCI+"/modules/helptools/"+format_to_test(k)+"/scilab_"+getlanguage()+"_help",%f,%f); + if isdir(dir_to_rm) then + mprintf("."); + rmdir(dir_to_rm,"s"); + end + end + + // Cleanup directories one by one + // --------------------------------------------------------------------- + + for k=1:size(dirs_m,"*") // help directory + + files_to_delete = listfiles([ .. + dirs_m(k)+"/.list*"; .. + dirs_m(k)+"/.last*"; .. + ]); + + for i=1:size(files_to_delete,"*") + if isfile(pathconvert(files_to_delete(i),%f,%f)) then + mprintf("."); + mdelete(files_to_delete(i)); + end + end + end + + // Toolbox directories + // --------------------------------------------------------------------- + + for k=1:size(dirs_c,"*") // help directory + + files_to_delete = listfiles([ .. + dirs_c(k)+"/.list*"; .. + dirs_c(k)+"/.last*"; .. + dirs_c(k)+"/master_help.xml"; .. + ]); + + for i=1:size(files_to_delete,"*") + if isfile(pathconvert(files_to_delete(i),%f,%f)) then + mprintf("."); + mdelete(files_to_delete(i)); + end + end + + // Now, remove the temporary files + + dir_to_rm = pathconvert(dirs_c(k)+"/scilab_"+getlanguage()+"_help",%f,%f); + if isdir(dir_to_rm) then + mprintf("."); + rmdir(dir_to_rm,"s"); + end + + // Now, remove the generated files + + format_to_test = ["chm";"ps";"pdf";"jar"]; + + for i=1:size(format_to_test,"*") + help_file_to_rm = pathconvert(dirs_c(k)+"/../../"+format_to_test(i)+"/scilab_"+getlanguage()+"_help."+format_to_test(i),%f,%f); + log_file_to_rm = pathconvert(dirs_c(k)+"/scilab_"+getlanguage()+"_help."+format_to_test(i)+".log",%f,%f); + + if isfile(file_to_rm) then + mprintf("."); + mdelete(file_to_rm); + mdelete(log_file_to_rm); + end + end + + html_dir = pathconvert(dirs_c(k)+"/../../html/"+getlanguage()); + + // remove the generated html tree + + if isdir(html_dir) then + mprintf("."); + rmdir(html_dir,"s"); + end + + end + + else + + for k=1:size(dirs,"*") // help directory + + dir_language = guess_lang(dirs(k)); + + files_to_delete = listfiles([ .. + dirs(k)+"/.list*"; .. + dirs(k)+"/.last*"; .. + dirs(k)+"/master_help.xml"; .. + ]); + + for i=1:size(files_to_delete,"*") + if isfile(pathconvert(files_to_delete(i),%f,%f)) then + mprintf("."); + mdelete(files_to_delete(i)); + end + end + + // Now, remove the temporary files + + dir_to_rm = pathconvert(dirs(k)+"/scilab_"+dir_language+"_help",%f,%f); + + if isdir(dir_to_rm) then + mprintf("."); + rmdir(dir_to_rm,"s"); + end + + // Now, remove the generated files + + format_to_test = ["chm";"ps";"pdf";"jar"]; + + for i=1:size(format_to_test,"*") + help_file_to_rm = pathconvert(dirs(k)+"/../../"+format_to_test(i)+"/scilab_"+dir_language+"_help."+format_to_test(i),%f,%f); + log_file_to_rm = pathconvert(dirs(k)+"/scilab_"+dir_language+"_help."+format_to_test(i)+".log",%f,%f); + + if isfile(help_file_to_rm) then + mprintf("."); + mdelete(help_file_to_rm); + mdelete(log_file_to_rm); + end + end + + html_dir = pathconvert(dirs(k)+"/../../html/"+dir_language); + + // remove the generated html tree + + if isdir(html_dir) then + mprintf("."); + rmdir(html_dir,"s"); + end + + end + + end + + mprintf("\n"); + + // On remet l'environement initial + //-------------------------------------------------------------------------- + + chdir(current_directory); + %helps = %helps_save; + %helps_modules = %helps_modules_save; + %HELPS = saved_helps; + +endfunction + + + +function dirs_out = get_xml_path(dirs_in) + + dirs_out = []; + + for k=1:size(dirs_in,"*") + + if basename(dirs_in(k)) == "jar" then + + help_basepath = part(dirs_in(k),1:length(dirs_in(k))-4) + filesep() + "help"; + + if isdir(help_basepath + filesep() +getlanguage()) then + dirs_out(k) = help_basepath + filesep() + getlanguage(); + elseif isdir(help_basepath+filesep()+getdefaultlanguage()) then + dirs_out(k) = help_basepath+filesep()+getlanguage(); + else + dirs_out(k) = ""; + end + + else + dirs_out(k) = dirs_in(k); + end + + end + +endfunction + + +function language_out = guess_lang(dir_in) + + language_out = getlanguage(); + + [my_start,my_end,my_match] = regexp(basename(dir_in),"/([a-z][a-z]_[A-Z][A-Z])$/"); + + if my_start <> [] then + language_out = part(my_match,1:5); + end + +endfunction diff --git a/modules/helptools/macros/cleanmacros.bat b/modules/helptools/macros/cleanmacros.bat new file mode 100755 index 000000000..4ad1bbae2 --- /dev/null +++ b/modules/helptools/macros/cleanmacros.bat @@ -0,0 +1,13 @@ + +rem Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +rem Copyright (C) 2008 - INRIA +rem +rem This file must be used under the terms of the CeCILL. +rem This source file is licensed as described in the file COPYING, which +rem you should have received as part of this distribution. The terms +rem are also available at +rem http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +@del *.bin 2>NUL +@del lib 2>NUL +@del names 2>NUL diff --git a/modules/helptools/macros/del_help_chapter.bin b/modules/helptools/macros/del_help_chapter.bin Binary files differnew file mode 100755 index 000000000..3998edb64 --- /dev/null +++ b/modules/helptools/macros/del_help_chapter.bin diff --git a/modules/helptools/macros/del_help_chapter.sci b/modules/helptools/macros/del_help_chapter.sci new file mode 100755 index 000000000..faa592803 --- /dev/null +++ b/modules/helptools/macros/del_help_chapter.sci @@ -0,0 +1,94 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function del_help_chapter(help_to_del,modulemode) + + // ========================================================================= + // Author : Pierre MARECHAL + // Scilab team + // Copyright INRIA + // Date : August 1st 2006 + // + // del_help_chapter(title,modulemode) + // + // Parameters + // + // title : a character string : + // - the help chapter title or + // - the module name + // + // Description + // + // This function deletes a entry in the helps list. + // ========================================================================= + + global %helps; + global %helps_modules; + + // Check input arguments + // ------------------------------------------------------------------------- + [lhs,rhs] = argn(0); + if (rhs<1) | (rhs>2) then error(39); end + if (rhs == 1) then modulemode=%F; end + if type(help_to_del) <> 10 then error(55,1); end + + // Is the first parameter a module name ? + // ------------------------------------------------------------------------- + + is_module_name = %F; + module_list = getmodules(); + is_module_name = find(module_list == help_to_del) <> [] + + // If yes, add the path + // ------------------------------------------------------------------------- + + if is_module_name then + help_to_del = pathconvert(SCI+"/modules/"+help_to_del+"/help/"+getlanguage(),%F,%F); + end + + // Now, check if help_to_del is present in the %helps_modules matrix + // ------------------------------------------------------------------------- + + if modulemode then + + k1 = find( %helps_modules(:,2) == help_to_del); + if k1 <> [] then + %helps_modules(k1,:) = []; + end + + else + + k1 = find( %helps(:,2) == help_to_del); + if k1 <> [] then + %helps(k1,:) = []; + end + + end + + if strindex(stripblanks(help_to_del),"(*)") == (length(stripblanks(help_to_del)) - 2) then + + help_to_del = strsubst(help_to_del,"(*)",""); + help_to_del = stripblanks(help_to_del); + + for i=1:100 + if modulemode then + k2 = find( %helps_modules(:,2) == help_to_del+" ("+string(i)+")" ); + if k2 <> [] then + %helps_modules(k2,:) = []; + end + else + k2 = find( %helps(:,2) == help_to_del+" ("+string(i)+")" ); + if k2 <> [] then + %helps(k2,:) = []; + end + end + end + end + +endfunction diff --git a/modules/helptools/macros/del_module_help_chapter.bin b/modules/helptools/macros/del_module_help_chapter.bin Binary files differnew file mode 100755 index 000000000..166520557 --- /dev/null +++ b/modules/helptools/macros/del_module_help_chapter.bin diff --git a/modules/helptools/macros/del_module_help_chapter.sci b/modules/helptools/macros/del_module_help_chapter.sci new file mode 100755 index 000000000..90354dbbb --- /dev/null +++ b/modules/helptools/macros/del_module_help_chapter.sci @@ -0,0 +1,21 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - INRIA - Allan CORNET <allan.cornet@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function del_module_help_chapter(modulename) + path_removechapter = SCI+"/modules/"+modulename+"/help/"+getlanguage()+"/removechapter.sce"; + if ~isfile(path_removechapter) then + path_removechapter = SCI+"/modules/"+modulename+"/help/"+getdefaultlanguage()+"/removechapter.sce"; + end + try + exec(path_removechapter); + catch + warning(" incorrect module path "+path_removechapter); + end +endfunction +// ==================================================================== diff --git a/modules/helptools/macros/extract_help_examples.bin b/modules/helptools/macros/extract_help_examples.bin Binary files differnew file mode 100755 index 000000000..7af3b05cc --- /dev/null +++ b/modules/helptools/macros/extract_help_examples.bin diff --git a/modules/helptools/macros/extract_help_examples.sci b/modules/helptools/macros/extract_help_examples.sci new file mode 100755 index 000000000..2de6f4a92 --- /dev/null +++ b/modules/helptools/macros/extract_help_examples.sci @@ -0,0 +1,777 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Serge STEER <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function extract_help_examples(dirpaths) + + // given a vector of strings giving help chapter paths, or nothinf for + // the default scilab help chapter paths, + // this function build in SCI/tests/Examples the files required for + // testing the examples given in all xml help files available in the + // given paths. + + global %helps + global %helps_modules + if %helps_modules == [] then + moduleslist = getmodules(); + for i = 1:size(moduleslist,"*") + add_module_help_chapter(moduleslist(i)); + end + end + %HELPS=[%helps_modules;%helps]; + + logfile=mopen("extract_help_examples.log","w") + lsave=lines();lines(0) + if argn(2)<1 then + dirpaths=%HELPS(:,1)'; + end + for d=dirpaths + helppaths=listfiles(pathconvert(d+"/*.xml",%f,%t))'; + mfprintf(logfile,"\nExtracting examples from "+d+"\n"); + mprintf("\n-- Extracting examples from "+d+"\n"); + count=0 + for h=helppaths + mprintf(h+"\n") + build_example_test(h,logfile) + end + mfprintf(logfile,"\n") + mprintf("\n") + end + lines(lsave(2)) + mclose(logfile) + +endfunction + + + +function build_example_test(xml_path,logfile) + + // given the path of an xml help file + // this function build in SCI/tests/Examples the files required for + // testing the examples given in the xml help file + + name=basename(xml_path) + if argn(2)<2 then logfile=mopen(name+".log","w"),end + + T=extract_help_example(xml_path); //look for examples + + if T<>[] then //an example is given + t=gettesttype(T) //check if it includes interactive or graphic functions + gen_test_files(T,name,t); + end + +endfunction + + + + +function t=gettesttype(T) + + interactive=["%io(1)","mscanf","dialog","tk","message","getcolor", ... + "xset()","xclick","xgetmouse", "locate","edit", ... + "x_choices","x_matrix","show_graph","addmenu","delmenu",.. + "uicontrol","uimenu","showprofile","editor","emacs","setbpt",.. + "eventhandler","dragrect","rubber","getfile","getvalue",... + "portrait","plotprofile","getfont","getmark","getlinestyle"] + + graphics=["plot","pie","bar","mesh","barh","xrect","xstring","xarc","xfarc","xpoly","xfpoly","xarrow", ... + "xset(", "xget(","contour","bode","black","nyquist","evans", ... + "param3d","champ(","surf","gcf(","gca(", "gce(", "champ1", "drawaxis",.. + "xgraduate","glue","polar","mapsound"] + + //deff('foo',T) + //T=primitives('foo') + + if grep(T,interactive)<>[] then + t="i" + elseif grep(T,graphics)<>[] then + t="g" + else + t="" + end + +endfunction + + + + +function T=extract_help_example(h) + + //extract the example out of an xml help file + + if name=="man" then T=[],return,end + T=mgetl(h); + [row,which]=grep(T,["<EXAMPLE>","</EXAMPLE>"]); + if row<>[] then + if size(row,"*")==1 then row=[row row],end + T=T(row(1):row(2)); + T(1)=stripblanks(strsubst(T(1),"<EXAMPLE>","")); + T($)=stripblanks(strsubst(T($),"</EXAMPLE>","")); + if length(T(1))==0 then T(1)=[];end + if length(T($))==0 then T($)=[];end + if T<>[] then + T(1)=stripblanks(strsubst(T(1),"<![CDATA[","")); + T($)=stripblanks(strsubst(T($),"]]>","")); + if length(T(1))==0 then T(1)=[];end + if length(T($))==0 then T($)=[];end + end + else + T=[] + end + +endfunction + + + +function gen_test_files(instructions,name,t) + + //set output directory + + select t + case "i" then + test_path="SCI/tests/interactive_tests/" + case "g" + test_path="SCI/tests/graphical_tests/" + else + test_path="SCI/tests/automatic_tests/" + end + + //set file names + tst=pathconvert(test_path+name+".tst",%f,%f) + ref=pathconvert(test_path+name+"_data.ref",%f,%f) + dia=strsubst(tst,".tst",".dia") + + interactive=t=="i" + + info=fileinfo(tst)//to check if the .tst file exists + + generate_dataref=%f;generate_tst=%f; + if info==[] //no <name>.tst file exists + mfprintf(logfile,"\n New Example "+name+" the reference is built. Check\n") + generate_tst=%t + if ~interactive then + generate_dataref=%t + T=instrument_instruction("cmp",instructions,ref); + end + else + // a tst file exists, check for validity + //compare it with instructions + T=instrument_instruction("cmp",instructions,ref); + if newest(tst,xml_path)==1 then + if fileinfo(ref)==[]&(~interactive) then + mfprintf(logfile,"\n Example in "+name+"_data.ref no more exist, It is regenerated\n") + generate_dataref=%t + end + else + T1=mgetl(tst); + if or(T1<>T) then + mfprintf(logfile,"\n Example in "+name+" help file has changed, the reference is updated. Check\n") + generate_tst=%t + generate_dataref=%t + elseif fileinfo(ref)==[]&(~interactive) then + mfprintf(logfile,"\n Example in "+name+"_data.ref no more exist, It is regenerated\n") + generate_dataref=%t + end + end + end + + if generate_dataref&(~interactive) then + + //build the reference data + + Tb=instrument_instruction("build",instructions,ref); + build_reference_data(Tb) + + [x,ierr]=fileinfo(ref) + if x(1)==0 then mfprintf(logfile,"generated file: "+name+"_data.ref is Empty "),end + end + + if generate_tst then + // write down the test script + mputl(T,tst), + //remove the <name>.dia file + if fileinfo(dia)<>[] then deletefile(pathconvert(dia,%f,%t)); end + dia=dia+".ref" + //remove the <name>.dia.ref file + if fileinfo(dia)<>[] then deletefile(pathconvert(dia,%f,%t)); end + end + +endfunction + + + +function build_reference_data(instructions) + + mputl(instructions,TMPDIR+"/temp.tst") + + // Execute the temporary file to generate the data reference file + if execstr("exec(TMPDIR+''/temp.tst'',-1)","errcatch")<>0 then + mclose(%U) + end + +endfunction + + + +function instructions=instrument_instruction(job,instructions,refpath) + + //Author : Serge Steer, april 2005, Copyright INRIA + // + //Executes the given instructions saving all the intermediate + // results into a Scilab binary file. + // This function must mirror the run_with_ref one. + + if argn(2)<>3 then error(42),end + // Form a function with the given instructions + mputl(["function %test()";instructions;"xdel(winsid());";"endfunction"],TMPDIR+"/test.sci") + // Compile and load it + //use exec instead of getf to handle inline functions definition + exec(TMPDIR+"/test.sci",-1); + // Get the pseudo-code image + + l1=macr2lst(%test) + + // Adapt the pseudo-code to add build or run tools + if job=="build" then + l=add_ref_code(list(l1(5:$))); + else //run + l=add_cmp_code(list(l1(5:$))); + end + l=list(l(1:$-2)); + + // Generate the Scilab instructions from the modified pseudo-code + txt=pseudocode2text(l) + + // Add opening and closing instructions + instructions=[] + if job<>"build" then instructions="getf SCI/util/testexamples.sci",end + instructions=[instructions;"reinit_for_test()"]; + if job=="build" then + instructions=[instructions;"%U=mopen(''"+refpath+"'',''wb'');"] + else + instructions=[instructions;"%U=mopen(''"+refpath+"'',''rb'');"] + end + instructions=[instructions; txt;"mclose(%U);"]; + +endfunction + + + +function p=primitives(mac_name,p) + + //search for the primitives called by a given macro, the second arg is + //for recursive calls only + + funcprot(0) + global scanned_macros + + if argn(2)==1 then p=[],scanned_macros=[];end + ierr=execstr("vars=macrovar("+mac_name+")","errcatch") + if ierr<>0 then return,end + called=vars(4);nc=size(called,1) + if nc==0 then p=[],return,end + to_get=[] + for k=1:nc + if find(called(k)==scanned_macros)<>[] then + to_get=[to_get,%f]; + else + to_get=[to_get,%t]; + end + end + called=called(to_get) + nc=size(called,"*") + for k=1:nc + clear w + execstr("w="+called(k)) + if type(w)==130 then + if grep(p,called(k))==[] then p=[p called(k)],end + else + scanned_macros=[scanned_macros called(k)] + p=primitives(called(k),p) + end + end + +endfunction + + +function txt=pseudocode2text(p) + + //Author : Serge Steer, april 2005, Copyright INRIA + // + //Generate Scilab instructions corresponding to the pseudo-code + + //make ins2sci known + prot=funcprot();funcprot(0);fun2string=fun2string;funcprot(prot); + //initialize variables for it + lcount=1;level=[0,0]; + quote="''" + dquote="""" + CR="\@" + opstable() + txt=ins2sci(mmodlst(p),1) +endfunction + + + +function ln=add_ref_code(l) + + //Author : Serge Steer, april 2005, Copyright INRIA + // + //Given a pseudo-code this function add code after each affectation + //operation (29) to save lhs variables into a binary file + + ln=list()// initialize result pseudo-code image + for k=1:size(l) //loop on pseudo-codes + lk=l(k); + if type(lk)==10 then //regular pseudo-code + + if lk(1)=="29" then //affectation operation + if and(lk(2)<>["52" "43" "99"]) then lk(2)="52",end + + if or(lk(2)==["52" "99"]) then + + //display required build reference + lk(2)="43" //disable display + if lk(3)=="ans" then + if and(l(k-1)==["5","25","1","1"])&l(k-2)(1)=="2" then + vv=l(k-2)(2) + lk(3)=l(k-2)(2) + if exists(vv)==1 then + execstr("var="+vv) + if exists(vv)==1&or(type(var)==[11 13 130]) then + //name is a function, syntax is equivalent to ans=name() + lk(3)="%ans"; + end + end + elseif and(l(k-1)==["20","deff","2","1"]) then + ln($+1)=lk + continue + else + lk(3)="%ans"; + end + end + + ln($+1)=lk + + for i=3:2:size(lk,"*") + ln($+1)="15" //newline + name=lk(i);ref=name+"_ref" + // add instruction: save_ref('''+name+'''); + // + ln($+1)=["3",name]; + ln($+1)=["2","save_ref","-2","1"]; + ln($+1)=["5","25","2","1"]; + ln($+1)=["29","43","ans","0"]; + end + + ln($+1)="15"; + else + ln($+1)=lk + end + + elseif lk(1)=="2"&or(lk(2)==["xdel","clf"]) then + //change some function names to allow overloading + lk(2)=lk(2)+"_build" + ln($+1)=lk + + else //other operations, just copy them + ln($+1)=lk + end + + elseif type(lk)==15 then //control structure starts + lt=lk(1) + //call the add_ref_code function recursively for imbedded instructions + if or(lt(1)==["if","while"]) then + lnk=list(lk(1),lk(2)) + for i=3:size(lk), lnk($+1)=add_ref_code(lk(i));end + ln($+1)=lnk + elseif lt(1)=="for" then + ln($+1)=list(lk(1),lk(2),add_ref_code(lk(3))) + elseif lt(1)=="select" then + lnk=list(lk(1),lk(2)) + for i=3:2:size(lk)-1 //the "case" sequence + lnk($+1)=lk(i) + lnk($+1)=add_ref_code(lk(i+1)); + end + //the else + if i+2==size(lk) then lnk($+1)=add_ref_code(lk(i+2));end + ln($+1)=lnk + end + end + end +endfunction + + + +function ln=add_cmp_code(l) + + //Author : Serge Steer, april 2005, Copyright INRIA + // + //Given a pseudo-code this function add code after each affectation + //operation (29) to compare lhs variables with references given in a binary file + // This function must mirror the add_ref_code one + + ln=list() // initialize result pseudo-code image + for k=1:size(l) //loop on pseudo-codes + lk=l(k); + if type(lk)==10 then //regular pseudo-code + if lk(1)=="29" then //affectation operation + if and(lk(2)<>["52" "43" "99"]) then lk(2)="52",end + if or(lk(2)==["52" "99"]) then + //display required compare result with reference + lk(2)="43"// disable display + if lk(3)=="ans" then + if and(l(k-1)==["5","25","1","1"])&l(k-2)(1)=="2" then + vv=l(k-2)(2) + lk(3)=l(k-2)(2) + if exists(vv)==1 then + execstr("var="+vv) + if exists(vv)==1&or(type(var)==[11 13 130]) then + //name is a function, syntax is equivalent to ans=name() + lk(3)="%ans"; + end + end + elseif and(l(k-1)==["20","deff","2","1"]) then + ln($+1)=lk + continue + else + lk(3)="%ans"; + end + end + + ln($+1)=lk + + for i=3:2:size(lk,"*") + ln($+1)="15"//newline + name=lk(i);ref=name+"_ref"; + // add instruction: if load_ref('''+name+''') then pause;end + ln($+1)=list("if",list(["3",name],["2","load_ref","-2","1"],["5","25","2","1"]),.. + list("12"),list()) + end + + ln($+1)="15" + else + ln($+1)=lk + end + elseif lk(1)=="2"&or(lk(2)==["xdel","clf"]) then + //change some function names to allow overloading + lk(2)=lk(2)+"_run" + ln($+1)=lk + else //other operations, just copy them + ln($+1)=lk + end + elseif type(lk)==15 then //control structure starts + lt=lk(1) + //call the add_ref_code function recursively for imbedded instructions + if or(lt(1)==["if","while"]) then + lnk=list(lk(1),lk(2)) + for i=3:size(lk), lnk($+1)=add_cmp_code(lk(i));end + ln($+1)=lnk + elseif lt(1)=="for" then + ln($+1)=list(lk(1),lk(2),add_cmp_code(lk(3))) + elseif lt(1)=="select" then + lnk=list(lk(1),lk(2)) + for i=3:2:size(lk)-1 //the "case" sequence + lnk($+1)=lk(i) + lnk($+1)=add_cmp_code(lk(i+1)); + end + //the else + if i+2==size(lk) then lnk($+1)=add_cmp_code(lk(i+2));end + ln($+1)=lnk + end + end + end + +endfunction + + + +function r=xbasc_build(w) + + //Author : Serge Steer, april 2005, Copyright INRIA + // + //Save the graphic windows to be cleared in a Scilab binary file. + // This function must mirror the xbasc_run one. + + r=%f + if winsid()==[] then return,end + cur=xget("window") + // + if argn(2)==1 then + ids_ref=[] + + for k=1:size(w,"*") + xset("window",w(k)) + if get("figure_style")=="new" then ids_ref=[ids_ref,w(k)],end + end + + save(%U,ids_ref) + + for k=ids_ref + %wins_ref=ghdl2tree(scf(k));save(%U,%wins_ref); + end + + clf(w) + else + if get("figure_style")=="old" then return,end + ids_ref=xget("window"); + save(%U,ids_ref) + %wins_ref=ghdl2tree(gcf()); + save(%U,%wins_ref) + clf() + end + if or(winsid()==cur) then xset("window",cur),end + +endfunction + + + +function r=xbasc_run(w) + + //Author : Serge Steer, april 2005, Copyright INRIA + // + //Compare the graphic windows to be cleared with the reference givenin a Scilab binary file. + // This function must mirror the xbasc_build one. + + r=%f + if winsid()==[] then return,end + cur=xget("window") + // + if argn(2)==1 then + ids_=[] + for k=1:size(w,"*") + xset("window",w(k)) + if get("figure_style")=="new" then ids_=[ids_,w(k)],end + end + load(%U,"ids_ref") + if or(ids_ref<>ids_) then r=%t,return,end + for k=ids_ref + %wins_=ghdl2tree(scf(k)); + load(%U,"%wins_ref"); + if %CMP(%wins_, %wins_ref) then r=%t,return,end + end + clf(w) + else + if get("figure_style")=="old" then return,end + ids_=xget("window"); + load(%U,"ids_ref") + if or(ids_ref<>ids_) then r=%t,return,end + %wins_=ghdl2tree(gcf()); + load(%U,"%wins_ref"); + if %CMP(%wins_, %wins_ref) then r=%t,return,end + clf() + end + if or(winsid()==cur) then xset("window",cur),end + +endfunction + + + +function r=clf_build(w,opt) + + //Author : Serge Steer, april 2005, Copyright INRIA + // + //Save the graphic windows to be cleared in a Scilab binary file. + // This function must mirror the clf_run one. + + r=%f + if winsid()==[] then return,end + cur=xget("window") + rhs=argn(2) + if rhs==1&type(w)==10 then opt=w;rhs=0,end + if winsid()==[] then return,end + // + if rhs>=1 then + ids_ref=[] + if type(w)==9 then + H=w;w=[] + for h=H,w=[w,h.figure_id],end + end + for k=1:size(w,"*") + xset("window",w(k)) + if get("figure_style")=="new" then ids_ref=[ids_ref,w(k)],end + end + save(%U,ids_ref) + for k=ids_ref,%wins_ref=ghdl2tree(scf(k));save(%U,%wins_ref);end + if rhs==1 then clf(w),else clf(w,opt),end + else + if get("figure_style")=="old" then return,end + ids_ref=xget("window"); + save(%U,ids_ref) + %wins_ref=ghdl2tree(gcf()); + save(%U,%wins_ref) + clf() + end + if or(winsid()==cur) then xset("window",cur),end + +endfunction + + + +function r=clf_run(w,opt) + + //Author : Serge Steer, april 2005, Copyright INRIA + // + //Compare the graphic windows to be cleared with the reference givenin a Scilab binary file. + // This function must mirror the clf_build one. + + r=%f + if winsid()==[] then return,end + cur=xget("window") + rhs=argn(2) + if rhs==1&type(w)==10 then opt=w;rhs=0,end + if winsid()==[] then return,end + // + if rhs==1 then + ids_=[] + if type(w)==9 then + H=w;w=[] + for h=H,w=[w,h.figure_id],end + end + for k=1:size(w,"*") + xset("window",w(k)) + if get("figure_style")=="new" then ids_=[ids_,w(k)],end + end + load(%U,"ids_ref") + if or(ids_ref<>ids_) then r=%t,return,end + for k=ids_ref + %wins_=ghdl2tree(scf(k)); + load(%U,"%wins_ref"); + if %CMP(%wins_, %wins_ref) then r=%t,return,end + end + if rhs==1 then clf(w),else clf(w,opt),end + else + if get("figure_style")=="old" then return,end + ids_=xget("window") + load(%U,"ids_ref") + if or(ids_ref<>ids_) then r=%t,return,end + %wins_=ghdl2tree(gcf()); + load(%U,"%wins_ref"); + if %CMP(%wins_,%wins_ref) then r=%t,return,end + clf() + end + if or(winsid()==cur) then xset("window",cur),end + +endfunction + + + +function r=xdel_build(w) + + //Author : Serge Steer, april 2005, Copyright INRIA + // + //Save the graphic windows to be cleared in a Scilab binary file. + // This function must mirror the xdel_run one. + + r=%f + if winsid()==[] then return,end + cur=xget("window") + // + if argn(2)>=1 then + ids_ref=[] + for k=1:size(w,"*") + xset("window",w(k)) + if get("figure_style")=="new" then ids_ref=[ids_ref,w(k)],end + end + save(%U,ids_ref) + for k=ids_ref,%wins_ref=ghdl2tree(scf(k));save(%U,%wins_ref);end + xdel(w); + else + if get("figure_style")=="old" then return,end + ids_ref=xget("window"); + save(%U,ids_ref) + %wins_ref=ghdl2tree(gcf()); + save(%U,%wins_ref) + xdel() + end + if or(winsid()==cur) then xset("window",cur),end + +endfunction + + + +function r=xdel_run(w,opt) + + //Author : Serge Steer, april 2005, Copyright INRIA + // + //Compare the graphic windows to be cleared with the reference givenin a Scilab binary file. + // This function must mirror the xdel_build one. + + r=%f + if winsid()==[] then return,end + cur=xget("window") + // + if argn(2)==1 then + ids_=[] + for k=1:size(w,"*") + xset("window",w(k)) + if get("figure_style")=="new" then ids_=[ids_,w(k)],end + end + load(%U,"ids_ref") + if or(ids_ref<>ids_) then r=%t,return,end + for k=ids_ref + %wins_=ghdl2tree(scf(k)); + load(%U,"%wins_ref"); + if %CMP(%wins_, %wins_ref) then r=%t,return,end + end + xdel(w) + else + if get("figure_style")=="old" then return,end + ids_=xget("window") + load(%U,"ids_ref") + if or(ids_ref<>ids_) then r=%t,return,end + %wins_=ghdl2tree(gcf()); + load(%U,"%wins_ref"); + if %CMP(%wins_,%wins_ref) then r=%t,return,end + xdel() + end + if or(winsid()==cur) then xset("window",cur),end + +endfunction + + + +function save_ref(name) + + if exists(name)==0 then return,end + v=evstr(name) + if type(v) == 9 then v = ghdl2tree(v);end, + if type(v) == 128 then v = 128;end,// lu handle + execstr(name+"_ref=v;save(%U,"+name+"_ref"+")") + +endfunction + + + +function r=load_ref(name) + if exists(name)==0 then r=%f;return,end + v=evstr(name) + if type(v) == 9 then v = ghdl2tree(v);end, + execstr(name+"_ref=v;load(%U,"+name+"_ref"+");r=%CMP(v,"+name+"_ref);") +endfunction + + + +function reinit_for_test() + + //reinitialize some Scilab state to be able to reproduce the same tests + + sdf();sda() + xdel(winsid()) + grand("setgen","clcg4");grand("setall",11111111,22222222,33333333,44444444); + grand("setgen","kiss");grand("setsd",362436069,521288629,123456789,380116160); + grand("setgen","clcg2");grand("setsd",1234567890,123456789); + grand("setgen","urand");grand("setsd",0); + grand("setgen","fsultra");grand("setsd",1234567,7654321); + grand("setgen","mt");grand("setsd",5489); + rand("seed",0); + + clearglobal() + format("v",10) + +endfunction diff --git a/modules/helptools/macros/find_links.bin b/modules/helptools/macros/find_links.bin Binary files differnew file mode 100755 index 000000000..571d850df --- /dev/null +++ b/modules/helptools/macros/find_links.bin diff --git a/modules/helptools/macros/find_links.sci b/modules/helptools/macros/find_links.sci new file mode 100755 index 000000000..92cb838ee --- /dev/null +++ b/modules/helptools/macros/find_links.sci @@ -0,0 +1,248 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +// ============================================================================================= +// find_links +// +// Private function !!! +// ============================================================================================= + +function flag = find_links(filein,fileout) + + // - return %t if a LINK were found + // - Adapt the dtd link + // - Adapt the date + + [lhs,rhs]=argn(0); + + flag=%f; + + if rhs<>2 then error(39), end + + sep=filesep(); + + txt=mgetl(filein); + + //--------------------------------------------------------------------------------- + // Gestion de la DTD + //--------------------------------------------------------------------------------- + + dtd_line = grep(convstr(txt,"u"),"<!DOCTYPE MAN SYSTEM"); + + if getos() == "Windows" then + txt(dtd_line) = "<!DOCTYPE MAN SYSTEM ""file://"+SCI+"\modules\helptools\help.dtd"">"; + else + txt(dtd_line) = "<!DOCTYPE MAN SYSTEM """+SCI+"/modules/helptools/help.dtd"">"; + end + + //--------------------------------------------------------------------------------- + // Gestion de la date (<DATE>$LastChangedDate: 2006-07-27 10:51:33 +0200 (jeu, 27 jui 2006) $</DATE>) + //--------------------------------------------------------------------------------- + + date_line = grep(convstr(txt,"u"),"<DATE>"); + start_date = strindex(txt(date_line(1)),"$LastChangedDate"); + + if start_date <> [] then + start_date = start_date + 18; + end_date = start_date + 10; + txt(date_line) = " <DATE>"+part(txt(date_line),start_date:end_date)+"</DATE>"; + end + + //--------------------------------------------------------------------------------- + // Gestion des liens + //--------------------------------------------------------------------------------- + + d=grep(txt,"<LINK>"); + + if d==[] then mputl(txt,fileout); return; end + + for k=d + tt=txt(k); + l1=strindex(tt,"<LINK>"); + l2=strindex(tt,"</LINK>"); + nlink=size(l1,"*") + for i=1:nlink + name=part(tt,[l1(1)+6:l2(1)-1]) + path=get_absolute_file_path(filein); + if length(name)<>0 then + l=getlink(name,path,filein) + else + l="unknown"; + end + // jpc 17 sept 2003 + l=strsubst(l,"//","/") + tt=part(tt,[1:l1(1)-1])+"<A href="""+l+"""><VERB>"+name+"</VERB></A>"+part(tt,[l2(1)+7:length(tt)]) + l1=strindex(tt,"<LINK>") + l2=strindex(tt,"</LINK>") + end + txt(k)=tt + end + + mputl(txt,fileout); + flag = %t; + +endfunction + + +// ============================================================================================= +// getlink +// ============================================================================================= + +function t=getlink(name,absolute_path,path) + + global %helps; + global %helps_modules; + if %helps_modules == [] then + moduleslist = getmodules(); + for i = 1:size(moduleslist,"*") + add_module_help_chapter(moduleslist(i)); + end + end + %HELPS=[%helps_modules;%helps]; + + name=stripblanks(name) + + if getos() == "Windows" then + sep="\"; + else + sep="/"; + end + + man_found = []; + + //--------------------------------------------------------------------------------- + // On commmence par chercher dans le répertoire "name" ( cas le plus fréquent ). + //--------------------------------------------------------------------------------- + + if fileinfo(absolute_path+".list_htm") <> [] then + + whatis=mgetl(absolute_path+".list_htm"); + // 1er test ( avec le contenu de la balise title ) + f = grep(whatis,"- "+name+"==>"); + if f<>[] then + for k1=f + w = whatis(k1); + w = strsubst(w,"- "+name+"==>",""); + man_found = absolute_path + w; + end + else + // 2nd test ( avec le nom du fichier ) + f = grep(whatis,"==>"+name+".htm"); + if f<>[] then + for k1=f + w = whatis(k1); + w = strsubst(w,"- "+name+"==>",""); + man_found = absolute_path + name + ".htm"; + end + end + end + + end + + //--------------------------------------------------------------------------------- + // On recherche maintenant dans les répertoires désignés dans %helps + //--------------------------------------------------------------------------------- + + if man_found == [] then + + for k=1:size(%HELPS,1) + + current_help_path = %HELPS(k,1)+sep; + + if fileinfo(current_help_path+".list_htm") <> [] then + + whatis=mgetl(current_help_path+".list_htm"); + // 1er test ( avec le contenu de la balise title ) + f = grep(whatis,"- "+name+"==>"); + if f<>[] then + for k1=f + w = whatis(k1); + w = strsubst(w,"- "+name+"==>",""); + man_found = current_help_path + w; + end + else + // 2nd test ( avec le nom du fichier ) + f = grep(whatis,"==>"+name+".htm"); + if f<>[] then + for k1=f + w = whatis(k1); + w = strsubst(w,"- "+name+"==>",""); + man_found = current_help_path + name + ".htm"; + end + end + end + + if man_found<>[] then break; end + + else + + if fileinfo(%HELPS(k,1)+sep+"whatis.htm") <> [] then + whatis = mgetl(%HELPS(k,1)+sep+"whatis.htm"); + f = grep(whatis,name); + else + f = []; + end + + if f<>[] then + for k1=f + w=whatis(k1) + i=strindex(w,">"); j=strindex(w,"</A>") + if j<>[] then + lname=part(w,i(2)+1:j-1) + lnames=getwords(lname) + // transforms "toto titi tata" into ["toto" "titi" "tata"] + for ii=lnames + ok=%F + if ii==name then + i=strindex(w,"HREF="""); j=strindex(w,""">") + man_found=current_help_path+part(w,[i+6:j-1]) + end + if man_found<>[] then break; end + end + if man_found<>[] then break; end + end + end + end + + if man_found<>[] then break; end + + end // if fileinfo .... + + end // for k=1:size(%HELPS,1) + + end // if man_found == [] + + if man_found == [] then + write(%io(2),"Bad LINK """+name+""" in file "+path); + t=[]; + return; + end + + t=getrelativefilename(absolute_path,man_found); + t=strsubst(t,"\","/"); + +endfunction + +// ============================================================================================= +// getwords +// ============================================================================================= + +function vnames=getwords(names) + v=strindex(names," ") + if v==[] then + vnames=[names] + else + vnames=[]; i=1 + for j=v + vnames=[vnames,part(names,i:j-1)] + i=j+1 + end + vnames=[vnames,part(names,i:length(names))] + end +endfunction diff --git a/modules/helptools/macros/help.bin b/modules/helptools/macros/help.bin Binary files differnew file mode 100755 index 000000000..50ea6cd77 --- /dev/null +++ b/modules/helptools/macros/help.bin diff --git a/modules/helptools/macros/help.sci b/modules/helptools/macros/help.sci new file mode 100755 index 000000000..1caa35550 --- /dev/null +++ b/modules/helptools/macros/help.sci @@ -0,0 +1,59 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Vincent COUVERT +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function help(varargin) + + [lhs,rhs]=argn(0); + + if rhs >= 1 then + key = varargin(1); + else + key = ""; + end + + if (findfiles("SCI/modules/helptools/jar","*_help.jar") <> []) then + + if getscilabmode() <> "NWNI" then + + // No input argument: launch help browser + if argn(2)==0 then + global %helps + helpbrowser(%helps(:,1), getlanguage()); + return + end + + if type(key) <> 10 then + error(999,msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"),"help",1)); + end + + // Search a function name + key=stripblanks(key) + + if or(part(key,1)==["(",")","[","]","{","}","%","''","""",":","*","/","\",".","<",">","&","^","|","~","+","-"]) & exists(key)==0 then + key="symbols"; + end + + // Treat "$" apart because contrarily to the previous symbols, "$" is an existing variable in Scilab + if part(key,1)=="$" & (exists(key)==0 | length(key)==1) then + key="symbols"; + end + + global %helps + helpbrowser(%helps(:,1), key, getlanguage(), %f); + + // If the function name does not exists then full-text search is done (See Java code) + + else + error(msprintf(gettext("%s: The help browser is disabled in %s mode.\n"), "help", getscilabmode())); + end + else + error(msprintf(gettext("%s: help file(.jar) is not installed.\n"), "help")); + end + +endfunction diff --git a/modules/helptools/macros/help_from_sci.bin b/modules/helptools/macros/help_from_sci.bin Binary files differnew file mode 100755 index 000000000..7e7a4585b --- /dev/null +++ b/modules/helptools/macros/help_from_sci.bin diff --git a/modules/helptools/macros/help_from_sci.sci b/modules/helptools/macros/help_from_sci.sci new file mode 100755 index 000000000..7da96505c --- /dev/null +++ b/modules/helptools/macros/help_from_sci.sci @@ -0,0 +1,446 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008-2009 - T. Pettersen +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// Copyright (C) 2011 - DIGITEO - Michael Baudin +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +//============================================================================== + +function [helptxt,demotxt]=help_from_sci(funname,helpdir,demodir) + // Generate help files and demo files from the head comments section of a .sci source file. + // + // Calling Sequence + // help_from_sci() // generate an empty function template + // helptxt = help_from_sci() // generate an empty function template + // help_from_sci(funname,helpdir) // generate helpdir/funname.xml from funname.sci. + // help_from_sci(dirname,helpdir) // process dirname/*.sci and create helpdir/*.xml help files. + // help_from_sci(dirname,helpdir,demodir) // as above but also creating demodir/*.dem.sce demo files. + // [helptxt,demotxt]=help_from_sci(funname) // return funname.xml and funname.dem.sce code as two text matrixes. + // Parameters + // funname: the name of a single .sci source file to be processed. + // dirname: directory name where all .sci files will be processed. + // helpdir: optional path where the .xml help file will be created. + // demodir: optional path where .dem.sce demo files will be created based on code from the Examples section. + // helptxt: returns the XML help code if helpdir is empty, or the path to the .xml file. + // demotxt: returns the demo code if demodir is empty, or the path to the .dem.sce file. + // + // Description + // The help_from_sci function generates .xml help files based on the head comments section + // of .sci source files. Optionally .dem.sce demo files can be generated based on + // code from the Examples section in the head comments section of .sci files. + // + // In order for help_from_sci to format the .xml file properly the + // head comments section should comply with some simple formatting rules. + // + // The first comment line following the function definition should contain a short description + // of the function. + // + // The remaining comments are formatted according to the following (optional) headlines: + // "Calling Sequence", "Parameters", "Description", "Examples", "See also", "Used functions", + // "Authors" and "Bibliography". + // + // The following guidelines should be used when writing the source code comments: + // <itemizedlist> + // <listitem><para><literal>Calling Sequence</literal> - one example pr. line.</para></listitem> + // <listitem><para><literal>Parameters</literal> - separate parameter name and + // description by a ":". Keep the description of each parameter on the same line.</para></listitem> + // <listitem><para><literal>Description</literal> - formatting of the text can be done + // using XML commands. Compare the output of head_comments("help_from_sci") with help("help_from_sci") + // to get some hints. + // Adding an empty comment line in the Description section is interpreted as the + // start of a new paragraph.</para></listitem> + // <listitem><para><literal>See also</literal> - list one function name pr line.</para></listitem> + // <listitem><para><literal>Authors</literal> - write one author on each line following + // the Authors headline. Use ";" to separate the authors name + // from any add additional information.</para></listitem> + // <listitem><para><literal>Bibliography</literal> - write one reference pr line + // following the References headline.</para></listitem> + // </itemizedlist> + // + // Examples + // help_from_sci() // Open an empty source code template in the scinotes editor. + // // Save this template as test_fun.sci in the current directory before running + // // the next example commands. + // + // help_from_sci("test_fun") // return the xml skeleton as a text string + // + // help_from_sci("test_fun",".") // create the xml help file in the current directory. + // + // // create both a xml help file and a demo file in the current directory. + // help_from_sci("test_fun",".",".") + // + // // From a toolbox root directory a typical calling sequence would be: + // // help_from_sci("macros","help\en_US","demos") + // // This command would process all .sci files in the macros directory + // // and use the head comments section to update all .xml help files in the + // // help\en_US directory an rebuild the .dem.sce files in the demos\ directory. + // + // See also + // help + // help_skeleton + // head_comments + // + // Authors + // Copyright (C) 2008-2009 - T. Pettersen + // Copyright (C) 2010 - DIGITEO - Allan CORNET + // Copyright (C) 2011 - DIGITEO - Michael Baudin + + if argn(2) == 0 then + helptxt = [.. + "function [z] = function_template(x,y)" + "// Short description on the first line following the function header." + "//" + "// Calling Sequence" + "// [z] = template_function(x,y) // calling examples, one pr. line" + "//" + "// Parameters" + "// x: the x parameter // single line description of each parameter." + "// y: the y parameter // parameter name and description must be " + "// z: the z parameter // separated by "":""." + "//" + "// Description" + "// Here is a description of the function." + "// Add an empty comment line to format the text into separate paragraphs." + "//" + "// XML format commands may also be used directly in the text, " + "// as in the following examples." + "//" + "// This is an example of a itemized list:" + "// <itemizedlist>" + "// <listitem><para>An itemized list is shown here</para></listitem>" + "// </itemizedlist>" + "// The help text for help_from_sci was generated from the head comments section of help_from_sci.sci" + "// Compare the output from head_comments(""help_from_sci"") and help(""help_from_sci"")" + "// to see more examples on how to write the head comments section." + "//" + "// This is an example of the programlisting tag:" + "// <programlisting>z = test_fun(x, y)</programlisting>" + "//" + "// This is an example of a latex equation:" + "// <latex>" + "// \begin{eqnarray}" + "// m = |M| \beta^{1-p}," + "// \end{eqnarray}" + "// </latex>" + "//" + "// Examples" + "// [z] = test_fun(1, 2) // examples of use" + "//" + "// // An empty comment line in the Examples section will add a halt() statement" + "// // in the demo file test_fun.dem.sce generated by help_from_sci." + "//" + "// See also" + "// help_from_sci" + "// help_skeleton" + "//" + "// Authors" + "// Author name ; should be listed one pr line. Use "";"" to separate names from additional information " + "//" + "// Bibliography" + "// Literature references one pr. line" + "" + "// start of coding after on empty line to mark the end of the head_comments section" + "z = sin(x).*cos(x + y);" + "endfunction" + ]; + + mputl(helptxt, TMPDIR + filesep() + "function_template.sci"); + if (isdef("editor") | (funptr("editor") <> 0)) then + editor(TMPDIR + filesep() + "function_template.sci"); + end + [helptxt, demotxt] = help_from_sci("TMPDIR/function_template"); + return; + end + + if argn(2) < 3 then demodir = []; end + if argn(2) < 2 then helpdir = []; end + + if ~isempty(demodir) & ~isdir(demodir) then + error(sprintf(gettext("%s: Wrong value for input argument #%d: A valid existing directory is expected.\n"), "help_from_sci", 3)); + end + + if isdir(funname) then + printf(gettext("%s: Reading from directory %s\n"), "help_from_sci", funname); + files = findfiles(funname, "*.sci"); // read *.sci files. + for i = 1:size(files, "r") + [tmp, out] = fileparts(files(i)); + if isempty(helpdir) then + help_from_sci(funname + filesep() + files(i), ".", demodir); + printf(gettext("%s: Processing of file: %s to %s\n"), "help_from_sci", funname + "/" + out, out); + else + help_from_sci(funname + filesep() + files(i), helpdir, demodir); + printf(gettext("%s: Processing of file: %s to %s\n"), "help_from_sci", funname + "/" + out, helpdir + "/" + out); + end + if ~isempty(demodir) then + printf(gettext("%s: Processing of file: %s\n"), "help_from_sci" , demodir + "/" + out + ".dem.sce"); + else + printf("\n"); + end + end + printf(gettext("%s: processed %i files.\n"), "help_from_sci", i); + helptxt = ""; + return; + end + + out = tokens(pathconvert(funname), filesep()); + out = out($); + out = tokens(out,"."); + out = out(1); // remove .sci (...wont work for fil.name.sci) + + demotxt = ["mode(1)" + "//" + "// Demo of "+out+".sci" + "//" + ""]; + + verno = ver(); + verno = verno(1,2); + helptxt = [ + "<?xml version=""1.0"" encoding=""UTF-8""?>" + "" + "<!--" + " *" + " * This help file was generated from "+out+".sci using help_from_sci()." + " *" + " -->" + "" + "<refentry version=""5.0-subset Scilab"" xml:id="""+out+""" xml:lang=""en""" + " xmlns=""http://docbook.org/ns/docbook""" + " xmlns:xlink=""http://www.w3.org/1999/xlink""" + " xmlns:svg=""http://www.w3.org/2000/svg""" + " xmlns:ns3=""http://www.w3.org/1999/xhtml""" + " xmlns:mml=""http://www.w3.org/1998/Math/MathML""" + " xmlns:scilab=""http://www.scilab.org""" + " xmlns:db=""http://docbook.org/ns/docbook"">" + "" + ]; + + if isempty(strindex(funname, ".sci")) then funname = funname + ".sci"; end; + if isempty(fileinfo(funname)) then + error(sprintf(gettext("%s: The file %s does not exist.\n"),"help_from_sci",funname)); + end; + f = mopen(funname, "rt"); + if isempty(f) then + error(sprintf(gettext("%s: Cannot open file %s.\n"), "help_from_sci", funname + ".sci")); + end + line = " "; + doc = []; + + while isempty(strindex(line, "function ")) & ~meof(f), line = mgetl(f, 1); end + + line = mgetl(f,1); + line = replaceTabBySpace(line); + short_descr = stripblanks(strsubst(line, "//", ""), %T); + helptxt = [helptxt; + " <refnamediv>" + " <refname>"+out+"</refname>" + " <refpurpose>"+short_descr+"</refpurpose>" + " </refnamediv>" + ]; + + cmds = ["CALLING SEQUENCE", "PARAMETERS", "DESCRIPTION", "EXAMPLES", "SEE ALSO", .. + "AUTHORS", "BIBLIOGRAPHY", "USED FUNCTIONS"]; + + doing = "search"; + i = strindex(line, "//"); + line = mgetl(f, 1); + line = replaceTabBySpace(line); + // Continue until empty line or end of file or a scilab command line (Bug#5487) + while (~isempty(stripblanks(line)) & ~meof(f)) & ~isempty(regexp(stripblanks(line),"/^\/\/*/")) + if stripblanks(line) == "//" then + if doing == "Description" then + in = "new_descr_param"; + else + in = ""; + end + else + + in = strsplit(line, i(1) + 1); + in = stripblanks(in(2)); + code = in; // store original line for the demos. + if (doing ~= "Examples") then // Replacing characters like <, > or & should not be done in the Examples + in = strsubst(in, "&", "&"); // remove elements that make xml crash. + in = strsubst(in, "< ", "< "); + if strindex(in ,"<") then + if ~helpfromsci_isxmlstr(in) then + in = strsubst(in, "<", "<"); + end; + end + in = strsubst(in, " >", " >"); + if strindex(in, ">") then + if ~helpfromsci_isxmlstr(in) then + in = strsubst(in, ">", ">"); + end; + end + end + end + + IN = convstr(in, "u"); + if find(cmds == IN) then + [add_txt, doing] = change_activity(doing, in); + helptxt = [helptxt; add_txt]; + else + if doing == "Calling Sequence" then + helptxt = [helptxt;" " + in]; + elseif doing == "Parameters" then + i = strindex(in, ":"); + if ~isempty(i) then + if length(in) > i(1) then + in = strsplit(in,i(1)); + par_name = in(1); + par_descr = in(2); + else + par_name = in; + par_descr = " "; + end + helptxt = [helptxt; " <varlistentry><term>" + par_name + "</term>"]; + helptxt = [helptxt;" <listitem><para>" + par_descr + "</para></listitem></varlistentry>"]; + end + elseif doing == "Description" & in == "new_descr_param" then + helptxt = [helptxt;" </para>";" <para>"]; + elseif doing == "Description" then + helptxt = [helptxt; in]; + elseif doing == "Examples" & convstr(in, "u") ~= "EXAMPLES" then + if isempty(stripblanks(in)) then + demotxt = [demotxt; "halt() // Press return to continue"; " "]; + else + demotxt = [demotxt; code]; + end + helptxt = [helptxt; in]; + elseif doing == "See also" & convstr(in, "u") ~= "SEE ALSO" & ~isempty(stripblanks(in)) then + str = stripblanks(in); + i = strindex(str, " "); + if i <> [] then + str = stripblanks(strsplit(str, i(1))); + else + str = [str str]; + end + helptxt = [helptxt; " <member><link linkend=""" + str(1) + """>" + str(2) + "</link></member>"]; + elseif doing == "Authors" & convstr(in, "u") ~= "AUTHORS" & ~isempty(stripblanks(in)) then + [name, ref] = chop(in, ";"); + if isempty(ref) then + helptxt = [helptxt; " <member>" + name + "</member>"]; + else + helptxt = [helptxt; " <member>" + name + "</member><listitem><para>" + ref + "</para></listitem>"]; + end + elseif doing == "Bibliography" & convstr(in, "u") ~= "BIBLIOGRAPHY" & ~isempty(stripblanks(in)) then + helptxt = [helptxt;" <para>" + in + "</para>"]; + elseif doing == "Used functions" & convstr(in, "u") ~= "USED FUNCTIONS" & ~isempty(stripblanks(in)) then + helptxt = [helptxt;" <para>" + in + "</para>"]; + end + end + line = mgetl(f,1); + line = replaceTabBySpace(line); + i = strindex(line, "//"); + end + + helptxt = [helptxt; change_activity(doing, "FINISHED")]; + mclose(f); + + if ~isempty(helpdir) then + fnme = pathconvert(helpdir, %t, %f) + out + ".xml"; + answ = 1; + if isfile(fnme) then // file exists... + answ = messagebox(fnme + " exists!", "Warning - help_from_sci", "warning", ["Create anyway" "Skip file"], "modal"); + end + if answ == 1 then + mputl(helptxt, fnme); + helptxt = fnme; + else + printf(gettext("%s: File skipped %s."), "help_from_sci", out + ".xml"); + helptxt = ""; + end + end + + demotxt = [demotxt; "//========= E N D === O F === D E M O =========//"]; + if ~isempty(demodir) then + fnme = demodir + filesep() + out + ".dem.sce"; + answ = 1; + if isfile(fnme) then + answ = messagebox(fnme + " exists!", "Warning - help_from_sci", "warning", ["Create anyway" "Skip file"], "modal"); + end + if answ == 1 then + mputl(demotxt, fnme); + demotxt = fnme; + else + printf(gettext("%s: File skipped %s."), "help_from_sci", out + ".demo.sce"); + demotxt = ""; + end + end +endfunction +//============================================================================== +function tf = helpfromsci_isxmlstr(str) + // Returns %t if the current string is a xml line + if ( ~isempty(regexp(str, "/\<*[a-z]\>/")) ) then + tf=%t + elseif ( ~isempty(regexp(str, "/\<(.*)\/\>/")) ) then + tf=%t + else + tf=%f + end +endfunction +//============================================================================== +function [head, tail] = chop(str, tok) + i = regexp(str, "/" + tok + "/", "o"); + if isempty(i) then + head = str; + tail = []; + else + head = part(str, 1:i - 1); + tail = part(str, i + 1:length(str)); + end +endfunction +//============================================================================== +function strOut = replaceTabBySpace(strIn) + strOut = strsubst(strIn, ascii(9), part(" ",1:4)); +endfunction +//============================================================================== +function [txt, doing] = change_activity(currently_doing, start_doing) + doing = start_doing; + select convstr(currently_doing,"u") + case "CALLING SEQUENCE" then + txt = [" </synopsis>"; "</refsynopsisdiv>"]; + case "PARAMETERS" then + txt = [" </variablelist>"; "</refsection>"]; + case "DESCRIPTION" then + txt = ["</para>"; "</refsection>"]; + case "EXAMPLES" then + txt = [" ]]></programlisting>"; "</refsection>"]; + case "SEE ALSO" then + txt = [" </simplelist>"; "</refsection>"]; + case "AUTHORS" then + txt = [" </simplelist>"; "</refsection>"]; + case "BIBLIOGRAPHY" then + txt = ["</refsection>"]; + case "USED FUNCTIONS" then + txt = ["</refsection>"]; + else + txt = ""; + end + + select convstr(start_doing, "u"), + case "CALLING SEQUENCE" + txt = [txt; ""; "<refsynopsisdiv>"; " <title>Calling Sequence</title>"; " <synopsis>"]; + case "PARAMETERS" + txt = [txt; ""; "<refsection>"; " <title>Parameters</title>"; " <variablelist>"]; + case "DESCRIPTION" + txt = [txt; ""; "<refsection>"; " <title>Description</title>"; " <para>"]; + case "EXAMPLES" + txt = [txt; ""; "<refsection>"; " <title>Examples</title>"; " <programlisting role=""example""><![CDATA["]; + case "SEE ALSO" + txt = [txt; ""; "<refsection>"; " <title>See also</title>"; " <simplelist type=""inline"">"]; + case "AUTHORS" + txt = [txt; ""; "<refsection>"; " <title>Authors</title>"; " <simplelist type=""vert"">"]; + case "BIBLIOGRAPHY" + txt = [txt; ""; "<refsection>"; " <title>Bibliography</title>"]; + case "USED FUNCTIONS" + txt = [txt; ""; "<refsection>"; " <title>Used functions</title>"]; + case "FINISHED" + txt = [txt; "</refentry>"]; + end +endfunction +//============================================================================== diff --git a/modules/helptools/macros/help_skeleton.bin b/modules/helptools/macros/help_skeleton.bin Binary files differnew file mode 100755 index 000000000..88b0fb53c --- /dev/null +++ b/modules/helptools/macros/help_skeleton.bin diff --git a/modules/helptools/macros/help_skeleton.sci b/modules/helptools/macros/help_skeleton.sci new file mode 100755 index 000000000..056b82fa0 --- /dev/null +++ b/modules/helptools/macros/help_skeleton.sci @@ -0,0 +1,222 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function txt = help_skeleton(funname, path, language) + + [lhs,rhs] = argn(0); + + if rhs > 3 | rhs < 1 then + error(39); + end + + if type(funname) <> 10 then + error(999,msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"help_skeleton",1)); + end + + if size(funname, "*") <> 1 then + error(999,msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"),"help_skeleton",1)); + end + + if rhs > 1 then + if type(path) <> 10 then + error(55,2); + end + end + + previouslangage = getlanguage(); + + if rhs == 3 then + if type(language) <> 10 then + error(55,3); + end + setlanguage(language); + else + language = getlanguage(); + end + + txt = []; + vars = macrovar(evstr(funname)); + inputs = vars(1); + outputs = vars(2); + context = vars(3); + Call = ""; + + if size(outputs,"*") == 1 then + Call = outputs + " = " + elseif size(outputs,"*") > 1 then + Call = "["+strcat(outputs,",")+"] = "; + end + + Call = Call + funname; + + if size(inputs,"*") >= 1 then + Call = Call+"("+strcat(inputs,",")+")"; + end + + args = [inputs(:);outputs(:)]; + + // date management + // -------------------------------------------------------------------------------- + w = getdate(); + xml_date = msprintf("%02d-%02d-%04d",w(6),w(2),w(1)); + + //header + // -------------------------------------------------------------------------------- + xmlns = "xmlns=""http://docbook.org/ns/docbook""" + xlink = "xmlns:xlink=""http://www.w3.org/1999/xlink""" + svg = "xmlns:svg=""http://www.w3.org/2000/svg""" + mml = " xmlns:mml=""http://www.w3.org/1998/Math/MathML""" + db = "xmlns:db=""http://docbook.org/ns/docbook""" + scins = "xmlns:scilab=""http://www.scilab.org""" + + refs = strcat([xmlns xlink svg mml db scins]," ") + + txt=["<?xml version=""1.0"" encoding='"UTF-8""?>" + "<!--" + _(" * Add some comments about XML file"); + "-->" + "<refentry " + refs + " xml:lang="""+ language + """ xml:id=""" + funname + """>" + " <refnamediv>" + " <refname>"+ funname + "</refname>" + " <refpurpose>" + _("Add short description here.") + "</refpurpose>" + " </refnamediv>" + " <refsynopsisdiv>" + " <title>" + _("Calling Sequence") + "</title>" + " <synopsis>" + Call + "</synopsis>" + " </refsynopsisdiv>"]; + + //Arguments + if size(args,"*") >0 then + txt=[txt; + " <refsection>" + " <title>" + _("Arguments") + "</title>" + " <variablelist>"] + for a=args' + txt=[txt; + " <varlistentry>" + " <term>" + a + "</term>" + " <listitem>" + " <para>" + _(" Add here the input/output argument description.") + " </para>" + " </listitem>" + " </varlistentry>"] + end + txt=[txt; + " </variablelist>" + " </refsection>"]; + end + + //Description + txt=[txt; + " <refsection>" + " <title>" + _("Description") + "</title>" + " <para>" + _(" Add here a paragraph of the function description.") + _(" Other paragraph can be added") + " </para>" + " <para>With a latex expression" + " <latex>" + " \begin{eqnarray}" + " f(x,a,r) = \frac{1}{r^{-a}\Gamma(a)} \int_0^x t^{a-1} \exp\left(-rt\right) dt" + " \end{eqnarray}" + " </latex>" + " </para>" + " </refsection>"]; + + // More information + txt=[txt; + " <refsection>" + " <title>" + _("More information") + "</title>" + " <note><para>A note about foo</para></note>" + " <caution><para>A caution about foo</para></caution>" + " <warning><para>A warning about foo</para></warning>" + " <important><para>An important about foo</para></important>" + " <tip><para>A tip about foo</para></tip>" + " </refsection>"]; + + //Example + txt=[txt; + " <refsection>" + " <title>" + _("Examples") + "</title>" + " <programlisting role=""example""><![CDATA[" + _(" Add here scilab instructions and comments") + " ]]></programlisting>" + " <scilab:image><![CDATA[" + "// "+_(" Add here scilab instructions to generate a graphic") + " ]]></scilab:image>" + " </refsection>"]; + + //See Also + txt=[txt; + " <refsection>" + " <title>" + _("See Also") + "</title>" + " <simplelist type=""inline"">" + " <member>" + " <link linkend=""" + _("add a reference name") + """ >" + _("add a reference") + "</link>" + " </member>" + " <member>" + " <link linkend=""" + _("add a reference name") + """>" + _("add a reference") + "</link>" + " </member>" + " </simplelist>" + " </refsection>"]; + + //Authors + txt=[txt; + " <refsection>" + " <title>" + _("Authors") + "</title>" + " <simplelist type=""vert"">" + " <member>" + _("add the author name and author reference") + "</member>" + " <member>" + _("add another author name and his/her reference") + "</member>" + " </simplelist>" + " </refsection>"]; + + //Bibliography + txt = [txt; + " <refsection>" + " <title>" + _("Bibliography") + "</title>" + " <para>" + _(" Add here the function bibliography") + " </para>" + " </refsection>"]; + + // History + txt = [txt; + " <refsection>" + " <title>" + _("History") + "</title>" + " <revhistory>" + " <revision>" + " <revnumber>X.Y</revnumber>" + " <revdescription>Function foo added</revdescription>" + " </revision>" + " </revhistory>" + " </refsection>"]; + + //Used functions + txt=[txt; + " <refsection>" + " <title>" + _("Used Functions") + "</title>" + " <para>" + _(" Add here the Scilab, C,... used code references") + " </para>" + " </refsection>"]; + + //footer + txt=[txt; + "</refentry>"]; + + setlanguage(previouslangage); + + if rhs >= 2 then + mputl(txt, pathconvert(path,%t,%f) + funname + ".xml"); + txt = pathconvert(path,%t,%f) + funname + ".xml"; + end + +endfunction diff --git a/modules/helptools/macros/lib b/modules/helptools/macros/lib Binary files differnew file mode 100755 index 000000000..6d2d9824a --- /dev/null +++ b/modules/helptools/macros/lib diff --git a/modules/helptools/macros/manedit.bin b/modules/helptools/macros/manedit.bin Binary files differnew file mode 100755 index 000000000..0901b5eb9 --- /dev/null +++ b/modules/helptools/macros/manedit.bin diff --git a/modules/helptools/macros/manedit.sci b/modules/helptools/macros/manedit.sci new file mode 100755 index 000000000..d2ca5078b --- /dev/null +++ b/modules/helptools/macros/manedit.sci @@ -0,0 +1,64 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function manedit(manitem) + + lhs=argn(1); + rhs=argn(2); + + if rhs<>1 then + error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"manedit",1)); + end + + // manitem : character string giving a manitem + + path=get_item_xml_path(manitem); + + if path==[] then + ierr=execstr("t=type("+manitem+")","errcatch") + if ierr==0&t==13 then + path = pathconvert(TMPDIR+"/"+manitem+".xml",%F,%F); + help_skeleton(manitem,TMPDIR); + else + path=[] + end + end + + if path <> [] then + if (isdef("editor") | (funptr("editor")<>0)) then + editor(path); + end + end + +endfunction + + + +function path = get_item_xml_path(manitem) + + path = []; + + global %helps + global %helps_modules; + if %helps_modules == [] then + moduleslist = getmodules(); + for i = 1:size(moduleslist,"*") + add_module_help_chapter(moduleslist(i)); + end + end + %HELPS=[%helps_modules;%helps]; + + for k=1:size(%HELPS(:,1),"*") + if isfile(pathconvert(%HELPS(k,1)+"/"+manitem+".xml",%f,%f)) then + path = pathconvert(%HELPS(k,1)+"/"+manitem+".xml",%f,%f); + return; + end + end + +endfunction diff --git a/modules/helptools/macros/names b/modules/helptools/macros/names new file mode 100755 index 000000000..1953d0e4e --- /dev/null +++ b/modules/helptools/macros/names @@ -0,0 +1,18 @@ +add_help_chapter +add_module_help_chapter +apropos +clean_help +del_help_chapter +del_module_help_chapter +extract_help_examples +find_links +help +help_from_sci +help_skeleton +manedit +xmltoformat +xmltohtml +xmltojar +xmltopdf +xmltops +xmltoweb diff --git a/modules/helptools/macros/xmltoformat.bin b/modules/helptools/macros/xmltoformat.bin Binary files differnew file mode 100755 index 000000000..1019236ee --- /dev/null +++ b/modules/helptools/macros/xmltoformat.bin diff --git a/modules/helptools/macros/xmltoformat.sci b/modules/helptools/macros/xmltoformat.sci new file mode 100755 index 000000000..832f969de --- /dev/null +++ b/modules/helptools/macros/xmltoformat.sci @@ -0,0 +1,1865 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> +// Copyright (C) 2008-2010 DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org> +// Copyright (C) 2009 DIGITEO - Vincent COUVERT <vincent.couvert@scilab.org> +// Copyright (C) 2010 - 2011 DIGITEO - Allan CORNET +// Copyright (C) 2013 - Scilab Enterprises - Clement DAVID +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function generated_files = xmltoformat(output_format,dirs,titles,directory_language,default_language) + + // ========================================================================= + // + output_format : "javaHelp", "pdf", "chm", "ps" + // + // + dirs : A set of directories for which help files (jar, pdf, chm, ...) are + // genereated + // + // + titles : associated title strings (optional or []) + // + // + directory_language : language in which the help is written + // + // + default_language : The directory we compiling is completed with help files + // from the default_language + // + // if dirs is not specified or [] then standard scilab man are assumed and + // titles are searched in %helps + // ========================================================================= + + my_wanted_language = getlanguage(); // This variable is only need when + // build all scilab help + + global %helps; + global %helps_modules; + + if %helps_modules == [] then + x2f_reset_help_mod_var(my_wanted_language); + end + + %HELPS = [%helps_modules; %helps]; + + SCI_long = pathconvert(getlongpathname(SCI),%F,%F); + + //-------------------------------------------------------------------------- + // Save the current environment + //-------------------------------------------------------------------------- + + current_directory = pwd(); + saved_helps = %HELPS; + %helps_save = %helps; + %helps_modules_save = %helps_modules; + + generated_files = []; + + all_scilab_help = %F; + + [lhs,rhs] = argn(0); + + // Too much parameters + // --------------------------------------------------------------------- + + if rhs > 5 | rhs < 1 then + error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"),"xmltoformat",1,5)); + end + + // Transformation of %helps_modules jar => help/language + + // Default case : building of the online help of Scilab + // --------------------------------------------------------------------- + + if ( (rhs <= 1) .. + | ((rhs == 2) & (dirs == [])) .. + | ((rhs == 3) & (dirs == []) & (titles == [])) .. + | ((rhs == 4) & (dirs == []) & (titles == [])) ) then + + all_scilab_help = %T; + + // "directory_language" input argument is defined ! + if rhs == 4 then + my_wanted_language = directory_language; + x2f_reset_help_mod_var(my_wanted_language); + %HELPS = [%helps_modules; %helps]; + end + + dirs_to_build = %HELPS; + dirs_to_build_m = %helps_modules; + dirs_to_build_c = %helps; + + dirs = x2f_get_xml_path(dirs_to_build(:,1),my_wanted_language); + dirs_m = x2f_get_xml_path(dirs_to_build_m(:,1),my_wanted_language); + dirs_c = x2f_get_xml_path(dirs_to_build_c(:,1),my_wanted_language); + + titles = dirs_to_build(:,2); + titles_m = dirs_to_build_m(:,2); + titles_c = dirs_to_build_c(:,2); + + dirs( find(dirs == "")) = []; + dirs_m( find(dirs_m == "")) = []; + dirs_c( find(dirs_c == "")) = []; + titles( find(dirs == "")) = []; + titles_m( find(dirs_m == "")) = []; + titles_c( find(dirs_c == "")) = []; + + directory_language = []; + directory_language_m = []; + directory_language_c = []; + + default_language = []; + default_language_m = []; + default_language_c = []; + + language_system = []; // language_system is equal to %T when + language_system_m = []; // a help directory needs to be completed + language_system_c = []; // with the default language + + if my_wanted_language == getdefaultlanguage() then + for k=1:size(dirs,"*") + directory_language = [directory_language;my_wanted_language]; + language_system = [language_system;%F]; + end + for k=1:size(dirs_m,"*") + directory_language_m = [directory_language_m;my_wanted_language]; + language_system_m = [language_system_m;%F]; + end + for k=1:size(dirs_c,"*") + directory_language_c = [directory_language_c;my_wanted_language]; + language_system_c = [language_system_c;%F]; + end + else + for k=1:size(dirs,"*") + directory_language = [directory_language;my_wanted_language]; + default_language = [default_language;getdefaultlanguage()]; + language_system = [language_system;%T]; // Enable the language system + end + for k=1:size(dirs_m,"*") + directory_language_m = [directory_language_m;my_wanted_language]; + default_language_m = [default_language_m;getdefaultlanguage()]; + language_system_m = [language_system_m;%T]; // Enable the language system + end + for k=1:size(dirs_c,"*") + directory_language_c = [directory_language_c;my_wanted_language]; + default_language_c = [default_language_c;getdefaultlanguage()]; + language_system_c = [language_system_c;%T]; // Enable the language system + end + end + + // Only directories are precised + // --------------------------------------------------------------------- + + elseif (rhs == 2) & (dirs <> []) then + + language_system = []; + titles = []; + directory_language = []; + default_language = []; + + for k=1:size(dirs,"*") + directory_language = [directory_language ; x2f_guess_lang(dirs(k)) ]; // Language detection + default_language = [default_language ; getdefaultlanguage()]; // Default Language + titles = [titles;gettext("Help chapter")+" "+string(k)]; + + if directory_language(k) == default_language(k) then + language_system = [language_system;%F]; // Enable the language system + else + language_system = [language_system;%T]; // Enable the language system + end + end + + // Only directories and title are precised + // --------------------------------------------------------------------- + + elseif rhs == 3 then + + language_system = []; + directory_language = []; + default_language = []; + + for k=1:size(dirs,"*") + directory_language = [directory_language ; x2f_guess_lang(dirs(k)) ]; // Language detection + default_language = [default_language ; getdefaultlanguage()]; // Default Language + + if directory_language(k) == default_language(k) then + language_system = [language_system;%F]; // Enable the language system + else + language_system = [language_system;%T]; // Enable the language system + end + end + + // Directories, title and languages are specified + // --------------------------------------------------------------------- + + elseif rhs == 4 then + + language_system = []; + default_language = []; + + for k=1:size(dirs,"*") + default_language = [default_language ; getdefaultlanguage()]; // Default Language + + if directory_language(k) == default_language(k) then + language_system = [language_system;%F]; // Enable the language system + else + language_system = [language_system;%T]; // Enable the language system + end + end + + // All is specified + // --------------------------------------------------------------------- + + elseif rhs == 5 then + + language_system = []; + + for k=1:size(dirs,"*") + if isdir(pathconvert(dirs(k)+"/../"+default_language(k),%f,%f)) then + if directory_language(k) == default_language(k) then + language_system = [language_system;%F]; // Enable the language system + else + language_system = [language_system;%T]; // Enable the language system + end + end + end + + end + + // Convert paths into absolute paths + // --------------------------------------------------------------------- + function dir_modified = checkAndConvertDir(dirs_path) + dir_modified = []; + if (dirs_path <> []) then + if ~and(isdir(dirs_path)) then + notDirIdx = find(isdir(dirs_path) == %F); + error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat", dirs_path(notDirIdx(1)))); + end + dir_modified = fullpath(dirs_path); + end + endfunction + + dirs = checkAndConvertDir(dirs); + + if all_scilab_help then + dirs_m = checkAndConvertDir(dirs_m); + dirs_c = checkAndConvertDir(dirs_c); + end + + // ========================================================================= + // Build the trees + // ========================================================================= + + if all_scilab_help then + + // ast_tree : "Modules" Tree + curLang = getlanguage(); + setlanguage(directory_language_m(1)); + scilab_manual = _("Scilab Help"); + setlanguage(curLang); + + modules_tree = struct(); + modules_tree("level") = 0; // It's a book + modules_tree("title") = scilab_manual; + modules_tree("book_title") = scilab_manual; + modules_tree("language") = directory_language_m(1); + modules_tree("path") = SCI; + modules_tree("master.xml") = %F; + modules_tree("xml_number") = 0; + modules_tree("xml_list") = []; + + // + // Scilab Modules + // + + for k=1:size(dirs_m,"*") + + this_tree = x2f_dir_to_tree(dirs_m(k),1); + this_tree("title_addchapter") = titles_m(k); + this_tree("language") = directory_language_m(k); + + if language_system_m(k) then + default_language_path = pathconvert(part(dirs_m(k),1:length(dirs_m(k))-5)+default_language_m(k)); + if isdir(default_language_path) then + this_tree_dl = x2f_dir_to_tree(default_language_path,1); + this_tree = x2f_merge_trees(this_tree_dl,this_tree); + end + end + + modules_tree("dir_"+getmd5(dirs_m(k),"string")) = this_tree; + + end + + // + // Scilab Toolboxes + // + + contrib_tree = struct(); + + for k=1:size(dirs_c,"*") + + this_tree = x2f_dir_to_tree(dirs_c(k),0); + this_tree("title_addchapter") = titles_c(k); + this_tree("language") = directory_language_c(k); + + if language_system_c(k) then + default_language_path = pathconvert(part(dirs_c(k),1:length(dirs_c(k))-5)+default_language_c(k)); + if isdir(default_language_path) then + this_tree_dl = x2f_dir_to_tree(default_language_path,0); + this_tree = x2f_merge_trees(this_tree_dl,this_tree); + end + end + + contrib_tree(dirs_c(k)) = this_tree; + end + else + + // + // Scilab Toolboxes + // + + contrib_tree = struct(); + + for k=1:size(dirs,"*") + + this_tree = x2f_dir_to_tree(dirs(k),0); + this_tree("title_addchapter") = titles(k); + this_tree("language") = directory_language(k); + + if language_system(k) then + default_language_path = pathconvert(part(dirs(k),1:length(dirs(k))-5)+default_language(k)); + if isdir(default_language_path) then + this_tree_dl = x2f_dir_to_tree(default_language_path,0); + this_tree = x2f_merge_trees(this_tree_dl,this_tree); + end + end + + contrib_tree(dirs(k)) = this_tree; + end + + end + + // ========================================================================= + // Build the master documents + // ========================================================================= + + if all_scilab_help then + + // + // Scilab Modules + // + + mprintf(_("\nBuilding the Scilab manual master document for %s.\n"),my_wanted_language); + + master_doc = pathconvert(SCI+"/modules/helptools/master_"+my_wanted_language+"_help.xml",%F); + modules_tree("master_document") = master_doc; + master_str = x2f_tree_to_master(modules_tree); + mputl(master_str,master_doc); + + // + // Scilab Toolboxes + // + + nb_dir = size(dirs_c,"*"); + displaydone = 0; + + for k=1:nb_dir + + if nb_dir > 1 then + if displaydone == 0 then + mprintf(_("\nBuilding master documents:\n")); + displaydone = 1; + end + else + mprintf(_("\nBuilding the master document:\n")); + end + + mprintf(_("\t%s\n"),strsubst(dirs_c(k),SCI_long,"SCI")); + + this_tree = contrib_tree(dirs_c(k)); + master_doc = pathconvert(dirs_c(k)+"/master_help.xml",%F); + this_tree("master_document") = master_doc; + master_str = x2f_tree_to_master(this_tree); + mputl(master_str,master_doc); + contrib_tree(dirs_c(k)) = this_tree; + + end + + else + + nb_dir = size(dirs,"*"); + displaydone = 0; + + for k=1:nb_dir + + if nb_dir > 1 then + if displaydone == 0 then + mprintf(_("\nBuilding master documents:\n")); + displaydone = 1; + end + else + mprintf(_("\nBuilding the master document:\n")); + end + + mprintf(_("\t%s\n"),strsubst(dirs(k),SCI_long,"SCI")); + + this_tree = contrib_tree(dirs(k)); + + if isfield(this_tree,"master.xml") & this_tree("master.xml") then + this_tree("master_document") = pathconvert(dirs(k)+"/master.xml",%F); + contrib_tree(dirs(k)) = this_tree; + continue; + end + + master_doc = pathconvert(dirs(k)+"/master_help.xml",%F); + this_tree("master_document") = master_doc; + master_str = x2f_tree_to_master(this_tree); + mputl(master_str,master_doc); + contrib_tree(dirs(k)) = this_tree; + + end + + end + + // ========================================================================= + // Perform the help generation + // scilab help files generation + // 2 steps : + // -- scilab help + // -- scilab internal toolbox + // ========================================================================= + + // target format modification : + // * update the format extension (eg. the created dir) + // * handle the second pass build (container management or second transform) + select output_format + case "javaHelp" then + formatDescriptor = output_format; + output_format_ext = "jar"; + second_pass_format = "jar-only"; + case "web" + formatDescriptor = output_format; + output_format_ext = "html"; + second_pass_format = []; + case "ps" + formatDescriptor = output_format; + output_format_ext = output_format; + output_format = "fo"; // ps file is generated on a second pass from fo files + second_pass_format = "ps"; + case "pdf" + formatDescriptor = output_format; + output_format_ext = output_format; + output_format = "fo"; // pdf file is generated on a second pass from fo files + second_pass_format = "pdf"; + else + formatDescriptor = output_format; + output_format_ext = output_format; + second_pass_format = []; + end + + is_html = (output_format == "html" | output_format == "web"); + is_chm = (output_format == "chm"); + + if all_scilab_help then + + mprintf(_("Building the scilab manual file [%s]\n"), formatDescriptor); + + // Define and create the final output directory if does not exist + if output_format == "web" then + final_output_dir = pathconvert(SCI+"/modules/helptools/web",%f,%f); + else + // Define and create the final output directory if does not exist + final_output_dir = pathconvert(SCI+"/modules/helptools/"+output_format_ext,%f,%f); + end + + if ~isdir(final_output_dir) then + mkdir(final_output_dir); + end + + if is_chm then + + elseif is_html then + final_output_dir = pathconvert(final_output_dir+"/"+my_wanted_language,%f,%f); + if ~isdir(final_output_dir) then + mkdir(final_output_dir); + end + end + + // Define and create the path of buildDoc working directory + buildDoc_dir = pathconvert(SCI+"/modules/helptools/"+ output_format + "/scilab_" + my_wanted_language + "_help",%t,%f); + + if ~isdir(pathconvert(SCI+"/modules/helptools/"+output_format,%f,%f)) then + mkdir(pathconvert(SCI+"/modules/helptools/"+output_format,%f,%f)); + end + + if ~isdir(buildDoc_dir) then + mkdir(buildDoc_dir); + end + + // Define the final location of the generated file + if is_chm then + final_help_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f); + elseif is_html then + final_help_file = pathconvert(final_output_dir+"/index.html",%f,%f); + else + final_help_file = pathconvert(final_output_dir+"/scilab_" + my_wanted_language + "_help." + output_format_ext,%f,%f); + end + + // Define the path of the generated file created by buildDoc + if is_chm then + buildDoc_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f); + elseif is_html then + buildDoc_file = pathconvert(buildDoc_dir + "index.html",%f,%f); + else + buildDoc_file = pathconvert(buildDoc_dir + "scilab_" + my_wanted_language + "_help." + output_format_ext,%f,%f); + end + + // Save the current directory + cur_dir = pwd(); + + // Change Scilab current directory so that Java Indexer works + if ~chdir(buildDoc_dir) then + error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",buildDoc_dir)); + end + + // process the build + fileToExec = buildDoc(output_format,modules_tree("master_document"), my_wanted_language); + if fileToExec ~= [] then + exec(fileToExec, -1); + end + if ~isempty(second_pass_format) then + buildDoc(second_pass_format,modules_tree("master_document"), my_wanted_language); + end + + check_move(buildDoc_file); + + // Now we can add the help file to the list of all generated files + generated_files = [ generated_files ; final_help_file ]; + + // internal toolbox + // example: scicos + // Now, build toolboxes help (if any) + + for k=1:size(dirs_c,"*"); + + this_tree = contrib_tree(dirs_c(k)); + + mprintf(_("\nBuilding the manual file [%s] in %s.\n"),formatDescriptor,strsubst(dirs_c(k),SCI_long,"SCI")); + + // Define and create the final output directory if does not exist + final_output_dir = pathconvert(dirs_c(k)+"/../../"+output_format_ext,%f,%f); + + if ~isdir(final_output_dir) then + mkdir(final_output_dir); + end + + // To improve the final_output_dir path + final_output_dir = pathconvert(fullpath(final_output_dir),%f,%f); + + if is_chm then + final_output_dir = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f); + elseif is_html then + final_output_dir = pathconvert(final_output_dir+"/"+directory_language_c(k),%f,%f); + if ~isdir(final_output_dir) then + mkdir(final_output_dir); + end + end + + // Define and create the path of buildDoc working directory + buildDoc_dir = pathconvert(dirs_c(k) + "/scilab_" + directory_language_c(k) + "_help",%t,%f); + if ~isdir(buildDoc_dir) then + mkdir(buildDoc_dir); + end + + // Define the final location of the generated file + if is_chm then + final_help_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f); + elseif is_html then + final_help_file = pathconvert(final_output_dir+"/index.html",%f,%f); + else + final_help_file = pathconvert(final_output_dir+"/scilab_" + directory_language_c(k) + "_help." + output_format_ext,%f,%f); + end + + + // Define the path of the generated file created by buildDoc + if is_chm then + buildDoc_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f); + elseif is_html then + buildDoc_file = pathconvert(buildDoc_dir + "index.html",%f,%f); + else + buildDoc_file = pathconvert(buildDoc_dir + "scilab_" + directory_language_c(k) + "_help." + output_format_ext,%f,%f); + end + + // Save the current directory + cur_dir = pwd(); + + // Change Scilab current directory so that Java Indexer works + if ~chdir(buildDoc_dir) then + chdir(cur_dir); + error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",buildDoc_dir)); + end + + // process the build + fileToExec = buildDoc(output_format,this_tree("master_document"),directory_language_c(k),dirs_c(k)); + if fileToExec ~= [] then + exec(fileToExec, -1); + end + if ~isempty(second_pass_format) then + buildDoc(second_pass_format,this_tree("master_document"),directory_language_c(k),dirs_c(k)); + end + + check_move(buildDoc_file); + + // Now we can add the help file to the list of all generated files + generated_files = [ generated_files ; final_help_file ]; + + end + + else + // ------------------------------ + // external (Toolboxes) + // ------------------------------ + + + // Dirs are precised in the input arguments + + nb_dir = size(dirs,"*"); + displaydone = 0; + + for k=1:nb_dir + + // Save the current directory + cur_dir = pwd(); + + this_tree = contrib_tree(dirs(k)); + + if nb_dir > 1 then + if displaydone == 0 then + mprintf(_("\nBuilding the manual file [%s].\n"),formatDescriptor); + displaydone = 1; + end + mprintf(_("\t%s\n"),strsubst(dirs(k),SCI_long,"SCI")); + else + mprintf(_("\nBuilding the manual file [%s] in %s.\n"),formatDescriptor,strsubst(dirs(k),SCI_long,"SCI")); + end + + // Define and create the final output directory if does not exist + final_output_dir = pathconvert(dirs(k)+"/../../"+output_format_ext,%f,%f); + + if ~isdir(final_output_dir) then + mkdir(final_output_dir); + end + + // To improve the final_output_dir path + + if ~chdir(final_output_dir) then + error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",final_output_dir)); + end + + final_output_dir = pathconvert(pwd(),%f,%f); + + if is_chm then + // nothing to do + else + if is_html then + final_output_dir = pathconvert(final_output_dir+"/"+directory_language(k),%f,%f); + if ~isdir(final_output_dir) then + mkdir(final_output_dir); + end + end + end + + // Define and create the path of buildDoc working directory + buildDoc_dir = pathconvert(dirs(k) + "/scilab_" + directory_language(k) + "_help",%t,%f); + if ~isdir(buildDoc_dir) then + mkdir(buildDoc_dir); + end + + // Define the final location of the generated file + if is_chm then + final_help_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f); + else + if is_html then + final_help_file = pathconvert(final_output_dir+"/index.html",%f,%f); + else + final_help_file = pathconvert(final_output_dir+"/scilab_" + directory_language(k) + "_help." + output_format_ext,%f,%f); + end + end + + // Define the path of the generated file created by buildDoc + if is_chm then + buildDoc_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f); + elseif is_html then + buildDoc_file = pathconvert(buildDoc_dir + "index.html",%f,%f); + else + buildDoc_file = pathconvert(buildDoc_dir + "scilab_" + directory_language(k) + "_help." + output_format_ext,%f,%f); + end + + // Change Scilab current directory so that Java Indexer works + if ~chdir(buildDoc_dir) then + error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",buildDoc_dir)); + end + + // process the build + fileToExec = buildDoc(output_format,this_tree("master_document"),directory_language(k),dirs(k)); + if fileToExec ~= [] then + exec(fileToExec, -1); + end + if ~isempty(second_pass_format) then + buildDoc(second_pass_format,this_tree("master_document"),directory_language(k),dirs(k)); + end + + check_move(buildDoc_file); + + // Now we can add the help file to the list of all generated files + generated_files = [ generated_files ; final_help_file ]; + + end + end + + // Restore the original environment + //-------------------------------------------------------------------------- + + chdir(current_directory); + %helps = %helps_save; + %helps_modules = %helps_modules_save; + %HELPS = saved_helps; + +endfunction + +// ============================================================================= +// check and move the generated files +// ============================================================================= +function check_move(buildDoc_file) + + // Check if the help file has been generated + if ~isfile(buildDoc_file) then + chdir(cur_dir); + error(msprintf(gettext("%s: %s has not been generated."),"xmltoformat",buildDoc_file)); + end + + // move the generated file(s) + if is_chm then + + elseif is_html then + my_html_files = listfiles(buildDoc_dir); + for k=1:size(my_html_files,"*") + if ~copyfile(my_html_files(k),pathconvert(final_output_dir+"/"+my_html_files(k),%f,%f)) then + chdir(cur_dir); + error(msprintf(gettext("%s: %s file hasn''t been moved in the %s directory."),"xmltoformat",my_html_files(k),final_output_dir)); + end + mdelete(my_html_files(k)); + end + else + copyfile(buildDoc_file,final_help_file); + mdelete(buildDoc_file); + end + + // Move into the initial directory + if ~chdir(cur_dir) then + error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",cur_dir)); + end + +endfunction + +// ============================================================================= +// dirs_out = x2f_get_xml_path(dirs_in,my_wanted_language) +// ============================================================================= + +function dirs_out = x2f_get_xml_path(dirs_in,my_wanted_language) + + dirs_out = []; + + for k=1:size(dirs_in,"*") + + if basename(dirs_in(k)) == "jar" then + + help_basepath = part(dirs_in(k),1:length(dirs_in(k))-4) + filesep() + "help"; + + if isdir(help_basepath + filesep() +my_wanted_language) then + dirs_out(k) = help_basepath + filesep() + my_wanted_language; + elseif isdir(help_basepath+filesep()+getdefaultlanguage()) then + dirs_out(k) = help_basepath+filesep()+getdefaultlanguage(); + else + dirs_out(k) = ""; + end + + else + dirs_out(k) = dirs_in(k); + end + + end + +endfunction + +// ============================================================================= +// language_out = x2f_guess_lang(dir_in) +// ============================================================================= + +function language_out = x2f_guess_lang(dir_in) + + language_out = getlanguage(); + + [my_start,my_end,my_match] = regexp(basename(dir_in),"/([a-z][a-z]_[A-Z][A-Z])$/"); + + if my_start <> [] then + language_out = part(my_match,1:5); + end + +endfunction + +// ============================================================================= +// x2f_reset_help_mod_var(language) +// ============================================================================= + +function x2f_reset_help_mod_var(language) + + global %helps_modules; + + // Reset the variable in hand + %helps_modules = []; + + modules_ordered_list = mgetl(SCI + "/modules/helptools/etc/MAIN_CHAPTERS"); + // remove empty lines in MAIN_CHAPTERS + modules_ordered_list(modules_ordered_list == "") = []; + + // get current modules used by scilab + current_modules_list = getmodules(); + + size_current_modules = size(current_modules_list, "*"); + size_modules_ordered = size(modules_ordered_list, "*"); + + if size_current_modules > size_modules_ordered then + error(msprintf(gettext("%s: Please check %s, number of modules is invalid.\n"), "xmltoformat", SCI + "/modules/helptools/etc/MAIN_CHAPTERS")); + end + + // Remove modules not present + k = 1; + cleaned_ordered_modules = []; + for i = 1:size_modules_ordered + for j = 1:size_current_modules + if (current_modules_list(j) == modules_ordered_list(i)) then + cleaned_ordered_modules(k) = modules_ordered_list(i); + k = k + 1; + end + end + end + + // We force to add windows_tools module in help + // Bug 9790 + if getos() <> "Windows" then + cleaned_ordered_modules(k) = "windows_tools"; + end + + size_cleaned_modules = size(cleaned_ordered_modules, "*"); + + // Loop on modules available ordered + for k = 1:size_cleaned_modules; + addchapter_path = SCI + "/modules/" + cleaned_ordered_modules(k) + "/help/" + language + "/addchapter.sce"; + if isfile(addchapter_path) then + exec(addchapter_path, -1); + end + end + +endfunction + +// ============================================================================= +// tree = x2f_dir_to_tree(directory,level) +// +// level : +// 0 : book +// 1 : part +// 2 : chapter +// 3 : sect1 +// 4 : sect2 +// 5 : sect3 +// 6 : sect4 +// ... +// +// Date : 24/04/2009 +// ============================================================================= + +function tree = x2f_dir_to_tree(directory,level) + + tree = struct(); + rhs = argn(2); + + // Check number of input arguments + // ========================================================================= + + if rhs<>2 then + error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_dir_to_tree",2)); + end + + // Check input argument type + // ========================================================================= + + if type(directory) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"x2f_dir_to_tree",1)); + end + + if type(level) <> 1 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: An integer expected.\n"),"x2f_dir_to_tree",2)); + end + + // Check input argument dimension + // ========================================================================= + + if size(directory,"*") <> 1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"x2f_dir_to_tree",1)); + end + + if size(level,"*") <> 1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: An integer expected.\n"),"x2f_dir_to_tree",1)); + end + + // Check the directory existence + // ========================================================================= + + if ~isdir(directory) then + error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid existing directory is expected.\n"),"x2f_dir_to_tree",1)); + end + + // ... and now, Action + // ========================================================================= + + // Normalize the directory path + directory = pathconvert(directory); + + + // init the structure + tree = struct(); + tree("path") = directory; + tree("level") = level; + + // If a master.xml file exists, don't go past + if isfile(directory+"master.xml") then + tree("master.xml") = %T; + return; + else + tree("master.xml") = %F; + end + + // + // Title management + // + + // Parse the CHAPTER file to get the directory title if this file is present + if isfile(directory+"CHAPTER") then + tree = x2f_cat(tree,x2f_read_CHAPTER(directory+"CHAPTER")); + end + + // Check if the addchapter.sce is present + if isfile(directory+"addchapter.sce") then + tree("title_addchapter") = basename(directory); + end + + // Check if the last_successful_build is present + if isfile(directory+".last_successful_build") then + tree = x2f_cat(tree , x2f_read_lsb(directory+".last_successful_build")); + end + + // Get the default title + + if getos() == "Windows" then + tmpdirectory = strsubst(directory,"/\\$/","","r"); + else + tmpdirectory = strsubst(directory,"/\/$/","","r"); + end + + tree("title_default") = basename(tmpdirectory); + + // + // XML list management + // + + // get the xml list + xmlfiles = x2f_get_xml_files(directory); + + // Allocate the xml list + tree("xml_list") = xmlfiles; + tree("xml_number") = size(xmlfiles(:,1),"*"); + + // + // Sub Trees management + // + + // get the directory list + directories = x2f_get_directories(directory); + + for i=1:size(directories,"*") + this_dir_tree = x2f_dir_to_tree(directory+directories(i),tree("level") + 1); + if this_dir_tree("xml_number") > 0 then + tree("dir_"+getmd5(directories(i),"string")) = this_dir_tree; + tree("xml_number") = tree("xml_number") + this_dir_tree("xml_number"); + end + end + +endfunction + +// ============================================================================= +// xmlfiles = x2f_get_xml_files(directory) +// return an n X 3 matrix +// +// xmlfiles(:,1) : basename of each XML file +// xmlfiles(:,2) : full path of each XML file +// xmlfiles(:,3) : Last modification time of each XML file +// +// Date : 24/04/2009 +// ============================================================================= + +function xmlfiles = x2f_get_xml_files(directory) + + rhs = argn(2); + + // Check number of input arguments + // ========================================================================= + + if rhs <> 1 then + error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"x2f_get_xml_files",1)); + end + + // Check input argument type + // ========================================================================= + + if type(directory) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"x2f_get_xml_files",1)); + end + + // Check input argument dimension + // ========================================================================= + + if size(directory,"*") <> 1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"x2f_get_xml_files",1)); + end + + // Check the directory existence + // ========================================================================= + + if ~isdir(directory) then + error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid existing directory is expected.\n"),"x2f_get_xml_files",1)); + end + + // ... and now, Action + // ========================================================================= + + directory = pathconvert(directory); + + // remove duplicated names in current directory (example: case ".xml~") + xmlfiles = unique(basename(findfiles(directory, "*.xml"))); + + xmlfiles = gsort(xmlfiles, "lr", "i"); + xmlfiles(grep(xmlfiles,"master_help")) = []; + xmlfiles(grep(xmlfiles,"master")) = []; + + // Loop on all xml files to get their full path + // ========================================================================= + + if xmlfiles <> [] then + xmlpaths = directory + xmlfiles + ".xml"; + else + xmlpaths = []; + end + + // Get XML modification time + // ========================================================================= + + if xmlpaths<>[] then + infos = fileinfo(xmlpaths); + ft = format(); + format(20); + lmt = string(infos(:,7)); + format(ft(2),ft(1)); + else + lmt = []; + end + + // xmlfiles => md5sum + // ========================================================================= + + if xmlfiles <> [] then + xmlmd5 = "a" + getmd5(xmlpaths,"string"); + else + xmlmd5 = []; + end + + // Build the final matrix + // ========================================================================= + xmlfiles = [ xmlmd5 xmlpaths lmt xmlfiles]; + +endfunction + +// ============================================================================= +// directories = x2f_get_directories(directory) +// +// Returns a colum vector that contain the list of subdirectories of <directory> +// +// Date : 24/04/2009 +// ============================================================================= + +function directories = x2f_get_directories(directory) + + rhs = argn(2); + + // Check number of input arguments + // ========================================================================= + + if rhs <> 1 then + error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"x2f_get_directories",1)); + end + + // Check input argument type + // ========================================================================= + + if type(directory) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"x2f_get_directories",1)); + end + + // Check input argument dimension + // ========================================================================= + + if size(directory,"*") <> 1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"x2f_get_directories",1)); + end + + // Check the directory existence + // ========================================================================= + + if ~isdir(directory) then + error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid existing directory is expected.\n"),"x2f_get_directories",1)); + end + + // ... and now, Action + // ========================================================================= + + // Normalize the directory path + directory = pathconvert(directory); + + items = listfiles(directory); + directories = []; + + for i=1:size(items,"*") + if isdir(directory+items(i)) then + directories = [ directories ; items(i) ]; + end + end + + // Sort directories + directories = gsort(basename(directories),"lr","i"); + + // Remove directories that start with a dot from the list + directories(grep(directories,"/^\./","r")) = []; + + // Remove blank strings from the list + directories(find(directories == "")) = []; + + // Remove all scilab_xx_XX_help directories from the list + directories( grep(directories,"/^scilab_[a-z][a-z]_[A-Z][A-Z]_help$/","r") ) = [] + +endfunction + +// ============================================================================= +// desc_out = x2f_read_CHAPTER(file_in) +// Parse a CHAPTER file +// +// Date : 24/04/2009 +// ============================================================================= + +function desc_out = x2f_read_CHAPTER(file_in) + + desc_out = struct(); + + rhs = argn(2); + + // Check number of input arguments + // ========================================================================= + + if rhs <> 1 then + error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"x2f_read_CHAPTER",1)); + end + + // Check input arguments value + // ========================================================================= + + if regexp( file_in,"/CHAPTER$/") == [] then + error(msprintf(gettext("%s: Wrong value for input argument #%d: A string that end with CHAPTER expected.\n"),"x2f_read_CHAPTER",1)); + end + + // Check the input file existence + // ========================================================================= + + if ~isfile( file_in ) then + error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid existing file is expected.\n"),"x2f_read_CHAPTER",1)); + end + + // ... and now, Action + // ========================================================================= + + FILETOPARSE = mgetl(file_in); + + current_field = ""; + + for i=1:size(FILETOPARSE,"*") + + // Second case : Current field continuation + if (regexp(FILETOPARSE(i),"/^\s/","o") == 1) & (current_field <> "") then + current_value = part(FILETOPARSE(i),2:length(FILETOPARSE(i))); + desc_out(current_field) = [ desc_out(current_field) ; current_value ]; + continue; + end + + // First case : new field + if regexp(FILETOPARSE(i),"/^[a-zA-Z][a-zA-Z0-9_]*\s*=\s*/","o") == 1 then + [current_field_start, current_field_end] = regexp(FILETOPARSE(i),"/\s*=\s*/","o") + current_field = part(FILETOPARSE(i),1:current_field_start-1); + current_value = part(FILETOPARSE(i),current_field_end+1:length(FILETOPARSE(i))); + desc_out(current_field) = current_value; + continue; + end + + // Third case : Blank line + if length(stripblanks(FILETOPARSE(i))) == 0 then + continue; + end + + // Else Error + error(msprintf(gettext("%s: The CHAPTER file is not well formated at line %d\n"),"x2f_read_CHAPTER",i)); + + end + +endfunction + +// ============================================================================= +// desc_out = x2f_read_lsb(file_in) +// Parse a last_successful_build file +// +// Date : 24/04/2009 +// ============================================================================= + +function desc_out = x2f_read_lsb(file_in) + + desc_out = struct(); + rhs = argn(2); + + // Check number of input arguments + // ========================================================================= + + if rhs <> 1 then + error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"x2f_read_lsb",1)); + end + + // Check input arguments value + // ========================================================================= + + if regexp( file_in,"/\.last_successful_build$/") == [] then + error(msprintf(gettext("%s: Wrong value for input argument #%d: A string that end with .last_successful_build expected.\n"),"x2f_read_lsb",1)); + end + + // Check the input file existence + // ========================================================================= + + if ~isfile( file_in ) then + error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid existing file is expected.\n"),"x2f_read_lsb",1)); + end + + // ... and now, Action + // ========================================================================= + + FILETOPARSE = stripblanks(mgetl(file_in)); + + for i=1:size(FILETOPARSE,"*") + + // First case : new field + if regexp(FILETOPARSE(i),"/^[a-zA-Z][a-zA-Z0-9_]*\s=\s/","o") == 1 then + current_field_length = regexp(FILETOPARSE(i),"/\s=\s/","o") + current_field = part(FILETOPARSE(i),1:current_field_length-1); + current_value = part(FILETOPARSE(i),current_field_length+3:length(FILETOPARSE(i))); + + if regexp(current_value,"/^[0-9]+$/") == [] then + error(msprintf(gettext("%s: The last_successful_build file is not well formated at line %d\n"),"x2f_read_lsb",i)); + end + + desc_out(current_field) = strtod(current_value); + continue; + end + + // Third case : Blank line + if length(FILETOPARSE(i)) == 0 then + continue; + end + + // Else Error + error(msprintf(gettext("%s: The last_successful_build file is not well formated at line %d\n"),"x2f_read_lsb",i)); + + end + +endfunction + +// ============================================================================= +// desc_out = x2f_cat( desc_in_1 , desc_in_2) +// +// Concatenate two mlist +// +// Date : 27/04/2009 +// ============================================================================= + +function desc_out = x2f_cat(desc_in_1,desc_in_2) + + rhs = argn(2); + + // Check number of input arguments + // ========================================================================= + + if rhs <> 2 then + error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_cat",2)); + end + + // Check input arguments type + // ========================================================================= + + if type(desc_in_1) <> 17 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_cat",1)); + end + + if type(desc_in_2) <> 17 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_cat",2)); + end + + // ... and now, Action + // ========================================================================= + + fields_in_2 = getfield(1,desc_in_2); + fields_in_2(1:2) = []; + + if or(isfield(desc_in_1,fields_in_2)) then + error(msprintf(gettext("%s: The 2 mlist must not have any field in common .\n"),"x2f_cat")); + end + + desc_out = desc_in_1; + + for i=1:size(fields_in_2,"*") + desc_out(fields_in_2(i)) = desc_in_2(fields_in_2(i)); + end + +endfunction + +// ============================================================================= +// master_document = x2f_tree_to_master( tree ) +// +// Date : 27/04/2009 +// ============================================================================= + +function master_document = x2f_tree_to_master( tree ) + + rhs = argn(2); + + // Check number of input arguments + // ========================================================================= + + if rhs <> 1 then + error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_tree_to_master",1)); + end + + // Check input arguments type + // ========================================================================= + + if type(tree) <> 17 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_tree_to_master",1)); + end + + // if a master.xml exists in the directory, return this file + // ========================================================================= + + if isfield(tree,"master.xml") & tree("master.xml") then + str = mgetl( tree("path") + "master.xml" ); + return; + end + + // Start output + // ========================================================================= + + if isfield(tree,"language") then + language = tree("language"); + else + language = "en_US"; + end + + master_document = ["<?xml version=""1.0"" encoding=""UTF-8""?>";.. + "<!DOCTYPE book ["; + "<!--Begin Entities-->"]; + + // Get the list of all xml files present in this tree + tree_xmllist = x2f_cat_xmllist( tree , [] ) + + // Process the path if under windows + if getos() == "Windows" then + tree_xmllist(:,2) = "file:///"+ strsubst(getlongpathname(tree_xmllist(:,2)) ,"\","/"); + end + + // Add entities + master_document = [ master_document ; "<!ENTITY "+tree_xmllist(:,1)+" SYSTEM """+tree_xmllist(:,2)+""">" ] + + // title management + + + if isfield(tree,"book_title") & (tree("book_title") <> "") then + // title defined in CHAPTER + book_title = tree("book_title"); + + + elseif isfield(tree,"title_addchapter") & (tree("title_addchapter") <> "") then + // title defined in addchapter.sce + book_title = tree("title_addchapter"); + + else + // title built with the directory name + book_title = tree("title_default"); + end + + book_title = strsubst(book_title,"&" ,"&"); + book_title = strsubst(book_title,"""" ,"""); + book_title = strsubst(book_title,">" ,">"); + book_title = strsubst(book_title,"<" ,"<"); + + master_document = [ master_document; .. + "<!--End Entities-->"; .. + "]>"; .. + "<book version=""5.0-subset Scilab"" xml:lang="""+language+""""; .. + " xmlns=""http://docbook.org/ns/docbook"""; .. + " xmlns:xlink=""http://www.w3.org/1999/xlink"""; .. + " xmlns:xi=""http://www.w3.org/2001/XInclude"""; .. + " xmlns:svg=""http://www.w3.org/2000/svg"""; .. + " xmlns:mml=""http://www.w3.org/1998/Math/MathML"""; .. + " xmlns:html=""http://www.w3.org/1999/xhtml"""; .. + " xmlns:db=""http://docbook.org/ns/docbook"">"; .. + " <info xml:id=''"+x2f_title2id(book_title)+"_manual''>"; .. + " <title>"+book_title+"</title>"; .. + " </info>"; .. + ""]; + + // title management + // ========================================================================= + + // title management + if isfield(tree,"title") & (tree("title") <> "") then + // title defined in CHAPTER + section_title = tree("title"); + elseif isfield(tree,"title_addchapter") & (tree("title_addchapter") <> "") then + // title defined in addchapter.sce + section_title = tree("title_addchapter"); + else + // title built with the directory name + section_title = tree("title_default"); + end + + // xml_list management + // ========================================================================= + + offset = 0; + + if isfield(tree,"xml_list") then + xmllist = tree("xml_list"); + if xmllist <> [] then + master_document = [ master_document ; "<part xml:id=''section_"+getmd5(strsubst(tree("path"),SCI,""),"string")+"''>" ]; + master_document = [ master_document ; "<title>"+section_title+"</title>" ]; + master_document = [ master_document ; "&"+xmllist(:,1)+";" ]; + offset = 1; + end + end + + // Loop on dir_ + // ========================================================================= + + my_subtrees = getfield(1,tree); + my_subtrees(find(part(my_subtrees,1:4)<>"dir_")) = []; + + for i=1:size(my_subtrees,"*") + master_document = [ master_document ; x2f_tree_to_section( tree(my_subtrees(i)) , offset ) ]; + end + + // End of master document + // ========================================================================= + + if offset == 1 then + master_document = [ master_document ; "</part>" ]; + end + + master_document = [ master_document; "</book>" ]; + +endfunction + +// ============================================================================= +// master_section = x2f_tree_to_section( tree , offset ) +// +// Date : 27/04/2009 +// ============================================================================= + +function master_section = x2f_tree_to_section( tree , offset ) + + rhs = argn(2); + + // Check number of input arguments + // ========================================================================= + + if rhs <> 2 then + error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_tree_to_section",2)); + end + + // Check input arguments type + // ========================================================================= + + if type(tree) <> 17 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_tree_to_section",1)); + end + + if type(offset) <> 1 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: An integer expected.\n"),"x2f_tree_to_section",2)); + end + + // And now, action ... + // ========================================================================= + + // + // Section Type management + // + + // level : + // 0 : book + // 1 : part + // 2 : chapter + // 3 : sect1 + // 4 : sect2 + // 5 : sect3 + // 6 : sect4 + + section_types = [ .. + "book" ; .. + "part" ; .. + "chapter" ; .. + "section" ; .. + "section" ; .. + "section" ; .. + "section" ; .. + "section" ]; + + if isfield(tree,"level") & ((tree("level") + offset)>0) & ((tree("level") + offset)<8) then + section_type = section_types( tree("level") + offset + 1 ); + else + section_type = "reference"; + end + + // + // title management + // + + if isfield(tree,"title_addchapter") & (tree("title_addchapter") <> "") then + // title defined in addchapter.sce + section_title = tree("title_addchapter"); + elseif isfield(tree,"title") & (tree("title") <> "") then + // title defined in CHAPTER + section_title = tree("title"); + else + // title built with the directory name + section_title = tree("title_default"); + end + + if (isfield(tree, "xml_id")) then + xml_id = tree("xml_id"); + else + xml_id = "section_"+getmd5(strsubst(tree("path"),SCI,""),"string"); + end + + section_title = strsubst(section_title,"&" ,"&"); + section_title = strsubst(section_title,"""" ,"""); + section_title = strsubst(section_title,">" ,">"); + section_title = strsubst(section_title,"<" ,"<"); + + master_section = []; + master_section = [ master_section ; "<"+section_type+" xml:id=''" + xml_id + "''>" ]; + master_section = [ master_section ; "<title>"+section_title+"</title>" ]; + + // Loop on dir_ + // ========================================================================= + + my_subtrees = getfield(1,tree); + my_subtrees(find(part(my_subtrees,1:4)<>"dir_")) = []; + + for i=1:size(my_subtrees,"*") + master_section = [ master_section ; x2f_tree_to_section( tree(my_subtrees(i)) , offset ) ]; + end + + // xml list + // ========================================================================= + + if isfield(tree,"xml_list") then + xmllist = tree("xml_list"); + if xmllist <> [] then + master_section = [ master_section ; "&"+xmllist(:,1)+";" ]; + end + end + + master_section = [ master_section ; "</"+section_type+">" ]; + +endfunction + +// ============================================================================= +// tree_out = x2f_merge_trees( tree_in_1 , tree_in_2 ) +// +// Date : 27/04/2009 +// ============================================================================= + +function tree_out = x2f_merge_trees( tree_in_1 , tree_in_2 ) + + // tree_in_1 : reference tree + // tree_in_2 : tree to fill + + rhs = argn(2); + + // Check number of input arguments + // ========================================================================= + + if rhs <> 2 then + error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_merge_trees",1)); + end + + // Check input arguments type + // ========================================================================= + + if type(tree_in_1) <> 17 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_merge_trees",1)); + end + + if type(tree_in_2) <> 17 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_merge_trees",2)); + end + + tree_out = tree_in_2; + + // Loop on dir_ + // ========================================================================= + + my_subtrees = getfield(1,tree_in_1); + my_subtrees(find(part(my_subtrees,1:4)<>"dir_")) = []; + + for i=1:size(my_subtrees,"*") + // Check if the subtree exists in tree_in_2 + if ~isfield(tree_in_2,my_subtrees(i)) then + // if not, copy the whole subtree in tree_in_2 + this_subtree = tree_in_1(my_subtrees(i)); + tree_out(my_subtrees(i)) = tree_in_1(my_subtrees(i)); + tree_out("xml_number") = tree_out("xml_number") + this_subtree("xml_number"); + + else + // if yes, iterate with x2f_merge_trees + this_subtree_before = tree_in_2(my_subtrees(i)) + xml_number_before = this_subtree_before("xml_number"); + this_subtree_after = x2f_merge_trees( tree_in_1(my_subtrees(i)) , this_subtree_before ); + xml_number_after = this_subtree_after("xml_number"); + + tree_out(my_subtrees(i)) = this_subtree_after; + tree_out("xml_number") = tree_out("xml_number") + xml_number_after - xml_number_before; + end + end + + // XML list management + // ========================================================================= + + if isfield(tree_in_1,"xml_list") then + xmllist_1 = tree_in_1("xml_list"); + else + xmllist_1 = []; + end + + if isfield(tree_in_2,"xml_list") then + xmllist_2 = tree_in_2("xml_list"); + else + xmllist_2 = []; + end + + xmllist_out = xmllist_2; + + for i=1:size(xmllist_1(:,4),"*") + if find(xmllist_2(:,4) == xmllist_1(i,4)) == [] then + xmllist_out = [ xmllist_out ; xmllist_1(i,:) ]; + tree_out("xml_number") = tree_out("xml_number") + 1; + end + end + + tree_out("xml_list") = xmllist_out; + +endfunction + +// ============================================================================= +// xmllist_out = x2f_cat_xmllist( tree , xmllist_in ) +// +// Returns a n x 3 matrix that list all xmlfile in this tree and subtrees +// +// Date : 27/04/2009 +// ============================================================================= + +function xmllist_out = x2f_cat_xmllist( tree , xmllist_in ) + + rhs = argn(2); + xmllist_out = xmllist_in; + + // Check number of input arguments + // ========================================================================= + + if rhs <> 2 then + error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_cat_xmllist",2)); + end + + // Check input arguments type + // ========================================================================= + + if type(tree) <> 17 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_cat_xmllist",1)); + end + + if (xmllist_in<> []) & (type(xmllist_in) <> 10) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"x2f_cat_xmllist",2)); + end + + // This tree xml list to start + // ========================================================================= + + if isfield(tree,"xml_list") then + xmllist_out = [ xmllist_out ; tree("xml_list") ]; + end + + // Loop on dir_ + // ========================================================================= + + my_subtrees = getfield(1,tree); + my_subtrees(find(part(my_subtrees,1:4)<>"dir_")) = []; + + for i=1:size(my_subtrees,"*") + xmllist_out = x2f_cat_xmllist( tree(my_subtrees(i)) , xmllist_out ); + end + +endfunction + +// ============================================================================= +// section_id = x2f_title2id(title) +// +// Returns a normalized string from <title> string +// +// Date : 27/04/2009 +// ============================================================================= + +function section_id = x2f_title2id(title_in) + + section_id = title_in; + + section_id = strsubst(section_id , "&" , "_" ); + + section_id = strsubst(section_id , "À" , "A" ); + section_id = strsubst(section_id , "Á" , "A" ); + section_id = strsubst(section_id , "Â" , "A" ); + section_id = strsubst(section_id , "Ã" , "A" ); + section_id = strsubst(section_id , "Ä" , "A" ); + section_id = strsubst(section_id , "Å" , "A" ); + section_id = strsubst(section_id , "Æ" , "AE"); + section_id = strsubst(section_id , "Ç" , "C" ); + section_id = strsubst(section_id , "È" , "E" ); + section_id = strsubst(section_id , "É" , "E" ); + section_id = strsubst(section_id , "Ê" , "E" ); + section_id = strsubst(section_id , "Ë" , "E" ); + section_id = strsubst(section_id , "Ì" , "I" ); + section_id = strsubst(section_id , "Í" , "I" ); + section_id = strsubst(section_id , "Î" , "I" ); + section_id = strsubst(section_id , "Ï" , "I" ); + section_id = strsubst(section_id , "Ð" , "D" ); + section_id = strsubst(section_id , "Ñ" , "N" ); + section_id = strsubst(section_id , "Ò" , "O" ); + section_id = strsubst(section_id , "Ó" , "O" ); + section_id = strsubst(section_id , "Ô" , "O" ); + section_id = strsubst(section_id , "Õ" , "O" ); + section_id = strsubst(section_id , "Ö" , "O" ); + section_id = strsubst(section_id , "Ù" , "U" ); + section_id = strsubst(section_id , "Ú" , "U" ); + section_id = strsubst(section_id , "Û" , "U" ); + section_id = strsubst(section_id , "Ü" , "U" ); + section_id = strsubst(section_id , "Ý" , "Y" ); + section_id = strsubst(section_id , "à" , "a" ); + section_id = strsubst(section_id , "á" , "a" ); + section_id = strsubst(section_id , "â" , "a" ); + section_id = strsubst(section_id , "ã" , "a" ); + section_id = strsubst(section_id , "ä" , "a" ); + section_id = strsubst(section_id , "å" , "a" ); + section_id = strsubst(section_id , "æ" , "ae"); + section_id = strsubst(section_id , "ç" , "c" ); + section_id = strsubst(section_id , "è" , "e" ); + section_id = strsubst(section_id , "é" , "e" ); + section_id = strsubst(section_id , "ê" , "e" ); + section_id = strsubst(section_id , "ë" , "e" ); + section_id = strsubst(section_id , "ì" , "i" ); + section_id = strsubst(section_id , "í" , "i" ); + section_id = strsubst(section_id , "î" , "i" ); + section_id = strsubst(section_id , "ï" , "i" ); + section_id = strsubst(section_id , "ñ" , "n" ); + section_id = strsubst(section_id , "ò" , "o" ); + section_id = strsubst(section_id , "ó" , "o" ); + section_id = strsubst(section_id , "ô" , "o" ); + section_id = strsubst(section_id , "õ" , "o" ); + section_id = strsubst(section_id , "ö" , "o" ); + section_id = strsubst(section_id , "ù" , "u" ); + section_id = strsubst(section_id , "ú" , "u" ); + section_id = strsubst(section_id , "û" , "u" ); + section_id = strsubst(section_id , "ü" , "u" ); + section_id = strsubst(section_id , "ý" , "y" ); + section_id = strsubst(section_id , "ÿ" , "y" ); + + section_id = strsubst(section_id , ":" , "" ); + section_id = strsubst(section_id , "\" , "_" ); + section_id = strsubst(section_id , "/" , "_" ); + section_id = strsubst(section_id , "''" , "_" ); + section_id = strsubst(section_id , " " , " " ); + section_id = strsubst(section_id , " " , "_" ); + section_id = strsubst(section_id , "[" , "" ); + section_id = strsubst(section_id , "]" , "" ); + + section_id = convstr(section_id,"l"); + +endfunction + +// ============================================================================= +// timestamp = x2f_get_most_recent( tree ) +// +// Return the timestamp associated with the most recent XML file, ... and its +// path if a second output argument is precised +// +// Date : 27/04/2009 +// ============================================================================= + +function [timestamp,path] = x2f_get_most_recent( tree ) + + rhs = argn(2); + timestamp = 0; + path = ""; + + // Check number of input arguments + // ========================================================================= + + if rhs <> 1 then + error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_get_most_recent",1)); + end + + // Check input arguments type + // ========================================================================= + + if type(tree) <> 17 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_cat_xmllist",1)); + end + + // Get the full XML list + // ========================================================================= + + xmllist = x2f_cat_xmllist(tree,[]); + + [values,index] = gsort(strtod(xmllist(:,3))); + + timestamp = xmllist( index(1) , 3 ); + path = xmllist( index(1) , 2 ); + +endfunction diff --git a/modules/helptools/macros/xmltohtml.bin b/modules/helptools/macros/xmltohtml.bin Binary files differnew file mode 100755 index 000000000..8bb44d2e8 --- /dev/null +++ b/modules/helptools/macros/xmltohtml.bin diff --git a/modules/helptools/macros/xmltohtml.sci b/modules/helptools/macros/xmltohtml.sci new file mode 100755 index 000000000..958c3da3f --- /dev/null +++ b/modules/helptools/macros/xmltohtml.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function generated_files = xmltohtml(dirs,titles,directory_language,default_language) + + lhs=argn(1); + rhs=argn(2); + + select rhs + + case 0 then + generated_files = xmltoformat("html"); + case 1 then + generated_files = xmltoformat("html",dirs); + case 2 then + generated_files = xmltoformat("html",dirs,titles); + case 3 then + generated_files = xmltoformat("html",dirs,titles,directory_language); + case 4 then + generated_files = xmltoformat("html",dirs,titles,directory_language,default_language); + else + error(msprintf(gettext("%s: Wrong number of input argument(s): At most %d expected.\n"),"xmltohtml",4)); + + end + +endfunction diff --git a/modules/helptools/macros/xmltojar.bin b/modules/helptools/macros/xmltojar.bin Binary files differnew file mode 100755 index 000000000..d7e96fb86 --- /dev/null +++ b/modules/helptools/macros/xmltojar.bin diff --git a/modules/helptools/macros/xmltojar.sci b/modules/helptools/macros/xmltojar.sci new file mode 100755 index 000000000..7d0140839 --- /dev/null +++ b/modules/helptools/macros/xmltojar.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function generated_files = xmltojar(dirs,titles,directory_language,default_language) + + lhs=argn(1); + rhs=argn(2); + + select rhs + + case 0 then + generated_files = xmltoformat("javaHelp"); + case 1 then + generated_files = xmltoformat("javaHelp",dirs); + case 2 then + generated_files = xmltoformat("javaHelp",dirs,titles); + case 3 then + generated_files = xmltoformat("javaHelp",dirs,titles,directory_language); + case 4 then + generated_files = xmltoformat("javaHelp",dirs,titles,directory_language,default_language); + else + error(msprintf(gettext("%s: Wrong number of input argument(s): At most %d expected.\n"),"xmltojar",4)); + + end + +endfunction diff --git a/modules/helptools/macros/xmltopdf.bin b/modules/helptools/macros/xmltopdf.bin Binary files differnew file mode 100755 index 000000000..4002e55b8 --- /dev/null +++ b/modules/helptools/macros/xmltopdf.bin diff --git a/modules/helptools/macros/xmltopdf.sci b/modules/helptools/macros/xmltopdf.sci new file mode 100755 index 000000000..9cb22e94b --- /dev/null +++ b/modules/helptools/macros/xmltopdf.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function generated_files = xmltopdf(dirs,titles,directory_language,default_language) + + lhs=argn(1); + rhs=argn(2); + + select rhs + + case 0 then + generated_files = xmltoformat("pdf"); + case 1 then + generated_files = xmltoformat("pdf",dirs); + case 2 then + generated_files = xmltoformat("pdf",dirs,titles); + case 3 then + generated_files = xmltoformat("pdf",dirs,titles,directory_language); + case 4 then + generated_files = xmltoformat("pdf",dirs,titles,directory_language,default_language); + else + error(msprintf(gettext("%s: Wrong number of input argument(s): At most %d expected.\n"),"xmltopdf",4)); + + end + +endfunction diff --git a/modules/helptools/macros/xmltops.bin b/modules/helptools/macros/xmltops.bin Binary files differnew file mode 100755 index 000000000..f234980bd --- /dev/null +++ b/modules/helptools/macros/xmltops.bin diff --git a/modules/helptools/macros/xmltops.sci b/modules/helptools/macros/xmltops.sci new file mode 100755 index 000000000..d3ba9b753 --- /dev/null +++ b/modules/helptools/macros/xmltops.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function generated_files = xmltops(dirs,titles,directory_language,default_language) + + lhs=argn(1); + rhs=argn(2); + + select rhs + + case 0 then + generated_files = xmltoformat("ps"); + case 1 then + generated_files = xmltoformat("ps",dirs); + case 2 then + generated_files = xmltoformat("ps",dirs,titles); + case 3 then + generated_files = xmltoformat("ps",dirs,titles,directory_language); + case 4 then + generated_files = xmltoformat("ps",dirs,titles,directory_language,default_language); + else + error(msprintf(gettext("%s: Wrong number of input argument(s): At most %d expected.\n"),"xmltops",4)); + + end + +endfunction diff --git a/modules/helptools/macros/xmltoweb.bin b/modules/helptools/macros/xmltoweb.bin Binary files differnew file mode 100755 index 000000000..12421c67a --- /dev/null +++ b/modules/helptools/macros/xmltoweb.bin diff --git a/modules/helptools/macros/xmltoweb.sci b/modules/helptools/macros/xmltoweb.sci new file mode 100755 index 000000000..23fe882ab --- /dev/null +++ b/modules/helptools/macros/xmltoweb.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function generated_files = xmltoweb(dirs,titles,directory_language,default_language) + + lhs=argn(1); + rhs=argn(2); + + select rhs + + case 0 then + generated_files = xmltoformat("web"); + case 1 then + generated_files = xmltoformat("web",dirs); + case 2 then + generated_files = xmltoformat("web",dirs,titles); + case 3 then + generated_files = xmltoformat("web",dirs,titles,directory_language); + case 4 then + generated_files = xmltoformat("web",dirs,titles,directory_language,default_language); + else + error(msprintf(gettext("%s: Wrong number of input argument(s): At most %d expected.\n"),"xmltoweb",4)); + + end + +endfunction |