Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 29, 2024
1 parent c95886c commit d555ed6
Showing 1 changed file with 54 additions and 58 deletions.
112 changes: 54 additions & 58 deletions macros/REST_ListMacros.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,36 @@ using namespace std;
//*** Lists all the official macros together with its documentation
//***
//*******************************************************************************************************
Int_t REST_ListMacros( int details = 0, std::string onlyThisMacro = "") {
Int_t REST_ListMacros(int details = 0, std::string onlyThisMacro = "") {
string macrosPath = (string)getenv("REST_PATH") + "/macros";
vector<string> directories = TRestTools::GetSubdirectories(macrosPath);

cout << endl;
cout << "Entering directory : " << macrosPath << endl;
vector<string> main_files = TRestTools::GetFilesMatchingPattern(macrosPath + "/REST_*.C");
if( details )
{
for (int m = 0; m < main_files.size(); m++) {
std::string macro = TRestTools::SeparatePathAndName(main_files[m]).second;
if( !onlyThisMacro.empty() && onlyThisMacro != macro )
continue;
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << " ++ "
<< " Macro : " << macro << endl;
std::ifstream t(main_files[m]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
if (details) {
for (int m = 0; m < main_files.size(); m++) {
std::string macro = TRestTools::SeparatePathAndName(main_files[m]).second;
if (!onlyThisMacro.empty() && onlyThisMacro != macro) continue;
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << " ++ "
<< " Macro : " << macro << endl;
std::ifstream t(main_files[m]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());

std::vector<string> lines = REST_StringHelper::Split(str, "\n");
std::vector<string> lines = REST_StringHelper::Split(str, "\n");

cout << " ++ " << endl;
for (int l = 0; l < lines.size(); l++)
if (lines[l].find("//*** ") != string::npos)
cout << " ++ " << lines[l].substr(6, -1) << endl;
cout << " ++ " << endl;
}
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
}
else
{
for (int m = 0; m < main_files.size(); m++) {
cout << " + " << TRestTools::SeparatePathAndName(main_files[m]).second << endl;
}
cout << " ++ " << endl;
for (int l = 0; l < lines.size(); l++)
if (lines[l].find("//*** ") != string::npos)
cout << " ++ " << lines[l].substr(6, -1) << endl;
cout << " ++ " << endl;
}
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
} else {
for (int m = 0; m < main_files.size(); m++) {
cout << " + " << TRestTools::SeparatePathAndName(main_files[m]).second << endl;
}
}

for (int n = 0; n < directories.size(); n++) {
Expand All @@ -56,40 +52,40 @@ Int_t REST_ListMacros( int details = 0, std::string onlyThisMacro = "") {
if (directories[n].find("/macros/mac/") != string::npos) continue;
vector<string> files = TRestTools::GetFilesMatchingPattern(directories[n] + "/REST_*.C");

if( details )
{
for (int m = 0; m < files.size(); m++) {
std::string macro = TRestTools::SeparatePathAndName(files[m]).second;
if( !onlyThisMacro.empty() && onlyThisMacro != macro )
continue;
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << " ++ Macro : " << macro << endl;
std::ifstream t(files[m]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
if (details) {
for (int m = 0; m < files.size(); m++) {
std::string macro = TRestTools::SeparatePathAndName(files[m]).second;
if (!onlyThisMacro.empty() && onlyThisMacro != macro) continue;
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
<< endl;
cout << " ++ Macro : " << macro << endl;
std::ifstream t(files[m]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());

std::vector<string> lines = REST_StringHelper::Split(str, "\n");
std::vector<string> lines = REST_StringHelper::Split(str, "\n");

cout << " ++ " << endl;
for (int l = 0; l < lines.size(); l++)
if (lines[l].find("//*** ") != string::npos)
cout << " ++ " << lines[l].substr(6, -1) << endl;
cout << " ++ " << endl;
}
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
}
else
{
for (int m = 0; m < files.size(); m++) {
cout << " + " << TRestTools::SeparatePathAndName(files[m]).second << endl;
}
std::cout << std::endl;
std::cout << " ------- " << std::endl;
std::cout << "IMPORTANT. To get a more detailed macro documentation enable the details argument:" << std::endl;
std::cout << "Execute: restListMacros 1" << std::endl;
std::cout << "OR if you want to show only the documentation of a given macro, add the macro.C filename as argument" << std::endl;
std::cout << "Execute: restListMacros 1 REST_CheckValidRuns.C" << std::endl;
std::cout << " ------- " << std::endl;
}
cout << " ++ " << endl;
for (int l = 0; l < lines.size(); l++)
if (lines[l].find("//*** ") != string::npos)
cout << " ++ " << lines[l].substr(6, -1) << endl;
cout << " ++ " << endl;
}
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
} else {
for (int m = 0; m < files.size(); m++) {
cout << " + " << TRestTools::SeparatePathAndName(files[m]).second << endl;
}
std::cout << std::endl;
std::cout << " ------- " << std::endl;
std::cout << "IMPORTANT. To get a more detailed macro documentation enable the details argument:"
<< std::endl;
std::cout << "Execute: restListMacros 1" << std::endl;
std::cout << "OR if you want to show only the documentation of a given macro, add the macro.C "
"filename as argument"
<< std::endl;
std::cout << "Execute: restListMacros 1 REST_CheckValidRuns.C" << std::endl;
std::cout << " ------- " << std::endl;
}
}
return 0;
}

0 comments on commit d555ed6

Please sign in to comment.