summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cpack.cxx
diff options
context:
space:
mode:
authorEric NOULARD <eric.noulard@gmail.com>2012-02-02 00:44:21 (GMT)
committerDavid Cole <david.cole@kitware.com>2012-02-14 21:05:23 (GMT)
commit543f1adfa4a8f2f38371512ffcb8c252332acb18 (patch)
tree8cccca965044622c799f5a147356744fb405cb85 /Source/CPack/cpack.cxx
parentcdbd1a9e39e79fe2f29dff3c3a7b9cf9c9fae3cc (diff)
downloadCMake-543f1adfa4a8f2f38371512ffcb8c252332acb18.zip
CMake-543f1adfa4a8f2f38371512ffcb8c252332acb18.tar.gz
CMake-543f1adfa4a8f2f38371512ffcb8c252332acb18.tar.bz2
Make the load of script documentation more efficient and dynamic.
CPack help will be searched in any CPack*.cmake file located near to CPack.cmake file. The script files is parsed iff the first line begin with ##section. Moreover the documentation section name is specified on the remaining part of the line minus the space immediately following ##section.
Diffstat (limited to 'Source/CPack/cpack.cxx')
-rw-r--r--Source/CPack/cpack.cxx60
1 files changed, 47 insertions, 13 deletions
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 4117971..25a72fa 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -26,6 +26,8 @@
#include "cmCPackLog.h"
#include <cmsys/CommandLineArguments.hxx>
+#include <cmsys/Glob.hxx>
+#include <cmsys/SystemTools.hxx>
#include <memory> // auto_ptr
//----------------------------------------------------------------------------
@@ -527,22 +529,54 @@ int main (int argc, char *argv[])
typedef std::pair<std::string,std::string> docModuleSectionPair_t;
typedef std::list<docModuleSectionPair_t> docedModulesList_t;
- docedModulesList_t docedModList;
+ docedModulesList_t docedModList;
docModuleSectionPair_t docPair;
std::string docedFile;
- // build the list of files to be parsed for documentation
- // extraction
- docPair.first = "CPack.cmake";
- docPair.second = "Variables common to all CPack generators";
- docedModList.push_back(docPair);
- docPair.first = "CPackComponent.cmake";
- docedModList.push_back(docPair);
- docPair.first = "CPackRPM.cmake";
- docPair.second = "Variables specific to a CPack generator";
- docedModList.push_back(docPair);
- docPair.first = "CPackDeb.cmake";
- docedModList.push_back(docPair);
+ cmsys::Glob gl;
+ std::string findExpr;
+ std::vector<std::string> files;
+ std::string line;
+ docedFile = globalMF->GetModulesFile("CPack.cmake");
+ if (docedFile.length()!=0)
+ {
+ findExpr += cmSystemTools::GetFilenamePath(docedFile.c_str());
+ findExpr += "/CPack*.cmake";
+ 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());
+ if (!fin) continue;
+ if (cmSystemTools::GetLineFromStream(fin, line))
+ {
+ if (line.find("##section")!=std::string::npos)
+ {
+ docPair.first = cmSystemTools::GetFilenameName(*itf);
+ // 10 is the size of '##section' + 1
+ docPair.second = line.substr(10,std::string::npos);
+ docedModList.push_back(docPair);
+ }
+ }
+ else
+ {
+ line.clear();
+ }
+ }
+ }
+ else
+ {
+ // build the list of files to be parsed for documentation
+ // extraction
+ docPair.first = "CPack.cmake";
+ docPair.second = "Variables common to all CPack generators";
+ docedModList.push_back(docPair);
+ docPair.first = "CPackComponent.cmake";
+ docedModList.push_back(docPair);
+ }
+ }
// parse the files for documentation.
for (docedModulesList_t::iterator it = docedModList.begin();