Skip to content
Snippets Groups Projects
Commit 11f13631 authored by Pau Miquel's avatar Pau Miquel Committed by Pere Mato
Browse files

added section creating notebooks

parent 6185b6ec
Branches
Tags
No related merge requests found
......@@ -161,15 +161,13 @@ void FilterClass()
// Source file.
if (gSource) {
size_t spos = 0;
while (fgets(gLine,255,f)) {
gLineString = gLine;
if (gInMacro && gLineString.find("End_Macro") != string::npos) {
if (gLineString.find("End_Macro") != string::npos) {
ReplaceAll(gLineString,"End_Macro","");
gImageSource = false;
gInMacro = 0;
spos = 0;
if (m) {
fclose(m);
m = 0;
......@@ -182,7 +180,6 @@ void FilterClass()
}
if (gInMacro) {
if (spos) gLineString = gLineString.substr(spos);
if (gInMacro == 1) {
if (EndsWith(gLineString,".C\n") || (gLineString.find(".C(") != string::npos)) {
ExecuteMacro();
......@@ -214,27 +211,14 @@ void FilterClass()
}
}
if (gLineString.find("Begin_Macro") != string::npos &&
gLineString.find("End_Macro") == string::npos) {
if (BeginsWith(gLineString, "///")) {
spos = gLineString.find_first_not_of(' ', 3);
}
if (gLineString.find("Begin_Macro") != string::npos) {
if (gLineString.find("source") != string::npos) gImageSource = true;
gImageID++;
gInMacro++;
gLineString = "\n";
}
size_t l = gLineString.length();
size_t b = 0;
do {
size_t e = gLineString.find('\n', b);
if (e != string::npos) e++;
if (spos) printf("%-*s%s", (int)spos, "///",
gLineString.substr(b, e - b).c_str());
else printf("%s", gLineString.substr(b, e - b).c_str());
b = e;
} while (b < l);
printf("%s",gLineString.c_str());
}
fclose(f);
return;
......@@ -298,6 +282,12 @@ void FilterTutorial()
m = fopen(StringFormat("%s/macros/%s",gOutDir.c_str(),gMacroName.c_str()).c_str(), "w");
ReplaceAll(gLineString, "\\macro_code", StringFormat("\\include %s",gMacroName.c_str()));
}
// notebook found
if (gLineString.find("\\notebook") != string::npos) {
ExecuteCommand(StringFormat("python converttonotebook.py %s %s/notebooks/",
gFileName.c_str(), gOutDir.c_str()));
}
// \macro_output found
if (gLineString.find("\\macro_output") != string::npos) {
......@@ -353,8 +343,7 @@ void GetClassName()
if (gSource) {
while (fgets(gLine,255,f)) {
gLineString = gLine;
if (gLineString.find("ClassImp") != string::npos ||
gLineString.find("NamespaceImp") != string::npos) {
if (gLineString.find("ClassImp") != string::npos) {
i1 = gLineString.find("(")+1;
i2 = gLineString.find(")")-1;
gClassName = gLineString.substr(i1,i2-i1+1);
......@@ -386,8 +375,12 @@ void ExecuteMacro()
gMacroName = gLineString.substr(i1,i2-i1+1);
// Build the ROOT command to be executed.
bool ts = false;
if (BeginsWith(gLineString,"///")) ts = true;
if (ts) ReplaceAll(gLineString,"///", "");
if (ts) ReplaceAll(gLineString," ", "");
gLineString.insert(0, StringFormat("root -l -b -q \"makeimage.C(\\\""));
size_t l = gLineString.length();
int l = gLineString.length();
gLineString.replace(l-1,1,StringFormat("\\\",\\\"%s\\\",\\\"%s\\\",true,false)\"", gImageName.c_str(), gOutDir.c_str()));
// Execute the macro
......@@ -395,9 +388,11 @@ void ExecuteMacro()
// Inline the directives to show the picture and/or the code
if (gImageSource) {
gLineString = StringFormat("\\include %s\n\\image html pict1_%s\n", gMacroName.c_str(), gImageName.c_str());
if (ts) gLineString = StringFormat("/// \\include %s\n/// \\image html pict1_%s\n", gMacroName.c_str(), gImageName.c_str());
else gLineString = StringFormat("\\include %s\n\\image html pict1_%s\n", gMacroName.c_str(), gImageName.c_str());
} else {
gLineString = StringFormat("\n\\image html pict1_%s\n", gImageName.c_str());
if (ts) gLineString = StringFormat("\n/// \\image html pict1_%s\n", gImageName.c_str());
else gLineString = StringFormat("\n\\image html pict1_%s\n", gImageName.c_str());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment