[cmake-commits] martink committed cmDocumentation.cxx 1.59 1.60 cmDocumentation.h 1.30 1.31 cmDocumentationFormatter.h 1.4 1.5 cmDocumentationFormatterHTML.cxx 1.5 1.6 cmDocumentationSection.h 1.2 1.3 cmakemain.cxx 1.72 1.73

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Oct 24 11:36:49 EDT 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv19582/Source

Modified Files:
	cmDocumentation.cxx cmDocumentation.h 
	cmDocumentationFormatter.h cmDocumentationFormatterHTML.cxx 
	cmDocumentationSection.h cmakemain.cxx 
Log Message:
ENH: some more cleanup, fixes, and patch for HTML output


Index: cmDocumentation.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentation.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- cmDocumentation.h	22 Oct 2007 19:33:19 -0000	1.30
+++ cmDocumentation.h	24 Oct 2007 15:36:47 -0000	1.31
@@ -76,10 +76,16 @@
   /** Add the documentation to the beginning/end of the section */
   void PrependSection(const char *sectionName,
                       const char *docs[][3]);
+  void PrependSection(const char *sectionName,
+                      std::vector<cmDocumentationEntry> &docs);
+  void PrependSection(const char *sectionName,
+                      cmDocumentationEntry &docs);
   void AppendSection(const char *sectionName,
                      const char *docs[][3]);
   void AppendSection(const char *sectionName,
                      std::vector<cmDocumentationEntry> &docs);
