[Cmake-commits] CMake branch, next, updated. v2.8.7-2464-gc277957

Eric Noulard eric.noulard at gmail.com
Sat Feb 4 06:19:28 EST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  c277957813c26ec1ee300b2d39062d39f4a7ecd8 (commit)
       via  dce3f99c031507ef43a744838161d5992beba0a0 (commit)
       via  0e1ddd4dd8c2a20f5a097c58155898eef0329e3b (commit)
       via  deb22f23bf5b184982fbc6c31cae0bcbfa1f9cc7 (commit)
       via  1d5f7ee9049c20a9181610992e7057ebe580b989 (commit)
      from  0f6f49786297b0ed2ac64bc353751e8239d7181e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c277957813c26ec1ee300b2d39062d39f4a7ecd8
commit c277957813c26ec1ee300b2d39062d39f4a7ecd8
Merge: 0f6f497 dce3f99
Author:     Eric Noulard <eric.noulard at gmail.com>
AuthorDate: Sat Feb 4 06:19:21 2012 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Feb 4 06:19:21 2012 -0500

    Merge topic 'ImproveCPackDoc-reloaded' into next
    
    dce3f99 Create getDocumentedModulesListInDir which may be used in other context.
    0e1ddd4 Add missing section markup for CPackComponent
    deb22f2 Example of builtin variable documentation (i.e. only used in C++ source code).
    1d5f7ee Make the load of script documentation more efficient and dynamic.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dce3f99c031507ef43a744838161d5992beba0a0
commit dce3f99c031507ef43a744838161d5992beba0a0
Author:     Eric NOULARD <eric.noulard at gmail.com>
AuthorDate: Sat Feb 4 12:15:57 2012 +0100
Commit:     Eric NOULARD <eric.noulard at gmail.com>
CommitDate: Sat Feb 4 12:15:57 2012 +0100

    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.

diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 25a72fa..3182915 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -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);
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(' ');
diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h
index 83a0a09..00dba1a 100644
--- a/Source/cmDocumentation.h
+++ b/Source/cmDocumentation.h
@@ -35,6 +35,21 @@ public:
   cmDocumentation();
   
   ~cmDocumentation();
