Skip to content

Commit

Permalink
Added list of modules to json syntax file
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth Aneurin Tribello authored and Gareth Aneurin Tribello committed Oct 12, 2024
1 parent 973be41 commit 93e45ce
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions src/cltools/GenJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ plumed gen_json
class GenJson : public CLTool {
private:
std::string version;
void printHyperlink(std::string action );
public:
static void registerKeywords( Keywords& keys );
explicit GenJson(const CLToolOptions& co );
Expand All @@ -75,6 +76,20 @@ GenJson::GenJson(const CLToolOptions& co ):
if( config::getVersionLong().find("dev")==std::string::npos ) version="v"+config::getVersion();
}

void GenJson::printHyperlink( std::string action ) {
std::cout<<" \"hyperlink\" : \"https://www.plumed.org/doc-"<<version<<"/user-doc/html/";
std::transform(action.begin(), action.end(), action.begin(), [](unsigned char c) { return std::tolower(c); });
while(true) {
std::size_t und=action.find_first_of("_");
if( und==std::string::npos ) break;
std::string first=action.substr(0,und);
for(auto c : first ) { if( isdigit(c) ) std::cout<<c; else std::cout<<"_"<<c; }
std::cout<<"_"; action=action.substr(und+1);
}
for(auto c : action ) { if( isdigit(c) ) std::cout<<c; else std::cout<<"_"<<c; }
std::cout<<".html\","<<std::endl;
}