+  void AppendSection(const char *sectionName,
+                     cmDocumentationEntry &docs);
 
   /**
    * Print documentation in the given form.  All previously added
@@ -131,11 +137,13 @@
   bool PrintDocumentationSingle(std::ostream& os);
   bool PrintDocumentationSingleModule(std::ostream& os);
   bool PrintDocumentationSingleProperty(std::ostream& os);
+  bool PrintDocumentationSingleVariable(std::ostream& os);
   bool PrintDocumentationUsage(std::ostream& os);
   bool PrintDocumentationFull(std::ostream& os);
   bool PrintDocumentationModules(std::ostream& os);
   bool PrintDocumentationCustomModules(std::ostream& os);
   bool PrintDocumentationProperties(std::ostream& os);
+  bool PrintDocumentationVariables(std::ostream& os);
   bool PrintDocumentationCurrentCommands(std::ostream& os);
   bool PrintDocumentationCompatCommands(std::ostream& os);
   void PrintDocumentationCommand(std::ostream& os,
@@ -171,7 +179,9 @@
   cmDocumentationFormatterMan ManFormatter;
   cmDocumentationFormatterText TextFormatter;
   cmDocumentationFormatterUsage UsageFormatter;
-  
+
+  std::vector<std::string> PropertySections;
+  std::vector<std::string> VariableSections;
 };
 
 #endif

Index: cmDocumentationFormatterHTML.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentationFormatterHTML.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cmDocumentationFormatterHTML.cxx	22 Oct 2007 16:48:39 -0000	1.5
+++ cmDocumentationFormatterHTML.cxx	24 Oct 2007 15:36:47 -0000	1.6
@@ -97,6 +97,21 @@
 
   const std::vector<cmDocumentationEntry> &entries = 
     section.GetEntries();
+
+  os << "<ul>\n";
+  for(std::vector<cmDocumentationEntry>::const_iterator op 
+        = entries.begin(); op != entries.end(); ++ op )
+    {
+    if(op->Name.size())
+      {
+      os << "    <li><a href=\"#command_"
+         << op->Name.c_str() << "\"><b><code>";
+      this->PrintHTMLEscapes(os, op->Name.c_str());
+      os << "</code></b></a></li>";
+      }
+    }
+  os << "</ul>\n" ;
+
   for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); 
       op != entries.end();)
     {
@@ -108,9 +123,10 @@
         os << "  <li>\n";
         if(op->Name.size())
           {
-          os << "    <b><code>";
+          os << "    <a name=\"command_"<< 
+            op->Name.c_str() << "\"><b><code>";
           this->PrintHTMLEscapes(os, op->Name.c_str());
-          os << "</code></b>: ";
+          os << "</code></b></a>: ";
           }
         this->PrintHTMLEscapes(os, op->Brief.c_str());
         if(op->Full.size())

Index: cmDocumentation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentation.cxx,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- cmDocumentation.cxx	23 Oct 2007 14:07:40 -0000	1.59
+++ cmDocumentation.cxx	24 Oct 2007 15:36:46 -0000	1.60
@@ -240,6 +240,19 @@
                                    "COMPATIBILITY COMMANDS");
   sec->Append(cmCompatCommandsDocumentationDescription);
   this->AllSections["Compatibility Commands"] = sec;  
+
+
+  this->PropertySections.push_back("Properties of Global Scope");
+  this->PropertySections.push_back("Properties on Directories");
+  this->PropertySections.push_back("Properties on Targets");
+  this->PropertySections.push_back("Properties on Tests");
+  this->PropertySections.push_back("Properties on Source Files");
+
+  this->VariableSections.push_back("Variables that Provide Information");
+  this->VariableSections.push_back("Variables That Change Behavior");
+  this->VariableSections.push_back("Variables That Describe the System");
+  this->VariableSections.push_back("Variables that Control the Build");
+  this->VariableSections.push_back("Variables for Languages");
 }
 
 //----------------------------------------------------------------------------
@@ -325,6 +338,8 @@
       return this->PrintDocumentationSingleModule(os);
     case cmDocumentation::SingleProperty:
       return this->PrintDocumentationSingleProperty(os);
+    case cmDocumentation::SingleVariable:
+      return this->PrintDocumentationSingleVariable(os);
     case cmDocumentation::List:
       this->PrintDocumentationList(os,"Commands");
       this->PrintDocumentationList(os,"Compatibility Commands");
@@ -334,11 +349,20 @@
       return true;
     case cmDocumentation::PropertyList: 
       this->PrintDocumentationList(os,"Properties Description");
-      this->PrintDocumentationList(os,"Properties of Global Scope");
-      this->PrintDocumentationList(os,"Properties on Directories");
-      this->PrintDocumentationList(os,"Properties on Targets");
-      this->PrintDocumentationList(os,"Properties on Tests");
-      this->PrintDocumentationList(os,"Properties on Source Files");
+      for (std::vector<std::string>::iterator i = 
+             this->PropertySections.begin();
+           i != this->PropertySections.end(); ++i)
+        {
+        this->PrintDocumentationList(os,i->c_str());
+        }
+      return true;
+    case cmDocumentation::VariableList: 
+      for (std::vector<std::string>::iterator i = 
+             this->VariableSections.begin();
+           i != this->VariableSections.end(); ++i)
+        {
+        this->PrintDocumentationList(os,i->c_str());
+        }
       return true;
     case cmDocumentation::Full: 
       return this->PrintDocumentationFull(os);
@@ -348,6 +372,8 @@
       return this->PrintDocumentationCustomModules(os);
     case cmDocumentation::Properties: 
       return this->PrintDocumentationProperties(os);
+    case cmDocumentation::Variables: 
+      return this->PrintDocumentationVariables(os);
     case cmDocumentation::Commands: 
       return this->PrintDocumentationCurrentCommands(os);
     case cmDocumentation::CompatCommands: 
@@ -641,6 +667,12 @@
       GET_OPT_ARGUMENT(help.Filename);
       help.HelpForm = this->GetFormFromFilename(help.Filename);
       }
+    else if(strcmp(argv[i], "--help-variables") == 0)
+      {
+      help.HelpType = cmDocumentation::Variables;
+      GET_OPT_ARGUMENT(help.Filename);
+      help.HelpForm = this->GetFormFromFilename(help.Filename);
+      }
     else if(strcmp(argv[i], "--help-modules") == 0)
       {
       help.HelpType = cmDocumentation::Modules;
@@ -705,6 +737,13 @@
       GET_OPT_ARGUMENT(help.Filename);
       help.HelpForm = this->GetFormFromFilename(help.Filename);
       }
+    else if(strcmp(argv[i], "--help-variable") == 0)
+      {
+      help.HelpType = cmDocumentation::SingleVariable;
+      GET_OPT_ARGUMENT(help.Argument);
+      GET_OPT_ARGUMENT(help.Filename);
+      help.HelpForm = this->GetFormFromFilename(help.Filename);
+      }
     else if(strcmp(argv[i], "--help-command-list") == 0)
       {
       help.HelpType = cmDocumentation::List;
@@ -723,6 +762,12 @@
       GET_OPT_ARGUMENT(help.Filename);
       help.HelpForm = cmDocumentation::TextForm;
       }
+    else if(strcmp(argv[i], "--help-variable-list") == 0)
+      {
+      help.HelpType = cmDocumentation::VariableList;
+      GET_OPT_ARGUMENT(help.Filename);
+      help.HelpForm = cmDocumentation::TextForm;
+      }
     else if(strcmp(argv[i], "--copyright") == 0)
       {
       help.HelpType = cmDocumentation::Copyright;
@@ -835,6 +880,24 @@
 }
 
 //----------------------------------------------------------------------------
+void cmDocumentation::PrependSection(const char *name, 
+                                     std::vector<cmDocumentationEntry> &docs)
+{
+  cmDocumentationSection *sec = 0;
+  if (this->AllSections.find(name) == this->AllSections.end())
+    {
+    sec = new cmDocumentationSection
+      (name, cmSystemTools::UpperCase(name).c_str());
+    this->SetSection(name,sec);
+    }
+  else
+    {
+    sec = this->AllSections[name];
+    }
+  sec->Prepend(docs);
+}
+
+//----------------------------------------------------------------------------
 void cmDocumentation::AppendSection(const char *name, 
                                     const char *docs[][3])
 {
@@ -871,6 +934,26 @@
 }
 
 //----------------------------------------------------------------------------
+void cmDocumentation::AppendSection(const char *name, 
+                                    cmDocumentationEntry &docs)
+{
+
+  std::vector<cmDocumentationEntry> docsVec;
+  docsVec.push_back(docs);
+  this->AppendSection(name,docsVec);
+}
+
+//----------------------------------------------------------------------------
+void cmDocumentation::PrependSection(const char *name, 
+                                     cmDocumentationEntry &docs)
+{
+
+  std::vector<cmDocumentationEntry> docsVec;
+  docsVec.push_back(docs);
+  this->PrependSection(name,docsVec);
+}
+
+//----------------------------------------------------------------------------
 void cmDocumentation::SetSeeAlsoList(const char *data[][3])
 {
   cmDocumentationSection *sec = 
@@ -996,31 +1079,46 @@
 //----------------------------------------------------------------------------
 bool cmDocumentation::PrintDocumentationSingleProperty(std::ostream& os)
 {
-  if (this->PrintDocumentationGeneric(os,"Properties of Global Scope"))
-    {
-    return true;
-    }
-  if (this->PrintDocumentationGeneric(os,"Properties on Directories"))
+  bool done = false;
+  for (std::vector<std::string>::iterator i = 
+         this->PropertySections.begin();
+       !done && i != this->PropertySections.end(); ++i)
     {
-    return true;
+    done = this->PrintDocumentationGeneric(os,i->c_str());
     }
-  if (this->PrintDocumentationGeneric(os,"Properties on Targets"))
+
+  if (done)
     {
     return true;
     }
-  if (this->PrintDocumentationGeneric(os,"Properties on Tests"))
+
+  // Argument was not a command.  Complain.
+  os << "Argument \"" << this->CurrentArgument.c_str()
+     << "\" to --help-property is not a CMake property.  "
+     << "Use --help-property-list to see all properties.\n";
+  return false;
+}
+
+//----------------------------------------------------------------------------
+bool cmDocumentation::PrintDocumentationSingleVariable(std::ostream& os)
+{
+  bool done = false;
+  for (std::vector<std::string>::iterator i = 
+         this->VariableSections.begin();
+       !done && i != this->VariableSections.end(); ++i)
     {
-    return true;
+    done = this->PrintDocumentationGeneric(os,i->c_str());
     }
-  if (this->PrintDocumentationGeneric(os,"Properties on Source Files"))
+
+  if (done)
     {
     return true;
     }
 
   // Argument was not a command.  Complain.
   os << "Argument \"" << this->CurrentArgument.c_str()
-     << "\" to --help-property is not a CMake property.  "
-     << "Use --help-property-list to see all properties.\n";
+     << "\" to --help-variable is not a defined variable.  "
+     << "Use --help-variable-list to see all defined variables.\n";
   return false;
 }
 
@@ -1105,11 +1203,30 @@
 {
   this->ClearSections();
   this->AddSectionToPrint("Properties Description");
-  this->AddSectionToPrint("Properties of Global Scope");
-  this->AddSectionToPrint("Properties on Directories");
-  this->AddSectionToPrint("Properties on Targets");
-  this->AddSectionToPrint("Properties on Tests");
-  this->AddSectionToPrint("Properties on Source Files");
+  for (std::vector<std::string>::iterator i = 
+         this->PropertySections.begin();
+       i != this->PropertySections.end(); ++i)
+    {
+    this->AddSectionToPrint(i->c_str());
+    }
+  this->AddSectionToPrint("Copyright");
+  this->AddSectionToPrint("Standard See Also");
+  this->CurrentFormatter->PrintHeader(this->GetNameString(), os);
+  this->Print(os);
+  this->CurrentFormatter->PrintFooter(os);
+  return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmDocumentation::PrintDocumentationVariables(std::ostream& os)
+{
+  this->ClearSections();
+  for (std::vector<std::string>::iterator i = 
+         this->VariableSections.begin();
+       i != this->VariableSections.end(); ++i)
+    {
+    this->AddSectionToPrint(i->c_str());
+    }
   this->AddSectionToPrint("Copyright");
   this->AddSectionToPrint("Standard See Also");
   this->CurrentFormatter->PrintHeader(this->GetNameString(), os);
@@ -1181,18 +1298,16 @@
   this->AddSectionToPrint("Commands");
   emitted.insert("Commands");
 
+  
   this->AddSectionToPrint("Properties Description");
   emitted.insert("Properties Description");
-  this->AddSectionToPrint("Properties of Global Scope");
-  emitted.insert("Properties of Global Scope");
-  this->AddSectionToPrint("Properties on Directories");
-  emitted.insert("Properties on Directories");
-  this->AddSectionToPrint("Properties on Targets");
-  emitted.insert("Properties on Targets");
-  this->AddSectionToPrint("Properties on Tests");
-  emitted.insert("Properties on Tests");
-  this->AddSectionToPrint("Properties on Source Files");
-  emitted.insert("Properties on Source Files");
+  for (std::vector<std::string>::iterator i = 
+         this->PropertySections.begin();
+       i != this->PropertySections.end(); ++i)
+    {
+    this->AddSectionToPrint(i->c_str());
+    emitted.insert(i->c_str());
+    }
 
   emitted.insert("Copyright");
   emitted.insert("See Also");

Index: cmakemain.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmakemain.cxx,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- cmakemain.cxx	22 Oct 2007 20:41:15 -0000	1.72
+++ cmakemain.cxx	24 Oct 2007 15:36:47 -0000	1.73
@@ -146,7 +146,7 @@
    "page, HTML and plain text."},
   {"--help-property prop [file]", 
    "Print help for a single property and exit.",
-   "Full documentation specific to the given module is displayed."
+   "Full documentation specific to the given property is displayed."
    "If a file is specified, the documentation is written into and the output "
    "format is determined depending on the filename suffix. Supported are man "
    "page, HTML and plain text."},
@@ -162,6 +162,24 @@
    "If a file is specified, the documentation is written into and the output "
    "format is determined depending on the filename suffix. Supported are man "
    "page, HTML and plain text."},
+  {"--help-variable var [file]", 
+   "Print help for a single variable and exit.",
+   "Full documentation specific to the given variable is displayed."
+   "If a file is specified, the documentation is written into and the output "
+   "format is determined depending on the filename suffix. Supported are man "
+   "page, HTML and plain text."},
+  {"--help-Variable-list [file]", "List documented variables and exit.",
+   "The list contains all variables for which help may be obtained by using "
+   "the --help-variable argument followed by a variable name.  If a file is "
+   "specified, the help is written into it."
+   "If a file is specified, the documentation is written into and the output "
+   "format is determined depending on the filename suffix. Supported are man "
+   "page, HTML and plain text."},
+  {"--help-variables [file]", "Print help for all variables and exit.",
+   "Full documentation for all variables is displayed."
+   "If a file is specified, the documentation is written into and the output "
+   "format is determined depending on the filename suffix. Supported are man "
+   "page, HTML and plain text."},
   {0,0,0}
 };
 
@@ -318,6 +336,12 @@
     doc.AppendSection("Compatibility Commands",compatCommands);
     doc.SetSections(propDocs);
 
+    cmDocumentationEntry e;
+    e.Brief = 
+      "variables defined by cmake, that give information about the project, "
+      "and cmake";
+    doc.PrependSection("Variables that Provide Information",e);
+
     doc.SetSeeAlsoList(cmDocumentationSeeAlso);
     int result = doc.PrintRequestedDocumentation(std::cout)? 0:1;
 

Index: cmDocumentationSection.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentationSection.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cmDocumentationSection.h	22 Oct 2007 19:33:19 -0000	1.2
+++ cmDocumentationSection.h	24 Oct 2007 15:36:47 -0000	1.3
@@ -59,6 +59,9 @@
 
   /** prepend some documentation to this section */
   void Prepend(const char *[][3]);
+  void Prepend(const std::vector<cmDocumentationEntry> &entries)
+  { this->Entries.insert(this->Entries.begin(),
+                         entries.begin(),entries.end()); }
 
   
 private:

Index: cmDocumentationFormatter.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentationFormatter.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cmDocumentationFormatter.h	22 Oct 2007 16:48:39 -0000	1.4
+++ cmDocumentationFormatter.h	24 Oct 2007 15:36:47 -0000	1.5
@@ -30,10 +30,10 @@
 public:
   /** Types of help provided.  */
   enum Type 
-     { None, Usage, Single, SingleModule, SingleProperty,
-       List, ModuleList, PropertyList,
-       Full, Properties, Modules, CustomModules, Commands, CompatCommands,
-       Copyright, Version };
+  { None, Usage, Single, SingleModule, SingleProperty, SingleVariable,
+    List, ModuleList, PropertyList, VariableList,
+    Full, Properties, Variables, Modules, CustomModules, Commands, 
+    CompatCommands, Copyright, Version };
 
   /** Forms of documentation output.  */
   enum Form { TextForm, HTMLForm, ManForm, UsageForm };



More information about the Cmake-commits mailing list