+
+  /**
+   * An helper type pair for [structured] documented modules.
+   * The comment of those module contains structure markup
+   * which makes it possible to retrieve the documentation
+   * of variables, macros and functions defined in the module.
+   * - first is the filename of the module
+   * - second is the section of the doc the module belongs too
+   */
+  typedef std::pair<std::string,std::string> documentedModuleSectionPair_t;
+  /**
+   * A list of documented module(s).
+   */
+  typedef std::list<documentedModuleSectionPair_t>  documentedModulesList_t;
+
   // High-level interface for standard documents:
   
   /**
@@ -133,6 +148,21 @@ public:
   void addCPackStandardDocSections();
 
   /**
+   * Retrieve the list of documented module located in
+   * path which match the globing expression globExpr.
+   * @param[in] path, directory where to start the search
+   *                  we will recurse into it.
+   * @param[in] globExpr, the globing expression used to
+   *                      match the file in path.
+   * @param[out] the list of obtained pairs (may be empty)
+   * @return 0 on success 1 on error or empty list
+   */
+  int getDocumentedModulesListInDir(
+          std::string path,
+          std::string globExpr,
+          documentedModulesList_t& docModuleList);
+
+  /**
    * Get the documentation of macros, functions and variable documented
    * with CMake structured documentation in a CMake script.
    * (in fact it may be in any file which follow the structured doc format)
@@ -140,7 +170,8 @@ public:
    * ## (double sharp) in column 1 & 2 immediately followed
    * by a markup. Those ## are ignored by the legacy module
    * documentation parser @see CreateSingleModule.
-   * Current markup are ##macro, ##function, ##variable and ##end.
+   * Current markup are ##section, ##module,
+   * ##macro, ##function, ##variable and ##end.
    * ##end is closing either of the previous ones.
    * @param[in] fname the script file name to be parsed for documentation
    * @param[in,out] commands the vector of command/macros documentation

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0e1ddd4dd8c2a20f5a097c58155898eef0329e3b
commit 0e1ddd4dd8c2a20f5a097c58155898eef0329e3b
Author:     Eric NOULARD <eric.noulard at gmail.com>
AuthorDate: Sat Feb 4 12:06:09 2012 +0100
Commit:     Eric NOULARD <eric.noulard at gmail.com>
CommitDate: Sat Feb 4 12:06:09 2012 +0100

    Add missing section markup for CPackComponent

diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake
index a0e0667..016cb8c 100644
--- a/Modules/CPackComponent.cmake
+++ b/Modules/CPackComponent.cmake
@@ -1,3 +1,6 @@
+##section Variables common to all CPack generators
+##end
+##module
 # - Build binary and source package installers
 #
 # The CPackComponent module is the module which handles
@@ -20,6 +23,7 @@
 # components are identified by the COMPONENT argument of CMake's
 # INSTALL commands, and should be further described by the following
 # CPack commands:
+##end
 #
 ##macro
 #   cpack_add_component - Describes a CPack installation component

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=deb22f23bf5b184982fbc6c31cae0bcbfa1f9cc7
commit deb22f23bf5b184982fbc6c31cae0bcbfa1f9cc7
Author:     Eric NOULARD <eric.noulard at gmail.com>
AuthorDate: Sat Feb 4 12:03:58 2012 +0100
Commit:     Eric NOULARD <eric.noulard at gmail.com>
CommitDate: Sat Feb 4 12:03:58 2012 +0100

    Example of builtin variable documentation (i.e. only used in C++ source code).

diff --git a/Source/CPack/cmCPackDocumentVariables.cxx b/Source/CPack/cmCPackDocumentVariables.cxx
index 6327152..68cde78 100644
--- a/Source/CPack/cmCPackDocumentVariables.cxx
+++ b/Source/CPack/cmCPackDocumentVariables.cxx
@@ -1,17 +1,25 @@
 #include "cmCPackDocumentVariables.h"
 #include "cmake.h"
 
-void cmCPackDocumentVariables::DefineVariables(cmake* )
+void cmCPackDocumentVariables::DefineVariables(cmake* cm)
 {
   // Subsection: variables defined/used by cpack,
   // which are common to all CPack generators
 
-//  cm->DefineProperty
-//      ("CPACK_PACKAGE_VENDOR", cmProperty::VARIABLE,
-//       "The name of the package vendor.",
-//       "If not specified, defaults to \"Humanity\"."
-//       "", false,
-//       "Variables common to all CPack generators");
+  cm->DefineProperty
+      ("CPACK_PACKAGING_INSTALL_PREFIX", cmProperty::VARIABLE,
+       "The prefix used in the built package.",
+       "Each CPack generator has a default value (like /usr)."
+       " This default value may"
+       " be overwritten from the CMakeLists.txt or the cpack command line"
+       " by setting an alternative value.\n"
+       "e.g. "
+       " set(CPACK_PACKAGING_INSTALL_PREFIX \"/opt\")\n"
+       "This is not the same purpose as CMAKE_INSTALL_PREFIX which"
+       " is used when installing from the build tree without building"
+       " a package."
+       "", false,
+       "Variables common to all CPack generators");
 
   // Subsection: variables defined/used by cpack,
   // which are specific to one CPack generator

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1d5f7ee9049c20a9181610992e7057ebe580b989
commit 1d5f7ee9049c20a9181610992e7057ebe580b989
Author:     Eric NOULARD <eric.noulard at gmail.com>
AuthorDate: Thu Feb 2 01:44:21 2012 +0100
Commit:     Eric NOULARD <eric.noulard at gmail.com>
CommitDate: Thu Feb 2 01:44:21 2012 +0100

    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.

diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index 1718008..8a44991 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -1,3 +1,6 @@
+##section Variables common to all CPack generators
+##end
+##module
 # - Build binary and source package installers.
 # The CPack module generates binary and source installers in a variety
 # of formats using the cpack program. Inclusion of the CPack module
@@ -28,16 +31,16 @@
 # on a per-generator basis. It only need contain overrides.
 #
 # Here's how it works:
-# - cpack runs
-# - it includes CPackConfig.cmake
-# - it iterates over the generators listed in that file's
-#     CPACK_GENERATOR list variable (unless told to use just a
-#     specific one via -G on the command line...)
+#  - cpack runs
+#  - it includes CPackConfig.cmake
+#  - it iterates over the generators listed in that file's
+#    CPACK_GENERATOR list variable (unless told to use just a
+#    specific one via -G on the command line...)
 #
-# - foreach generator, it then
-#   - sets CPACK_GENERATOR to the one currently being iterated
-#   - includes the CPACK_PROJECT_CONFIG_FILE
-#   - produces the package for that generator
+#  - foreach generator, it then
+#    - sets CPACK_GENERATOR to the one currently being iterated
+#    - includes the CPACK_PROJECT_CONFIG_FILE
+#    - produces the package for that generator
 #
 # This is the key: For each generator listed in CPACK_GENERATOR
 # in CPackConfig.cmake, cpack will *reset* CPACK_GENERATOR
@@ -47,6 +50,7 @@
 # Before including this CPack module in your CMakeLists.txt file,
 # there are a variety of variables that can be set to customize
 # the resulting installers. The most commonly-used variables are:
+##end
 #
 ##variable
 #   CPACK_PACKAGE_NAME - The name of the package (or application). If
diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
index fc7f992..0916843 100644
--- a/Modules/CPackDeb.cmake
+++ b/Modules/CPackDeb.cmake
@@ -1,3 +1,6 @@
+##section Variables specific to a CPack generator
+##end
+##module
 # - The builtin (binary) CPack Deb generator (Unix only)
 # CPackDeb may be used to create Deb package using CPack.
 # CPackDeb is a CPack generator thus it uses the CPACK_XXX variables
@@ -11,6 +14,7 @@
 # the wiki:
 #  http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
 # However as a handy reminder here comes the list of specific variables:
+##end
 #
 ##variable
 # CPACK_DEBIAN_PACKAGE_NAME
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index de06fef..f76e91e 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -1,5 +1,7 @@
-# - The builtin (binary) CPack RPM generator (Unix only)
+##section Variables specific to a CPack generator
+##end
 ##module
+# - The builtin (binary) CPack RPM generator (Unix only)
 # CPackRPM may be used to create RPM package using CPack.
 # CPackRPM is a CPack generator thus it uses the CPACK_XXX variables
 # used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration
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();
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 80f74a6..ed1e5e1 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -768,6 +768,7 @@ int cmDocumentation::GetStructuredDocFromFile(
 {
     typedef enum sdoce {
         SDOC_NONE, SDOC_MODULE, SDOC_MACRO, SDOC_FUNCTION, SDOC_VARIABLE,
+        SDOC_SECTION,
         SDOC_UNKNOWN} sdoc_t;
     int nbDocItemFound = 0;
     int docCtxIdx      = 0;
@@ -795,9 +796,13 @@ int cmDocumentation::GetStructuredDocFromFile(
       if(line.size() && line[0] == '#')
         {
         /* handle structured doc context */