int GenJson::main(FILE* in, FILE*out,Communicator& pc) {
std::string line(""), actionfile; parse("--actions",actionfile);
IFile myfile; myfile.open(actionfile); bool stat;
Expand All @@ -93,23 +108,18 @@ int GenJson::main(FILE* in, FILE*out,Communicator& pc) {
// And the replicas link
std::cout<<" \"replicalink\" : \"https://www.plumed.org/doc-"<<version<<"/user-doc/html/special-replica-syntax.html\","<<std::endl;
// Get the names of all the actions
std::vector<std::string> action_names( actionRegister().getActionNames() );
std::vector<std::string> action_names( actionRegister().getActionNames() ); std::vector<std::string> allmodules;
for(unsigned i=0; i<action_names.size(); ++i) {
std::cout<<" \""<<action_names[i]<<'"'<<": {"<<std::endl; std::string action=action_names[i];
// Handle conversion of action names to links
std::cout<<" \"hyperlink\" : \"https://www.plumed.org/doc-"<<version<<"/user-doc/html/";
std::transform(action.begin(), action.end(), action.begin(), [](unsigned char c) { return std::tolower(c); });
while(true) {
std::size_t und=action.find_first_of("_");
if( und==std::string::npos ) break;
std::string first=action.substr(0,und);
for(auto c : first ) { if( isdigit(c) ) std::cout<<c; else std::cout<<"_"<<c; }
std::cout<<"_"; action=action.substr(und+1);
}
for(auto c : action ) { if( isdigit(c) ) std::cout<<c; else std::cout<<"_"<<c; }
std::cout<<".html\","<<std::endl;
printHyperlink( action );
std::cout<<" \"description\" : \""<<action_map[action_names[i]]<<"\",\n";
std::cout<<" \"module\" : \""<<getModuleMap().find(action_names[i])->second<<"\",\n";
bool found=false; std::string thismodule = getModuleMap().find(action_names[i])->second;
for(unsigned i=0; i<allmodules.size(); ++i) {
if( allmodules[i]==thismodule ) { found=true; break; }
}
if( !found ) allmodules.push_back( thismodule );
std::cout<<" \"module\" : \""<<thismodule<<"\",\n";
// Now output keyword information
Keywords keys; actionRegister().getKeywords( action_names[i], keys );
std::cout<<" \"displayname\" : \""<<keys.getDisplayName()<<"\",\n";
Expand Down Expand Up @@ -189,6 +199,18 @@ int GenJson::main(FILE* in, FILE*out,Communicator& pc) {
std::cout<<" \"link\" : \"https://www.plumed.org/doc-"<<version<<"/user-doc/html/_m_o_l_i_n_f_o.html\""<<std::endl;
}
std::cout<<" }"<<std::endl;
std::cout<<" },"<<std::endl;
std::cout<<" \"modules\" : {"<<std::endl;
std::cout<<" \""<<allmodules[0]<<"\" : { "<<std::endl;
printHyperlink( allmodules[0] );
std::cout<<" \"description\" : \"A module that will be used for something\""<<std::endl;
for(unsigned i=1; i<allmodules.size(); ++i) {
std::cout<<" },"<<std::endl;
std::cout<<" \""<<allmodules[i]<<"\" : { "<<std::endl;
printHyperlink( allmodules[i] );
std::cout<<" \"description\" : \"A module that will be used for something\""<<std::endl;
}
std::cout<<" }"<<std::endl;
std::cout<<" }"<<std::endl;
std::cout<<"}"<<std::endl;
return 0;
Expand Down

1 comment on commit 93e45ce

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found broken examples in automatic/ANGLES.tmp
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/CAVITY.tmp
Found broken examples in automatic/CLASSICAL_MDS.tmp
Found broken examples in automatic/CLUSTER_DIAMETER.tmp
Found broken examples in automatic/CLUSTER_DISTRIBUTION.tmp
Found broken examples in automatic/CLUSTER_PROPERTIES.tmp
Found broken examples in automatic/CONSTANT.tmp
Found broken examples in automatic/CONTACT_MATRIX.tmp
Found broken examples in automatic/CONTACT_MATRIX_PROPER.tmp
Found broken examples in automatic/CONVERT_TO_FES.tmp
Found broken examples in automatic/COORDINATIONNUMBER.tmp
Found broken examples in automatic/DFSCLUSTERING.tmp
Found broken examples in automatic/DISTANCE_FROM_CONTOUR.tmp
Found broken examples in automatic/DUMPCUBE.tmp
Found broken examples in automatic/DUMPGRID.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FIND_CONTOUR.tmp
Found broken examples in automatic/FIND_CONTOUR_SURFACE.tmp
Found broken examples in automatic/FIND_SPHERICAL_CONTOUR.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/GPROPERTYMAP.tmp
Found broken examples in automatic/HBOND_MATRIX.tmp
Found broken examples in automatic/HISTOGRAM.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/INCYLINDER.tmp
Found broken examples in automatic/INENVELOPE.tmp
Found broken examples in automatic/INTERPOLATE_GRID.tmp
Found broken examples in automatic/LOCAL_AVERAGE.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/METATENSOR.tmp
Found broken examples in automatic/MULTICOLVARDENS.tmp
Found broken examples in automatic/OUTPUT_CLUSTER.tmp
Found broken examples in automatic/PAMM.tmp
Found broken examples in automatic/PCA.tmp
Found broken examples in automatic/PCAVARS.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in automatic/PYCVINTERFACE.tmp
Found broken examples in automatic/PYTHONFUNCTION.tmp
Found broken examples in automatic/Q3.tmp
Found broken examples in automatic/Q4.tmp
Found broken examples in automatic/Q6.tmp
Found broken examples in automatic/QUATERNION.tmp
Found broken examples in automatic/REWEIGHT_BIAS.tmp
Found broken examples in automatic/REWEIGHT_METAD.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_LINEAR_PROJ.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_MAHA_DIST.tmp
Found broken examples in automatic/SPRINT.tmp
Found broken examples in automatic/TETRAHEDRALPORE.tmp
Found broken examples in automatic/TORSIONS.tmp
Found broken examples in automatic/WHAM_HISTOGRAM.tmp
Found broken examples in automatic/WHAM_WEIGHTS.tmp
Found broken examples in AnalysisPP.md
Found broken examples in CollectiveVariablesPP.md
Found broken examples in MiscelaneousPP.md

Please sign in to comment.