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.
This commit is contained in:
Eric NOULARD
2012-02-04 12:15:57 +01:00
committed by David Cole
parent 24fbc28e5f
commit 02ccb3291b
3 changed files with 99 additions and 56 deletions

View File

@@ -26,7 +26,6 @@
#include "cmCPackLog.h"
#include <cmsys/CommandLineArguments.hxx>
#include <cmsys/Glob.hxx>
#include <cmsys/SystemTools.hxx>
#include <memory> // auto_ptr
@@ -527,68 +526,26 @@ int main (int argc, char *argv[])
std::vector<cmDocumentationEntry> commands;
typedef std::pair<std::string,std::string> docModuleSectionPair_t;
typedef std::list<docModuleSectionPair_t> docedModulesList_t;
docedModulesList_t docedModList;
docModuleSectionPair_t docPair;
std::string docedFile;
std::string docedFile;
std::string docPath;
cmDocumentation::documentedModulesList_t docedModList;
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);
}
docPath = cmSystemTools::GetFilenamePath(docedFile.c_str());
doc.getDocumentedModulesListInDir(docPath,"CPack*.cmake",docedModList);
}
// parse the files for documentation.
for (docedModulesList_t::iterator it = docedModList.begin();
it!= docedModList.end(); ++it)
cmDocumentation::documentedModulesList_t::iterator docedIt;
for (docedIt = docedModList.begin();
docedIt!= docedModList.end(); ++docedIt)
{
docedFile = globalMF->GetModulesFile((it->first).c_str());
if (docedFile.length()!=0)
{
doc.GetStructuredDocFromFile(docedFile.c_str(),
commands,&cminst,(it->second).c_str());
}
}
doc.GetStructuredDocFromFile(
(docedIt->first).c_str(),
commands,&cminst,(docedIt->second).c_str());
}
std::map<std::string,cmDocumentationSection *> propDocs;
cminst.GetPropertiesDocumentation(propDocs);