Skip to content

Commit

Permalink
- Moved isPackage to the scripting enviornment
Browse files Browse the repository at this point in the history
- GenerateDoc now splits the index page between libraries and builtin environment


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10874 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 10, 2012
1 parent 48b5d59 commit 2f1435a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 28 deletions.
11 changes: 11 additions & 0 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -2190,6 +2190,17 @@ annotation(
preferredView="text");
end basename;

function isPackage
input TypeName cl;
output Boolean b;
external "builtin";
annotation(
Documentation(info="<html>
Returns true if the given classname is a package.
</html>"),
preferredView="text");
end isPackage;

annotation(preferredView="text");
end Scripting;

Expand Down
8 changes: 7 additions & 1 deletion Compiler/Script/CevalScript.mo
Expand Up @@ -1680,6 +1680,12 @@ algorithm
((str1,str2)) = Interactive.getNamedAnnotation(classpath, p, "Documentation", SOME(("","")),Interactive.getDocumentationAnnotationString);
then
(cache,ValuesUtil.makeArray({Values.STRING(str1),Values.STRING(str2)}),st);

case (cache,env,"isPackage",{Values.CODE(Absyn.C_TYPENAME(classpath))},st as Interactive.SYMBOLTABLE(ast=p),msg)
equation
b = Interactive.isPackage(classpath, p);
then
(cache,Values.BOOL(b),st);

case (cache,env,"getAstAsCorbaString",{Values.STRING("<interactive>")},st as Interactive.SYMBOLTABLE(ast=p),msg)
equation
Expand Down Expand Up @@ -3955,7 +3961,7 @@ algorithm
// Absyn.CLASS(partialPrefix = false) = c; // do not filter partial classes
cr = Absyn.pathToCref(className);
// filter out packages
false = Interactive.isPackage(cr, p);
false = Interactive.isPackage(className, p);
// filter out functions
// false = Interactive.isFunction(cr, p);
// filter out types
Expand Down
21 changes: 5 additions & 16 deletions Compiler/Script/Interactive.mo
Expand Up @@ -1986,15 +1986,6 @@ algorithm
then
(resstr,st);

case (istmts, st as SYMBOLTABLE(ast = p))
equation
matchApiFunction(istmts, "isPackage");
{Absyn.CREF(componentRef = cr)} = getApiFunctionArgs(istmts);
b1 = isPackage(cr, p);
resstr = boolString(b1);
then
(resstr,st);

case (istmts, st as SYMBOLTABLE(ast = p))
equation
matchApiFunction(istmts, "isClass");
Expand Down Expand Up @@ -2089,7 +2080,7 @@ algorithm
matchApiFunction(istmts, "existPackage");
{Absyn.CREF(componentRef = cr)} = getApiFunctionArgs(istmts);
b1 = existClass(cr, p);
b2 = isPackage(cr, p);
b2 = isPackage(Absyn.crefToPath(cr), p);
b = boolAnd(b1, b2);
resstr = boolString(b);
then
Expand Down Expand Up @@ -8583,23 +8574,21 @@ public function isPackage
This function takes a component reference and a program.
It returns true if the refrenced class has the restriction
\"package\", otherwise it returns false."
input Absyn.ComponentRef inComponentRef;
input Absyn.Path path;
input Absyn.Program inProgram;
output Boolean outBoolean;
algorithm
outBoolean:=
matchcontinue (inComponentRef,inProgram)
matchcontinue (path,inProgram)
local
Absyn.Path path;
Absyn.ComponentRef cr;
Absyn.Program p;
case (cr,p)
case (path,p)
equation
path = Absyn.crefToPath(cr);
Absyn.CLASS(_,_,_,_,Absyn.R_PACKAGE(),_,_) = getPathedClassInProgram(path, p);
then
true;
case (cr,p) then false;
else false;
end matchcontinue;
end isPackage;

Expand Down
40 changes: 29 additions & 11 deletions Examples/GenerateDoc.mos
Expand Up @@ -184,22 +184,40 @@ replaceCommands := "";
filetmp := "index.html";
writeFile(filetmp, "<html><head><title>Modelica Documentation</title><link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" /></head><body><h1>Modelica Documentation</h1>\n");
writeFile(filetmp, "<p>This is a listing of builtin Modelica functions, libraries shipped with OpenModelica and the documentation for OpenModelica-specific scripting.</p>\n", append = true);
writeFile(filetmp, "<h2>Contents</h2>\n", append = true);
writeFile(filetmp, "<h2>Libraries</h2>\n", append = true);
writeFile(filetmp, "<table><tr><th>Name</th><th>Description</th><th>Version</th></tr>", append = true);
for cl in classNames loop
file := getSourceFile(cl);
base := basename(file);
contentStrToks := typeNameStrings(cl);
modelVersion := getVersion(cl);
if base == "package.mo" then
replaceCommands := replaceCommands + " $link2 =~ s&[Mm][Oo][Dd][Ee][Ll][Ii][Cc][Aa]://" + contentStrToks[end] + "/&" + dirname(file) + "/&g;\n";
dirpaths := strtok(dirname(file),"/");
dirs := dirs + " \"" + dirpaths[end] + "\" ";
if base <> "ModelicaBuiltin.mo" then
base := basename(file);
contentStrToks := typeNameStrings(cl);
modelVersion := getVersion(cl);
if base == "package.mo" then
replaceCommands := replaceCommands + " $link2 =~ s&[Mm][Oo][Dd][Ee][Ll][Ii][Cc][Aa]://" + contentStrToks[end] + "/&" + dirname(file) + "/&g;\n";
dirpaths := strtok(dirname(file),"/");
dirs := dirs + " \"" + dirpaths[end] + "\" ";
end if;
comment := getClassComment(cl);
contentStr := typeNameString(cl);
fileName := filename(contentStr);
writeFile(filetmp, "<tr><td><a href=\"" + fileName + ".html\">" + contentStrToks[end] + "</a></td><td>" + comment + "</td><td>" + modelVersion + "</td></tr>", append = true);
end if;
end for;
writeFile(filetmp, "</table>\n", append = true);
writeFile(filetmp, "<h2>Builtin Environment</h2>\n", append = true);
writeFile(filetmp, "<table><tr><th>Name</th><th>Description</th><th>Version</th></tr>", append = true);
for cl in classNames loop
file := getSourceFile(cl);
base := basename(file);
if base == "ModelicaBuiltin.mo" then
contentStr := typeNameString(cl);
contentStrToks := typeNameStrings(cl);
modelVersion := getVersion(cl);
comment := getClassComment(cl);
fileName := filename(contentStr);
writeFile(filetmp, "<tr><td><a href=\"" + fileName + ".html\">" + contentStrToks[end] + "</a></td><td>" + comment + "</td><td>" + modelVersion + "</td></tr>", append = true);
end if;
contentStr := typeNameString(cl);
comment := getClassComment(cl);
fileName := filename(contentStr);
writeFile(filetmp, "<tr><td><a href=\"" + fileName + ".html\">" + contentStrToks[end] + "</a></td><td>" + comment + "</td><td>" + modelVersion + "</td></tr>", append = true);
end for;
writeFile(filetmp, "</table>\n", append = true);
writeFile(filetmp, version + " (<a href=\"ModelicaDocumentation.tar.xz\">Offline version</a>)", append = true);
Expand Down

0 comments on commit 2f1435a

Please sign in to comment.