error(number): converting occurrences remaining in all .sce .sci files
[scilab.git] / scilab / modules / helptools / macros / help_skeleton.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2008 - INRIA
3 // Copyright (C) 2009 - DIGITEO - Allan CORNET
4 //
5 // Copyright (C) 2012 - 2016 - Scilab Enterprises
6 //
7 // This file is hereby licensed under the terms of the GNU GPL v2.0,
8 // pursuant to article 5.3.4 of the CeCILL v.2.1.
9 // This file was originally licensed under the terms of the CeCILL v2.1,
10 // and continues to be available under such terms.
11 // For more information, see the COPYING file which you should have received
12 // along with this program.
13
14 function txt = help_skeleton(funname, path, language)
15
16     [lhs,rhs] = argn(0);
17
18     if rhs > 3 | rhs < 1 then
19         msg = _("%s: Wrong number of input arguments: %d to %d expected.\n")
20         error(msprintf(msg, "help_skeleton", 1, 3));
21     end
22
23     if type(funname) <> 10 then
24         msg = gettext("%s: Wrong type for input argument #%d: string expected.\n")
25         error(msprintf(msg, "help_skeleton", 1));
26     end
27
28     if size(funname, "*") <> 1 then
29         msg = gettext("%s: Wrong size for input argument #%d: string expected.\n")
30         error(msprintf(msg, "help_skeleton", 1));
31     end
32
33     if rhs > 1 then
34         if type(path) <> 10 then
35             msg = _("%s: Argument #%d: Text(s) expected.\n")
36             error(msprintf(msg, "help_skeleton", 2));
37         end
38     end
39
40     previouslangage = getlanguage();
41
42     if rhs == 3 then
43         if type(language) <> 10 then
44             msg = _("%s: Argument #%d: Text(s) expected.\n")
45             error(msprintf(msg, "help_skeleton", 3));
46         end
47         setlanguage(language);
48     else
49         language = getlanguage();
50     end
51
52     txt = [];
53     vars = macrovar(evstr(funname));
54     inputs = vars(1);
55     outputs = vars(2);
56     context = vars(3);
57     Call = "";
58
59     if size(outputs,"*") == 1 then
60         Call = outputs + " = "
61     elseif size(outputs,"*") > 1 then
62         Call = "["+strcat(outputs,",")+"] = ";
63     end
64
65     Call = Call + funname;
66
67     if size(inputs,"*") >= 1 then
68         Call = Call+"("+strcat(inputs,",")+")";
69     end
70
71     args = [inputs(:);outputs(:)];
72
73     // date management
74     // --------------------------------------------------------------------------------
75     w = getdate();
76     xml_date = msprintf("%02d-%02d-%04d",w(6),w(2),w(1));
77
78     //header
79     // --------------------------------------------------------------------------------
80     xmlns = "xmlns=""http://docbook.org/ns/docbook"""
81     xlink = "xmlns:xlink=""http://www.w3.org/1999/xlink"""
82     svg = "xmlns:svg=""http://www.w3.org/2000/svg"""
83     mml = " xmlns:mml=""http://www.w3.org/1998/Math/MathML"""
84     db = "xmlns:db=""http://docbook.org/ns/docbook"""
85     scins = "xmlns:scilab=""http://www.scilab.org"""
86
87     refs = strcat([xmlns xlink svg mml db scins]," ")
88
89     txt=["<?xml version=""1.0"" encoding='"UTF-8""?>"
90     "<!--"
91     _(" * Add some comments about XML file");
92     "-->"
93     "<refentry " + refs + " xml:lang="""+ language + """ xml:id=""" + funname + """>"
94     "  <refnamediv>"
95     "    <refname>"+ funname + "</refname>"
96     "    <refpurpose>" + _("Add short description here.") + "</refpurpose>"
97     "  </refnamediv>"
98     "  <refsynopsisdiv>"
99     "    <title>" + _("Syntax") + "</title>"
100     "    <synopsis>" + Call + "</synopsis>"
101     "  </refsynopsisdiv>"];
102
103     //Arguments
104     if size(args,"*") >0 then
105         txt=[txt;
106         "  <refsection>"
107         "    <title>" + _("Arguments") + "</title>"
108         "    <variablelist>"]
109         for a=args'
110             txt=[txt;
111             "      <varlistentry>"
112             "        <term>" + a + "</term>"
113             "        <listitem>"
114             "          <para>"
115             _("            Add here the input/output argument description.")
116             "          </para>"
117             "        </listitem>"
118             "      </varlistentry>"]
119         end
120         txt=[txt;
121         "    </variablelist>"
122         "  </refsection>"];
123     end
124
125     //Description
126     txt=[txt;
127     "  <refsection>"
128     "    <title>" + _("Description") + "</title>"
129     "    <para>"
130     _("          Add here a paragraph of the function description.")
131     _("          Other paragraph can be added")
132     "    </para>"
133     "    <para>With a latex expression"
134     "          <latex>"
135     "            \begin{eqnarray}"
136     "    f(x,a,r) = \frac{1}{r^{-a}\Gamma(a)} \int_0^x t^{a-1} \exp\left(-rt\right) dt"
137     "    \end{eqnarray}"
138     "    </latex>"
139     "    </para>"
140     "  </refsection>"];
141
142     // More information
143     txt=[txt;
144     "  <refsection>"
145     "    <title>" + _("More information") + "</title>"
146     "    <note><para>A note about foo</para></note>"
147     "    <caution><para>A caution about foo</para></caution>"
148     "    <warning><para>A warning about foo</para></warning>"
149     "    <important><para>An important about foo</para></important>"
150     "    <tip><para>A tip about foo</para></tip>"
151     "  </refsection>"];
152
153     //Example
154     txt=[txt;
155     "  <refsection>"
156     "    <title>" + _("Examples") + "</title>"
157     "    <programlisting role=""example""><![CDATA["
158     _("        Add here scilab instructions and comments")
159     "    ]]></programlisting>"
160     "    <scilab:image><![CDATA["
161     "// "+_("        Add here scilab instructions to generate a graphic")
162     "    ]]></scilab:image>"
163     "  </refsection>"];
164
165     //See Also
166     txt=[txt;
167     "  <refsection>"
168     "    <title>" + _("See Also") + "</title>"
169     "    <simplelist type=""inline"">"
170     "      <member>"
171     "        <link linkend=""" + _("add a reference name") + """ >" + _("add a reference") + "</link>"
172     "      </member>"
173     "      <member>"
174     "        <link linkend=""" + _("add a reference name") + """>" + _("add a reference") + "</link>"
175     "      </member>"
176     "    </simplelist>"
177     "  </refsection>"];
178
179     //Authors
180     txt=[txt;
181     "  <refsection>"
182     "    <title>" + _("Authors") + "</title>"
183     "    <simplelist type=""vert"">"
184     "      <member>" + _("add the author name and author reference") + "</member>"
185     "      <member>" + _("add another author name and his/her reference") + "</member>"
186     "    </simplelist>"
187     "  </refsection>"];
188
189     //Bibliography
190     txt = [txt;
191     "  <refsection>"
192     "     <title>" + _("Bibliography") + "</title>"
193     "       <para>"
194     _("         Add here the function bibliography")
195     "       </para>"
196     "     </refsection>"];
197
198     // History
199     txt = [txt;
200     "    <refsection>"
201     "       <title>" + _("History") + "</title>"
202     "      <revhistory>"
203     "        <revision>"
204     "          <revnumber>X.Y</revnumber>"
205     "          <revdescription>Function foo added</revdescription>"
206     "        </revision>"
207     "      </revhistory>"
208     "    </refsection>"];
209
210     //Used functions
211     txt=[txt;
212     "  <refsection>"
213     "     <title>" + _("Used Functions") + "</title>"
214     "       <para>"
215     _("         Add here the Scilab, C,... used code references")
216     "       </para>"
217     "     </refsection>"];
218
219     //footer
220     txt=[txt;
221     "</refentry>"];
222
223     setlanguage(previouslangage);
224
225     if rhs >= 2 then
226         mputl(txt, pathconvert(path,%t,%f) + funname + ".xml");
227         txt = pathconvert(path,%t,%f) + funname + ".xml";
228     end
229
230 endfunction