From bf0dce4252ab5ec470d97d139e6a5df2b65043f6 Mon Sep 17 00:00:00 2001 From: Gareth Tribello <gareth.tribello@gmail.com> Date: Fri, 14 Dec 2018 20:46:07 +0000 Subject: [PATCH] Added functionality to output keywords in a form that the spell checker can use --- src/core/ActionRegister.cpp | 4 +++- src/core/ActionRegister.h | 2 +- src/core/CLToolRegister.cpp | 7 +++++-- src/core/CLToolRegister.h | 2 +- src/tools/Keywords.cpp | 5 +++++ src/tools/Keywords.h | 2 ++ user-doc/.gitignore | 1 + 7 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/core/ActionRegister.cpp b/src/core/ActionRegister.cpp index aff321fd4..b68527d48 100644 --- a/src/core/ActionRegister.cpp +++ b/src/core/ActionRegister.cpp @@ -85,11 +85,13 @@ std::unique_ptr<Action> ActionRegister::create(const ActionOptions&ao) { return action; } -bool ActionRegister::printManual( const std::string& action, const bool& vimout ) { +bool ActionRegister::printManual( const std::string& action, const bool& vimout, const bool& spellout ) { if ( check(action) ) { Keywords keys; mk[action](keys); if( vimout ) { printf("%s",action.c_str()); keys.print_vim(); printf("\n"); + } else if( spellout ) { + keys.print_spelling(); } else { keys.print_html(); } diff --git a/src/core/ActionRegister.h b/src/core/ActionRegister.h index 475d73e25..8c508bfeb 100644 --- a/src/core/ActionRegister.h +++ b/src/core/ActionRegister.h @@ -68,7 +68,7 @@ public: /// \param ao object containing information for initialization, such as the full input line, a pointer to PlumedMain, etc std::unique_ptr<Action> create(const ActionOptions&ao); /// Print out the keywords for an action in html/vim ready for input into the manual - bool printManual(const std::string& action, const bool& vimout); + bool printManual(const std::string& action, const bool& vimout, const bool& spellout); /// Print out a template command for an action bool printTemplate(const std::string& action, bool include_optional); void remove(creator_pointer); diff --git a/src/core/CLToolRegister.cpp b/src/core/CLToolRegister.cpp index 4a7f740dd..2bc3f3b10 100644 --- a/src/core/CLToolRegister.cpp +++ b/src/core/CLToolRegister.cpp @@ -92,8 +92,11 @@ std::ostream & operator<<(std::ostream &log,const CLToolRegister&ar) { return log; } -bool CLToolRegister::printManual( const std::string& cltool ) { - if ( check(cltool) ) { +bool CLToolRegister::printManual( const std::string& cltool, const bool& spelling ) { + if( spelling && check(cltool) ) { + mk[cltool].print_spelling(); + return true; + } else if ( check(cltool) ) { mk[cltool].print_html(); return true; } else { diff --git a/src/core/CLToolRegister.h b/src/core/CLToolRegister.h index d03f0338c..4e3197a53 100644 --- a/src/core/CLToolRegister.h +++ b/src/core/CLToolRegister.h @@ -65,7 +65,7 @@ public: /// Returns a list of the allowed CLTools std::vector<std::string> list()const; /// Print out the instructions for using the tool in html ready for input into the manual - bool printManual(const std::string& cltool); + bool printManual(const std::string& cltool,const bool& spelling); /// Return all the keys of this cltool std::vector<std::string> getKeys(const std::string& cltool)const; }; diff --git a/src/tools/Keywords.cpp b/src/tools/Keywords.cpp index 267863809..ac8b5cdc5 100644 --- a/src/tools/Keywords.cpp +++ b/src/tools/Keywords.cpp @@ -447,6 +447,11 @@ void Keywords::print_html() const { std::cout<<"</table>\n\n"; } +void Keywords::print_spelling() const { + for(unsigned i=0; i<keys.size(); ++i) printf("%s\n", keys[i].c_str() ); + for(unsigned i=0; i<cnames.size(); ++i) printf("%s\n",cnames[i].c_str() ); +} + void Keywords::print( FILE* out ) const { unsigned nkeys=0; for(unsigned i=0; i<keys.size(); ++i) { diff --git a/src/tools/Keywords.h b/src/tools/Keywords.h index a94cfe6c4..5af9caa18 100644 --- a/src/tools/Keywords.h +++ b/src/tools/Keywords.h @@ -113,6 +113,8 @@ public: void print( Log& log ) const ; /// Print the documentation to a file (use by PLUMED::CLTool::readCommandLineArgs) void print( FILE* out ) const ; +/// Print a file containing the list of keywords for a particular action (used for spell checking) + void print_spelling() const ; /// Reserve a keyword void reserve( const std::string & t, const std::string & k, const std::string & d ); /// Reserve a flag diff --git a/user-doc/.gitignore b/user-doc/.gitignore index a187357cd..139073b02 100644 --- a/user-doc/.gitignore +++ b/user-doc/.gitignore @@ -10,4 +10,5 @@ /*doc* /manual.pdf /regtests +/spelling -- GitLab