-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathqigendoc.m
executable file
·50 lines (43 loc) · 1.68 KB
/
qigendoc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/local/bin/MathematicaScript -script
Print[$ScriptCommandLine[[2]]]
Needs["QI`"];
qiFormatUsageMsg[inName_,inMsg_] := Block[{name = "$ " <> inName <> " $ ",usage=inMsg,txt},
usage=StringReplace[usage,"\{"->"LEFTCURLY"];
usage=StringReplace[usage,"\}"->"RIGHTCURLY"];
txt="\\textbf{"<>name<>"}"<>"-- "<>StringDrop[StringReplace[usage,RegularExpression["\\\\text{([^\}]{5,1000})}"]-> " $$1$ "],2] <> " $";
txt=StringReplace[txt,"LEFTCURLY"-> "\{"];
txt=StringReplace[txt,"RIGHTCURLY"->"\}"];
txt
];
qiGenDoc[docFile_]:=Block[{latexHeader,latexFooter,f,txt,usage,name,functionsList},
ExportString["","TeX"];
functionsList=Table[{Names["QI`*"][[i]],ToExpression[Evaluate[Names["QI`*"][[i]]<>"::usage"]]},{i,1,Length[Names["QI`*"]]}];
latexHeader="\\documentclass[a4paper,10pt]{scrartcl}
\\usepackage{amsmath,amssymb,graphicx}
\\usepackage{fullpage}
\\parindent=0pt
\\begin{document}
\\title{QI Package for \\emph{Mathematica} 7.0 \\\\(version " <> QI`Private`qiVersion <> ")}" <>
"\\author{Jaros{\\l}aw Adam Miszczak \\quad Piotr Gawron \\quad Zbigniew Pucha{\\l}a\\\\
{The Institute of Theoretical and Applied Informatics}\\\\
{Polish Academy of Sciences},\\\\
{Ba{\\l}tycka 5, 44-100 Gliwice, Poland}}
\\maketitle
\\begin{abstract}"
<> QI`Private`qiAbout <>
"\\end{abstract}
";
latexFooter = "\\end{document}";
f=OpenWrite[docFile];
WriteString[f,latexHeader];
For[i=1,i<= Length[functionsList],i++,
name=ToString[TeXForm[functionsList[[i,1]]]];
usage=ToString[TeXForm[DisplayForm[functionsList[[i,2]]]]];
txt = qiFormatUsageMsg[name, usage];
WriteString[f,txt];
WriteString[f,"\\\\\n\n"];
];
WriteString[f,latexFooter];
Close[f];
];
qiGenDoc[$ScriptCommandLine[[2]]];