Skip to content

Commit 8b3413f

Browse files
committed
Implement \macro_output.
Still to be checked: the macro code and macro output appear in the reverse order compare to the one in the tutorial macro.
1 parent 2e458f1 commit 8b3413f

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

tutorials/doxygen/filter.cxx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ string gFileName; // Input file name
2727
string gLineString; // Current line (as a string) in the current input file
2828
string gImageName; // Current image name
2929
string gMacroName; // Current macro name
30+
string gOutputName; // File containing std::out
3031
string gCwd; // Current working directory
3132
string gOutDir; // Output directory
3233
int gShowSource; // True if the source code should be shown
34+
int gShowOutput; // True if the output should be shown
35+
int gShowImage; // True if the image should be shown
3336

3437
////////////////////////////////////////////////////////////////////////////////
3538
/// Filter ROOT tutorials for Doxygen.
@@ -40,6 +43,8 @@ int main(int argc, char *argv[])
4043

4144
gFileName = argv[1];
4245
gShowSource = 0;
46+
gShowOutput = 0;
47+
gShowImage = 0;
4348

4449
// Retrieve the output directory
4550
gOutDir = getenv("TUTORIALS_OUTPUT_DIRECTORY");
@@ -52,30 +57,41 @@ int main(int argc, char *argv[])
5257
FILE *m = 0;
5358

5459
// Extract the macro name
55-
int i1 = gFileName.rfind('/')+1;
56-
int i2 = gFileName.rfind('C');
57-
gMacroName = gFileName.substr(i1,i2-i1+1);
60+
int i1 = gFileName.rfind('/')+1;
61+
int i2 = gFileName.rfind('C');
62+
gMacroName = gFileName.substr(i1,i2-i1+1);
63+
gImageName = StringFormat("%s.png", gMacroName.c_str()); // Image name
64+
gOutputName = StringFormat("%s.out", gMacroName.c_str()); // output name
5865

5966
// Parse the source and generate the image if needed
6067
while (fgets(gLine,255,f)) {
6168
gLineString = gLine;
6269

6370
// \macro_image found
6471
if (gLineString.find("\\macro_image") != string::npos) {
65-
gImageName = StringFormat("%s.png", gMacroName.c_str()); // Image name
6672
ExecuteCommand(StringFormat("root -l -b -q \"makeimage.cxx(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\")\"",
6773
gFileName.c_str(), gImageName.c_str(), gOutDir.c_str()));
6874
ReplaceAll(gLineString, "\\macro_image",
6975
StringFormat("\\image html %s",gImageName.c_str()));
70-
76+
gShowImage = 1;
77+
remove(gOutputName.c_str());
7178
}
7279

7380
// \macro_code found
7481
if (gLineString.find("\\macro_code") != string::npos) {
7582
gShowSource = 1;
7683
m = fopen(StringFormat("%s/html/%s",gOutDir.c_str(),gMacroName.c_str()).c_str(), "w");
7784
ReplaceAll(gLineString, "\\macro_code",
85+
StringFormat("\\include %s",gOutputName.c_str()));
86+
}
87+
88+
// \macro_output found
89+
if (gLineString.find("\\macro_output") != string::npos) {
90+
ExecuteCommand(StringFormat("root -l -b -q %s", gFileName.c_str()).c_str());
91+
rename(gOutputName.c_str(), StringFormat("%s/html/%s",gOutDir.c_str(), gOutputName.c_str()).c_str());
92+
ReplaceAll(gLineString, "\\macro_output",
7893
StringFormat("\\include %s",gMacroName.c_str()));
94+
gShowOutput = 1;
7995
}
8096

8197
// \author is the last comment line.
@@ -87,6 +103,7 @@ int main(int argc, char *argv[])
87103
if (m && gShowSource == 2) fprintf(m,"%s",gLineString.c_str());
88104
}
89105
}
106+
90107
if (m) fclose(m);
91108
fclose(f);
92109
return 0;
@@ -99,7 +116,7 @@ int main(int argc, char *argv[])
99116
void ExecuteCommand(string command)
100117
{
101118
int o = dup(fileno(stdout));
102-
freopen("stdout.dat","a",stdout);
119+
freopen(gOutputName.c_str(),"a",stdout);
103120
system(command.c_str());
104121
dup2(o,fileno(stdout));
105122
close(o);

tutorials/hist/ContourList.C

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
///
55
/// \macro_image
66
/// \macro_code
7+
/// \macro_output
78
///
89
/// \authors Josh de Bever (CSI Medical Physics Group, The University of Western Ontario, London, Ontario, Canada), Olivier Couet
910

0 commit comments

Comments
 (0)