generate_scifun_tex_file - create main tex file of scilab macros
txt = generate_scifun_tex_file(namef,flag,lang)
- namef : string. the name of the scilab macros.
- flag : string. set the type of tex files to produce
- 'html' : to produce tex file for html format
- 'guide' : to produce tex file for paper format
- lang : string. set the lang of tex file
- 'eng' : to produce english man page
- 'fr' : to produce french man page
- txt : vector of strings. the output text of the tex file
//generate_scifunc_tex_file
//Entrée : namef un vecteur de chaine de caractère
// flag 'html' ou 'guide'
//txt = le texte du fichier .tex principal
function txt=generate_scifun_tex_file(namef,flag,lang)
//verify the 'lang' right parameter
[lsh,rsh]=argn(0)
if rsh<3 then
if ~exists('lang') then
lang='eng'
elseif lang<>'eng' & lang<>'fr' then
lang='eng'
end
end
//Generate auxiliary tex files
namef=generate_aux_tex_file(namef,'sci');
//tt1 : header
//tt2 : library
//tt3 : calling Sequence
//tt4 : parameters
//tt5 : description
//tt6 : remarks (_rmk)
//tt7 : example
//tt8 : algorithm (_algo)
//tt9 : text of function
//tt10 : used functions
//tt11 : see also
//tt12 : Authors
//tt13 : Bibliography
//tt14 : end of tex file
//define title of paragraph
tt_title=[
'' //tt1 : header du fichier tex
'Library' //tt2 : library
'Calling Sequence' //tt3 : calling sequence
'Parameters' //tt4 : parameters
'Description' //tt5 : Description (_long)
'Remarks' //tt6 : Remarks
'Example' //tt7 : Example (_ex)
'Algorithm' //tt8 : Algorithm (_algo)
'File content' //tt9 : text of funtion
'Used function(s)' //tt10 : Used functions (_used_func)
'See Also' //tt11 : See Also (_see_also)
'Authors' //tt12 : Authors (_authors)
'Bibliography' //tt13 : Bibliography (_bib)
'' //tt14 : End of tex file
]
//change language of title
if lang=='fr' then
tt_title=change_lang_title(lang,tt_title);
end
//define level of paragraph
if flag=='html' then
tex_title='\subsection{'+tt_title+'}'
else
tex_title='\subsection{'+tt_title+'}'
end
for i=1:size(namef,1) //for each file
for j=1:14 execstr('tt'+string(j)+'=[]'),end //for each paragraph
if fileinfo(namef(i,1)+'_sci/'+namef(i,1)+'_call_seq.tex')<>[] then
tt3=[tex_title(3) //Calling sequence
'\input{'+namef(i,1)+'_call_seq}']
end
if fileinfo(namef(i,1)+'_sci/'+namef(i,1)+'_param.tex')<>[] then
tt4=[tex_title(4) //parameters
'\input{'+namef(i,1)+'_param}']
end
if fileinfo(namef(i,1)+'_sci/'+namef(i,1)+'_long.tex')<>[] then
tt5=[tex_title(5) //description
''
'\input{'+namef(i,1)+'_long}']
end
if fileinfo(namef(i,1)+'_sci/'+namef(i,1)+'_rmk.tex')<>[] then
tt6=[tex_title(6) //Remarks
'\input{'+namef(i,1)+'_rmk}']
end
if fileinfo(namef(i,1)+'_sci/'+namef(i,1)+'_ex.tex')<>[] then
tt7=[tex_title(7) //Example
'\input{'+namef(i,1)+'_ex}']
end
if fileinfo(namef(i,1)+'/'+namef(i,1)+'_algo.tex')<>[] then //Algorithm
tt8=[tex_title(8)
'\input{'+namef(i,1)+'_algo}']
end
tt_rep=return_ext_file(tt_ml,namef(i,1)+'.sci');
if tt_rep<>[] then
if size(tt_rep,1)==1 then
tt9=[tex_title(9) //file content
'{\tiny'
'\verbatiminput{'+tt_rep(1)+tt_rep(2)+'}'
'}']
end
end
if fileinfo(namef(i,1)+'_sci/'+namef(i,1)+'_used_func.tex')<>[] then
tt10=[tex_title(10) //Used function
'\input{'+namef(i,1)+'_used_func}']
end
if fileinfo(namef(i,1)+'_sci/'+namef(i,1)+'_see_also.tex')<>[] then
tt11=[tex_title(11) //See also
'\input{'+namef(i,1)+'_see_also}']
end
if fileinfo(namef(i,1)+'_sci/'+namef(i,1)+'_bib.tex')<>[] then
tt13=['\input{'+namef(i,1)+'_bib.tex}']; //bibliography
end
if flag=='guide' then
//TO BE DONE
new_title=convstr(part(namef(i,2),1),'u')+part(namef(i,2),2:length(namef(i,2)));
tt1=['\section{'+latexsubst(new_title)+'\label{'+namef(i,1)+'}} ';
'\begin{itemize}';]
if lang=='fr' then
tt1=[tt1;'\item \textbf{Nom:} '+latexsubst(namef(i,1))];
else
tt1=[tt1;'\item \textbf{Name:} '+latexsubst(namef(i,1))];
end
LibName=return_rpordoef(tt_ml,namef(i,1)+'.sci');
//pause
if LibName==[] then
for j=1:size(modnum_sci_func,1)
if namef(i,1)==modnum_sci_func(j) then
LibName=mod_num_sci_lib;
break
end
end
end
if LibName<>[] then
if size(LibName,1)==1 then
tta=return_xml_sdesc(xml_path+lang+'/'+LibName+'.xml')
if tta<>[] then
if lang=='fr' then
tt1=[tt1;'\item \textbf{Librairie:} '+latexsubst(LibName)+...
' - '+latexsubst(tta)]
else
tt1=[tt1;'\item \textbf{Library:} '+latexsubst(LibName)+...
' - '+latexsubst(tta)]
end
end
end
end
tt1=[tt1;'\end{itemize}'];
elseif flag=='html' then
if lang=='fr' then //Header of tex file
tt1=['\documentclass[11pt,frenchb]{article}']
else
tt1=['\documentclass[11pt]{article}']
end
tt1=[tt1;
'\usepackage{makeidx,graphics,fullpage}'
'\usepackage{verbatim,times,amsmath,amssymb,epsfig,color}'
'\usepackage{html}'
'\begin{document}'];
if lang=='fr' then
tt1=[tt1;'\begin{center}Fonction Scilab\\'];
else
tt1=[tt1;'\begin{center}'+latexsubst(namef(i,3))+'\\'];
end
tt1=[tt1
'\htmladdnormallink{eng}{../eng/'+namef(i,1)+'.htm}\hspace{2mm}-'+...
'\hspace{2mm}\htmladdnormallink{fr}{../fr/'+namef(i,1)+'.htm}}'
'\end{center}'];
tt1=[tt1;'\section{\textbf{'+latexsubst(namef(i,1))+...
'} - '+latexsubst(namef(i,2))+'}\label{'+namef(i,1)+'}'];
LibName=return_rpordoef(tt_ml,namef(i,1)+'.sci');
//pause
if LibName==[] then
for j=1:size(modnum_sci_func,1)
if namef(i,1)==modnum_sci_func(j) then
LibName=mod_num_sci_lib;
break
end
end
end
if LibName<>[] then
if size(LibName,1)==1 then
tta=return_xml_sdesc(xml_path+lang+'/'+LibName+'.xml')
if tta<>[] then
tt2=[tex_title(2) //Library
'\begin{itemize}']
tt2=[tt2;'\item{\htmladdnormallink{'+latexsubst(LibName)+...
' - '+latexsubst(tta)+'}{'+LibName+'.htm}}']
tt2=[tt2;'\end{itemize}']
end
end
end
if fileinfo(namef(i,1)+'_sci/'+namef(i,1)+'_authors.tex')<>[] then
tt12=[tex_title(12) //authors
'\input{'+namef(i,1)+'_authors}']
end
tt14=['\htmlinfo*';'\end{document}']
end
//Write the main tex file of scilab macro
txt=[];
for j=1:14 txt=[txt;evstr('tt'+string(j))], end;
mputl(txt,namef(i,1)+'_sci/'+namef(i,1)+'.tex');
end
// else
// printf("Bad flag\n");
// txt=[];
// end
endfunction
IRCOM Group
Alan Layec