106void ReplaceAll(
string&,
const string&,
const string&);
108bool EndsWith(
string const &,
string const &);
139int main(
int argc,
char *argv[])
164 gOutDir = std::getenv(
"DOXYGEN_OUTPUT_DIRECTORY");
168 gSourceDir = std::getenv(
"DOXYGEN_SOURCE_DIRECTORY");
189 while (fgets(
gLine,255,
f)) {
191 if (
gLineString.find(
"\\pythondoc") != string::npos) {
197 "\\brief \\parblock \\endparblock\n"
200 "<summary style=\"font-size:20px; color: #425788;\">\n"
201 "<b>Python interface</b></summary>\n"
202 "<div class=\"pyrootbox\">\n"
204 "\\ingroup Pythonizations", class_name.c_str());
206 if (
gLineString.find(
"\\endpythondoc") != string::npos)
223 while (fgets(
gLine,255,
f)) {
234 while (fgets(
gLine,255,
f)) {
245 StringFormat(
"root -b -q \"makeimage.C+O(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",true,false)\"",
252 FILE *
f = fopen(
"ImagesSizes.dat",
"r");
254 if (fscanf(
f,
"%d", &ImageSize) == 1) {
261 remove(
"ImagesSizes.dat");
297 if (
gLineString.find(
"Begin_Macro") != string::npos &&
305 }
else if (
gLineString.find(
"svg") != string::npos) {
312 if (wpos1 != string::npos) {
313 int wpos2 =
gLineString.find_first_of(
"\"", wpos1+1);
327 if (
e != string::npos)
e++;
328 if (spos)
printf(
"%-*s%s", (
int)spos,
"///",
339 while (fgets(
gLine,255,
f)) {
363 StringFormat(
"root -q \"makeimage.C+O(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,false)\"",
367 StringFormat(
"root -b -q \"makeimage.C+O(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,false)\"",
381 std::ofstream worklist_py(
"tutorialWorklist_py", ios_base::app);
383 std::ofstream worklist_root(
"tutorialWorklist_root", ios_base::app);
388 int showTutSource = 0;
404 FILE *cn = fopen(
"CleanNamespaces.sh",
"a");
409 fprintf(cn,
"./modifyNamespacesWebpage.sh %s\n",
name.c_str());
414 while (fgets(
gLine,255,
f)) {
418 if (
gLineString.find(
"\\macro_image") != string::npos) {
419 bool nobatch = (
gLineString.find(
"(nobatch)") != string::npos);
421 bool tcanvas_js =
false, rcanvas_js =
false;
422 int tcanvas_aclic = 0;
424 if (
gLineString.find(
"(tcanvas_js)") != string::npos) {
430 if (
gLineString.find(
"(tcanvas_jsp)") != string::npos) {
436 if (
gLineString.find(
"(rcanvas_js)") != string::npos) {
441 bool image_created_by_macro = (
gLineString.find(
".png)") != string::npos) ||
444 if (image_created_by_macro) {
447 ReplaceAll(image_name,
"///\\macro_image(",
"");
457 }
else if (tcanvas_js) {
460 int i = IN.find(
".");
461 IN.erase(i,IN.length());
465 }
else if (rcanvas_js) {
468 int i = IN.find(
".");
469 IN.erase(i,IN.length());
471 "root -b -q --web=batch \"MakeRCanvasJS.C+O(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,%d)\"",
482 if (
gLineString.find(
"\\macro_code") != string::npos) {
489 if (
gLineString.find(
"\\notebook") != string::npos) {
491 worklist_py <<
"converttonotebook.py " <<
gFileName <<
" " <<
gOutDir <<
"/notebooks/" << std::endl;
499 gLineString +=
StringFormat(
"\\htmlonly <a href=\"https://nbviewer.jupyter.org/url/root.cern/doc/master/notebooks/%s.nbconvert.ipynb\" target=\"_blank\"><img src= notebook.gif alt=\"View in nbviewer\" style=\"height:1.5em\" ></a> <a href=\"https://cern.ch/swanserver/cgi-bin/go?projurl=https://root.cern/doc/master/notebooks/%s.nbconvert.ipynb\" target=\"_blank\"><img src=\"https://swanserver.web.cern.ch/swanserver/images/badge_swan_white_150.png\" alt=\"Open in SWAN\" style=\"height:1.5em\" ></a> <br/>\\endhtmlonly \n",
gMacroName.c_str() ,
gMacroName.c_str());
503 if (
gLineString.find(
"\\preview") != string::npos) {
513 if (
gLineString.find(
"\\macro_output") != string::npos) {
523 if (
gLineString.find(
"\\author") != string::npos) {
526 if (showTutSource == 1) {
533 if (
m && showTutSource == 2) fprintf(
m,
"%s",
gLineString.c_str());
539 else printf(
"/// \\endcond \n");
581 if (
gLineString.find(
"../../..") != string::npos) {
608 int o = dup(fileno(stdout));
609 if (freopen(
gOutputName.c_str(),
"a", stdout) !=
nullptr) {
610 int i = system(command.c_str());
611 dup2(o, fileno(stdout));
622 FILE *
f = fopen(
"NumberOfImages.dat",
"r");
624 if (fscanf(
f,
"%d", &ImageNum) != 1)
627 remove(
"NumberOfImages.dat");
634void ReplaceAll(
string& str,
const string& from,
const string& to) {
635 if (from.empty())
return;
637 wsRet.reserve(str.length());
638 size_t start_pos = 0, pos;
639 while ((pos = str.find(from, start_pos)) != string::npos) {
640 wsRet += str.substr(start_pos, pos - start_pos);
642 pos += from.length();
645 wsRet += str.substr(start_pos);
653 int final_n,
n = ((
int)fmt_str.size()) * 2;
655 unique_ptr<char[]> formatted;
658 formatted.reset(
new char[
n]);
659 strcpy(&formatted[0], fmt_str.c_str());
660 va_start(ap, fmt_str);
661 final_n = vsnprintf(&formatted[0],
n, fmt_str.c_str(), ap);
663 if (final_n < 0 || final_n >=
n)
n += abs(final_n -
n + 1);
666 return string(formatted.get());
677 char evalstring[300];
678 snprintf(&evalstring[0], 300,
" \n/// \\image html pict%d_%s width=%d",
N,
name.c_str(), 10000);
679 int evallen = (
int)strlen(evalstring);
682 int vallen =
sizeof(char) * evallen *
N;
683 char *val = (
char *)
malloc(vallen);
687 FILE *
f = fopen(
"ImagesSizes.dat",
"r");
690 for (
int i = 1; i <=
N; i++){
691 if (fscanf(
f,
"%d", &ImageSize) == 1) {
694 snprintf(&val[len], vallen,
" \n## \\image html pict%d_%s width=%d", i,
name.c_str(), ImageSize);
696 snprintf(&val[len], vallen,
" \n/// \\image html pict%d_%s width=%d", i,
name.c_str(), ImageSize);
698 snprintf(&val[len], vallen,
"\\image html pict%d_%s width=%d", i,
name.c_str(), ImageSize);
700 len = (
int)strlen(val);
705 remove(
"ImagesSizes.dat");
713bool EndsWith(
string const &fullString,
string const &ending) {
714 if (fullString.length() >= ending.length()) {
715 return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
724bool BeginsWith(
const string& haystack,
const string& needle) {
725 return needle.length() <= haystack.length() && equal(needle.begin(), needle.end(), haystack.begin());
void CreateTutorialImage(bool)
Create PNG tutorial image.
bool EndsWith(string const &, string const &)
Find if a string ends with another string.
void FilterPythonBox()
Filter ROOT python box for Doxygen.
void ExecuteCommand(string)
Execute a command making sure stdout will not go in the doxygen file.
string ImagesList(string &)
Return the image list after a tutorial macro execution.
int NumberOfImages()
Get the number of images in NumberOfImages.dat after makeimage.C is executed.
void ReplaceAll(string &, const string &, const string &)
Replace all instances of a string with another string.
void ExecuteMacro()
Execute the macro in gLineString and produce the corresponding picture.
void GetClassName()
Retrieve the class name.
void FilterTutorial()
Filter ROOT tutorials for Doxygen.
string StringFormat(const string fmt_str,...)
std::string formatting like sprintf.
void FilterClass()
Filter ROOT class for Doxygen.
bool BeginsWith(const string &, const string &)
Find if a string begins with another string.
printf("Client 0: bytes recv = %d, bytes sent = %d\n", s0->GetBytesRecv(), s0->GetBytesSent())