Dynamically add documentation section specified in documented script.

Modify CPackDeb and CPackRPM as an example
This commit is contained in:
Eric NOULARD 2012-02-18 22:07:39 +01:00
parent bfbb575086
commit a6bce55aef
5 changed files with 25 additions and 9 deletions

View File

@ -1,4 +1,4 @@
##section Variables specific to a CPack generator ##section Variables specific to CPack Debian (DEB) generator
##end ##end
##module ##module
# - The builtin (binary) CPack Deb generator (Unix only) # - The builtin (binary) CPack Deb generator (Unix only)

View File

@ -1,4 +1,4 @@
##section Variables specific to a CPack generator ##section Variables specific to CPack RPM generator
##end ##end
##module ##module
# - The builtin (binary) CPack RPM generator (Unix only) # - The builtin (binary) CPack RPM generator (Unix only)

View File

@ -514,7 +514,6 @@ int main (int argc, char *argv[])
if ( help ) if ( help )
{ {
// Construct and print requested documentation. // Construct and print requested documentation.
std::vector<cmDocumentationEntry> variables;
doc.SetName("cpack"); doc.SetName("cpack");
doc.SetSection("Name",cmDocumentationName); doc.SetSection("Name",cmDocumentationName);
@ -545,7 +544,7 @@ int main (int argc, char *argv[])
{ {
doc.GetStructuredDocFromFile( doc.GetStructuredDocFromFile(
(docedIt->first).c_str(), (docedIt->first).c_str(),
commands,&cminst,(docedIt->second).c_str()); commands,&cminst);
} }
std::map<std::string,cmDocumentationSection *> propDocs; std::map<std::string,cmDocumentationSection *> propDocs;

View File

@ -745,6 +745,18 @@ void cmDocumentation::addCPackStandardDocSections()
"Variables specific to a CPack generator"); "Variables specific to a CPack generator");
} }
void cmDocumentation::addAutomaticVariableSections(const std::string& section)
{
std::vector<std::string>::iterator it;
it = find(this->VariableSections.begin(),
this->VariableSections.end(),
section);
/* if the section does not exist then add it */
if (it==this->VariableSections.end())
{
this->VariableSections.push_back(section);
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int cmDocumentation::getDocumentedModulesListInDir( int cmDocumentation::getDocumentedModulesListInDir(
std::string path, std::string path,
@ -818,8 +830,7 @@ static void trim(std::string& s)
int cmDocumentation::GetStructuredDocFromFile( int cmDocumentation::GetStructuredDocFromFile(
const char* fname, const char* fname,
std::vector<cmDocumentationEntry>& commands, std::vector<cmDocumentationEntry>& commands,
cmake* cm, cmake* cm)
const char *docSection)
{ {
typedef enum sdoce { typedef enum sdoce {
SDOC_NONE, SDOC_MODULE, SDOC_MACRO, SDOC_FUNCTION, SDOC_VARIABLE, SDOC_NONE, SDOC_MODULE, SDOC_MACRO, SDOC_FUNCTION, SDOC_VARIABLE,
@ -835,6 +846,7 @@ int cmDocumentation::GetStructuredDocFromFile(
{ {
return nbDocItemFound; return nbDocItemFound;
} }
std::string section;
std::string name; std::string name;
std::string full; std::string full;
std::string brief; std::string brief;
@ -886,6 +898,8 @@ int cmDocumentation::GetStructuredDocFromFile(
{ {
docCtxIdx++; docCtxIdx++;
docContextStack[docCtxIdx]=SDOC_SECTION; docContextStack[docCtxIdx]=SDOC_SECTION;
// 10 is the size of '##section' + 1
section = line.substr(10,std::string::npos);
/* drop the rest of the line */ /* drop the rest of the line */
line = ""; line = "";
newCtx = true; newCtx = true;
@ -900,11 +914,12 @@ int cmDocumentation::GetStructuredDocFromFile(
brief.c_str(),full.c_str())); brief.c_str(),full.c_str()));
break; break;
case SDOC_VARIABLE: case SDOC_VARIABLE:
this->addAutomaticVariableSections(section);
cm->DefineProperty cm->DefineProperty
(name.c_str(), cmProperty::VARIABLE, (name.c_str(), cmProperty::VARIABLE,
brief.c_str(), brief.c_str(),
full.c_str(),false, full.c_str(),false,
docSection); section.c_str());
break; break;
case SDOC_MODULE: case SDOC_MODULE:
/* not implemented */ /* not implemented */

View File

@ -147,6 +147,9 @@ public:
/** Add the CPack standard documentation section(s) */ /** Add the CPack standard documentation section(s) */
void addCPackStandardDocSections(); void addCPackStandardDocSections();
/** Add automatic variables sections */
void addAutomaticVariableSections(const std::string& section);
/** /**
* Retrieve the list of documented module located in * Retrieve the list of documented module located in
* path which match the globing expression globExpr. * path which match the globing expression globExpr.
@ -185,8 +188,7 @@ public:
*/ */
int GetStructuredDocFromFile(const char* fname, int GetStructuredDocFromFile(const char* fname,
std::vector<cmDocumentationEntry>& commands, std::vector<cmDocumentationEntry>& commands,
cmake* cm, cmake* cm);
const char *docSection);
private: private:
void SetForm(Form f); void SetForm(Form f);
void SetDocName(const char* docname); void SetDocName(const char* docname);