Skip to content

Commit

Permalink
- Additional speed-up for GenerateDoc.mos
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10763 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Dec 18, 2011
1 parent 9c15aba commit 64052b3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -5439,9 +5439,9 @@ algorithm
local
Absyn.Path path;
String s1;
case (Values.CODE(Absyn.C_TYPENAME(Absyn.IDENT(s1))),cache,env)
case (Values.CODE(Absyn.C_TYPENAME(path)),cache,env)
equation
(_,_,_,DAE.VALBOUND(valBound=Values.CODE(A=Absyn.C_TYPENAME(path=path))),_,_,_,_,_) = Lookup.lookupVar(cache, env, ComponentReference.makeCrefIdent(s1, DAE.T_ANYTYPE_DEFAULT, {}));
(_,_,_,DAE.VALBOUND(valBound=Values.CODE(A=Absyn.C_TYPENAME(path=path))),_,_,_,_,_) = Lookup.lookupVar(cache, env, ComponentReference.pathToCref(path));
then Values.CODE(Absyn.C_TYPENAME(path));
else val;
end matchcontinue;
Expand Down
54 changes: 42 additions & 12 deletions Examples/GenerateDoc.mos
Expand Up @@ -59,8 +59,8 @@ end if;
getErrorString();

a:=0;
b:=getClassNames(builtin=true,recursive=true,sort=true);

b:=getClassNames(builtin=true,recursive=true,sort=true);
/* If we want to test on fewer classes */
// b := {$TypeName(Modelica),$TypeName(Modelica.Math.Matrices.LAPACK.dgglse_vec)};
// b := {$TypeName(Modelica),$TypeName(Modelica.Electrical.Analog.Basic),$TypeName(Modelica.Electrical.Analog.Basic.VariableInductor)};
Expand All @@ -87,12 +87,46 @@ function filename
;
end filename;

function notLast
input String str[:];
output String ostr[:] := str[1:end];
end notLast;

function last
input String str[:];
output String ostr := str[end];
end last;

record Item
OpenModelica.Code.TypeName c;
String fullName;
String file;
String lastName;
String packageNames[:];
String docInfo[2];
String contents;
String comment;
String interface;
end Item;
");

echo(false); // This array is too big :)
b:={Item(
c,
OpenModelica.Scripting.typeNameString(c),
filename(OpenModelica.Scripting.typeNameString(c))+".html",
last(OpenModelica.Scripting.typeNameStrings(c)),
notLast(OpenModelica.Scripting.typeNameStrings(c)),
OpenModelica.Scripting.getDocumentationAnnotation(c),
sum("<tr><td><a href=\"" + filename(OpenModelica.Scripting.typeNameString(cl)) + ".html\">" +
last(OpenModelica.Scripting.strtok(OpenModelica.Scripting.typeNameString(cl),".")) + "</a></td>" +
"<td>" + filename(OpenModelica.Scripting.getClassComment(cl)) + "</td></tr>\n"
for cl in OpenModelica.Scripting.getClassNames(c,qualified=true,sort=true)),
OpenModelica.Scripting.getClassComment(c),
OpenModelica.Scripting.list(c,interfaceOnly=true)
) for c in b};
echo(true);

searchPaths := "";
filetmp := "index.html";
writeFile(filetmp, "<html><head><title>Modelica Documentation</title></head><body><h1>Modelica Documentation</h1>\n");
Expand All @@ -119,16 +153,12 @@ writeFile(filetmp, "</body>\n</html>", append = true);
i := 0;
sz := size(b,1);
for c in b loop
contents := sum("<tr><td><a href=\"" + filename(OpenModelica.Scripting.typeNameString(cl)) + ".html\">" +
last(OpenModelica.Scripting.strtok(OpenModelica.Scripting.typeNameString(cl),".")) + "</a></td>" +
"<td>" + filename(OpenModelica.Scripting.getClassComment(cl)) + "</td></tr>\n"
for cl in OpenModelica.Scripting.getClassNames(c,qualified=true,sort=true));
cl := typeNameString(c);
cls := typeNameStrings(c);
contents := c.contents;
cl := c.fullName;
compound := "";
clsEnd := cls[end];
clsNotEnd := cls[1:end-1];
file := filename(cl) + ".html";
clsEnd := c.lastName;
clsNotEnd := c.packageNames;
file := c.file;
filetmp := file + ".tmp";
writeFile(filetmp, "<title>"+cl+"</title>\n<h1><a href = \"index.html\">.</a>");
for ident in clsNotEnd loop
Expand All @@ -137,15 +167,15 @@ for c in b loop
writeFile(filetmp, "<a href = \""+file+"\">"+ident+"</a>.", append = true);
end for;
writeFile(filetmp, clsEnd + "</h1>", append = true);
arr := getDocumentationAnnotation(c);
arr := c.docInfo;
docInfo := if arr[1] == "" then "<pre>" + OpenModelica.Scripting.getClassComment(c) + "</pre>" else arr[1];
revisions := arr[2];
if regexBool(docInfo,"^.*<[Hh][Tt][Mm][Ll]>.*$") then
writeFile(filetmp, "\n" + docInfo, append = true);
else
writeFile(filetmp, "\n<pre>" + docInfo + "</pre>", append = true);
end if;
interface := list(c, interfaceOnly = true);
interface := c.interface;
if interface <> "" then
writeFile(filetmp, "\n<h4>Interface</h4>\n<blockquote><pre>" + interface + "</pre></blockquote>", append = true);
end if;
Expand Down

0 comments on commit 64052b3

Please sign in to comment.