-        if (line[1]=='#')
+        if ((line.size()>=2) && line[1]=='#')
         {
-            std::string mkword = line.substr(2,std::string::npos);
+            /* markup word is following '##' stopping at first space
+             * Some markup word like 'section' may have more characters
+             * following but we don't handle those here.
+             */
+            std::string mkword = line.substr(2,line.find(' ',2)-2);
             if (mkword=="macro")
             {
                docCtxIdx++;
@@ -822,6 +827,14 @@ int cmDocumentation::GetStructuredDocFromFile(
                docContextStack[docCtxIdx]=SDOC_MODULE;
                newCtx = true;
             }
+            else if (mkword=="section")
+            {
+               docCtxIdx++;
+               docContextStack[docCtxIdx]=SDOC_SECTION;
+               /* drop the rest of the line */
+               line.clear();
+               newCtx = true;
+            }
             else if (mkword.substr(0,3)=="end")
             {
                switch (docContextStack[docCtxIdx]) {
@@ -841,6 +854,9 @@ int cmDocumentation::GetStructuredDocFromFile(
                case SDOC_MODULE:
                    /*  not implemented */
                    break;
+               case SDOC_SECTION:
+                   /*  not implemented */
+                   break;
                default:
                    /* ignore other cases */
                    break;

-----------------------------------------------------------------------

Summary of changes:
 Modules/CPack.cmake                       |   22 +++++----
 Modules/CPackComponent.cmake              |    4 ++
 Modules/CPackDeb.cmake                    |    4 ++
 Modules/CPackRPM.cmake                    |    4 +-
 Source/CPack/cmCPackDocumentVariables.cxx |   22 ++++++---
 Source/CPack/cpack.cxx                    |   45 +++++++----------
 Source/cmDocumentation.cxx                |   75 ++++++++++++++++++++++++++++-
 Source/cmDocumentation.h                  |   33 ++++++++++++-
 8 files changed, 162 insertions(+), 47 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list