Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2012-2023 The plumed team 3 : (see the PEOPLE file at the root of the distribution for a list of names) 4 : 5 : See http://www.plumed.org for more information. 6 : 7 : This file is part of plumed, version 2. 8 : 9 : plumed is free software: you can redistribute it and/or modify 10 : it under the terms of the GNU Lesser General Public License as published by 11 : the Free Software Foundation, either version 3 of the License, or 12 : (at your option) any later version. 13 : 14 : plumed is distributed in the hope that it will be useful, 15 : but WITHOUT ANY WARRANTY; without even the implied warranty of 16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 : GNU Lesser General Public License for more details. 18 : 19 : You should have received a copy of the GNU Lesser General Public License 20 : along with plumed. If not, see <http://www.gnu.org/licenses/>. 21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ 22 : #include "CLTool.h" 23 : #include "core/CLToolRegister.h" 24 : #include "tools/Tools.h" 25 : #include "config/Config.h" 26 : #include "core/ActionRegister.h" 27 : #include <cstdio> 28 : #include <string> 29 : #include <iostream> 30 : 31 : namespace PLMD { 32 : namespace cltools { 33 : 34 : //+PLUMEDOC TOOLS manual 35 : /* 36 : manual is a tool that you can use to construct the manual page for a particular action 37 : 38 : The manual constructed by this action is in html. In all probability you will never need to use this 39 : tool. However, it is was within the scripts that generate the old html manual for PLUMED. 40 : 41 : WE WILL POSSIBILY DELETE THIS COMMAND SOON AS IT IS NO LONGER USED TO CONSTRUCT THE MANUAL 42 : 43 : ## Examples 44 : 45 : The following generates the html manual for the action DISTANCE. 46 : 47 : ```plumed 48 : plumed manual --action DISTANCE 49 : ``` 50 : 51 : */ 52 : //+ENDPLUMEDOC 53 : 54 : class Manual: 55 : public CLTool { 56 : public: 57 : static void registerKeywords( Keywords& keys ); 58 : explicit Manual(const CLToolOptions& co ); 59 : int main(FILE* in, FILE*out,Communicator& pc) override; 60 5 : std::string description()const override { 61 5 : return "print out a description of the keywords for an action in html"; 62 : } 63 : }; 64 : 65 16701 : PLUMED_REGISTER_CLTOOL(Manual,"manual") 66 : 67 5418 : void Manual::registerKeywords( Keywords& keys ) { 68 5418 : CLTool::registerKeywords( keys ); 69 5418 : keys.add("compulsory","--action","print the manual for this particular action"); 70 5418 : keys.addFlag("--vim",false,"print the keywords in vim syntax"); 71 5418 : keys.addFlag("--spelling",false,"print a list of the keywords and component names for the spell checker"); 72 5418 : } 73 : 74 447 : Manual::Manual(const CLToolOptions& co ): 75 447 : CLTool(co) { 76 447 : inputdata=commandline; 77 447 : } 78 : 79 442 : int Manual::main(FILE* in, FILE*out,Communicator& pc) { 80 : 81 : std::string action; 82 884 : if( !parse("--action",action) ) { 83 : return 1; 84 : } 85 442 : std::cerr<<"LIST OF DOCUMENTED ACTIONS:\n"; 86 442 : std::cerr<<actionRegister()<<"\n"; 87 442 : std::cerr<<"LIST OF DOCUMENTED COMMAND LINE TOOLS:\n"; 88 442 : std::cerr<<cltoolRegister()<<"\n\n"; 89 : bool vimout; 90 442 : parseFlag("--vim",vimout); 91 : bool spellout; 92 442 : parseFlag("--spelling",spellout); 93 442 : if( vimout && spellout ) { 94 0 : error("can only use one of --vim and --spelling at a time"); 95 : } 96 442 : if( !actionRegister().printManual(action,vimout,spellout) && !cltoolRegister().printManual(action,spellout) ) { 97 1 : std::fprintf(stderr,"specified action is not registered\n"); 98 : return 1; 99 : } 100 : 101 : return 0; 102 : } 103 : 104 : } // End of namespace 105 : }