diff options
author | Eric NOULARD <eric.noulard@gmail.com> | 2012-02-04 11:15:57 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2012-02-14 21:05:23 (GMT) |
commit | 02ccb3291bd1053df30600211b0ceefbb7fea00f (patch) | |
tree | 1687be1cb35110d1553548787a82fac5346ecbec /Source/cmDocumentation.cxx | |
parent | 24fbc28e5f81823661853be0c0acdf2670b3453e (diff) | |
download | CMake-02ccb3291bd1053df30600211b0ceefbb7fea00f.zip CMake-02ccb3291bd1053df30600211b0ceefbb7fea00f.tar.gz CMake-02ccb3291bd1053df30600211b0ceefbb7fea00f.tar.bz2 |
Create getDocumentedModulesListInDir which may be used in other context.
This should makes it easier to use the same "documented module"
techniques for CTest, CMake or user module.
Diffstat (limited to 'Source/cmDocumentation.cxx')
-rw-r--r-- | Source/cmDocumentation.cxx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index ed1e5e1..dde4953 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -14,6 +14,7 @@ #include "cmSystemTools.h" #include "cmVersion.h" #include <cmsys/Directory.hxx> +#include <cmsys/Glob.hxx> //---------------------------------------------------------------------------- @@ -745,6 +746,60 @@ void cmDocumentation::addCPackStandardDocSections() } //---------------------------------------------------------------------------- +int cmDocumentation::getDocumentedModulesListInDir( + std::string path, + std::string globExpr, + documentedModulesList_t& docedModuleList) +{ + cmsys::Glob gl; + std::string findExpr; + std::vector<std::string> files; + std::string line; + documentedModuleSectionPair_t docPair; + int nbDocumentedModules = 0; + + findExpr = path + "/" + globExpr; + if (gl.FindFiles(findExpr)) + { + files = gl.GetFiles(); + for (std::vector<std::string>::iterator itf=files.begin(); + itf!=files.end();++itf) + { + std::ifstream fin((*itf).c_str()); + // file access trouble ignore it (ignore this kind of error) + if (!fin) continue; + /* read first line in order to get doc section */ + if (cmSystemTools::GetLineFromStream(fin, line)) + { + /* Doc section indicates that + * this file has structured doc in it. + */ + if (line.find("##section")!=std::string::npos) + { + // ok found one more documented module + ++nbDocumentedModules; + docPair.first = *itf; + // 10 is the size of '##section' + 1 + docPair.second = line.substr(10,std::string::npos); + docedModuleList.push_back(docPair); + } + // No else if no section is found (undocumented module) + } + // No else cannot read first line (ignore this kind of error) + line.clear(); + } + } + if (nbDocumentedModules>0) + { + return 0; + } + else + { + return 1; + } +} + +//---------------------------------------------------------------------------- static void trim(std::string& s) { std::string::size_type pos = s.find_last_not_of(' '); |