[Cmake-commits] [cmake-commits] hoffman committed cmDocumentationFormatter.cxx 1.1 1.1.2.1 cmDocumentationFormatter.h 1.8 1.8.2.1 cmDocumentationFormatterDocbook.cxx 1.1 1.1.2.1 cmDocumentationFormatterHTML.cxx 1.11 1.11.2.1

cmake-commits at cmake.org cmake-commits at cmake.org
Mon May 5 13:38:21 EDT 2008


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

Modified Files:
      Tag: CMake-2-6
	cmDocumentationFormatter.cxx cmDocumentationFormatter.h 
	cmDocumentationFormatterDocbook.cxx 
	cmDocumentationFormatterHTML.cxx 
Log Message:
ENH: merge in changes for generated docs


Index: cmDocumentationFormatter.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentationFormatter.h,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -C 2 -d -r1.8 -r1.8.2.1
*** cmDocumentationFormatter.h	5 Mar 2008 16:05:21 -0000	1.8
--- cmDocumentationFormatter.h	5 May 2008 17:38:19 -0000	1.8.2.1
***************
*** 63,66 ****
--- 63,69 ----
                            std::vector<const cmDocumentationSection *>&)
      {}
+ 
+   /** Compute a prefix for links into a section (#<prefix>_SOMETHING).  */
+   std::string ComputeSectionLinkPrefix(std::string const& name);
  };
  

Index: cmDocumentationFormatterHTML.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentationFormatterHTML.cxx,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -C 2 -d -r1.11 -r1.11.2.1
*** cmDocumentationFormatterHTML.cxx	6 Mar 2008 16:34:23 -0000	1.11
--- cmDocumentationFormatterHTML.cxx	5 May 2008 17:38:19 -0000	1.11.2.1
***************
*** 53,56 ****
--- 53,81 ----
  
  //----------------------------------------------------------------------------
+ bool cmDocumentationHTMLIsIdChar(char c)
+ {
+   // From the HTML specification:
+   //   ID and NAME tokens must begin with a letter ([A-Za-z]) and may
+   //   be followed by any number of letters, digits ([0-9]), hyphens
+   //   ("-"), underscores ("_"), colons (":"), and periods (".").
+   return ((c >= 'A' && c <= 'Z') ||
+           (c >= 'a' && c <= 'z') ||
+           (c >= '0' && c <= '9') ||
+           c == '-' || c == '_' || c == ':' || c == '.');
+ }
+ 
+ //----------------------------------------------------------------------------
+ void cmDocumentationPrintHTMLId(std::ostream& os, const char* begin)
+ {
+   for(const char* c = begin; *c; ++c)
+     {
+     if(cmDocumentationHTMLIsIdChar(*c))
+       {
+       os << *c;
+       }
+     }
+ }
+ 
+ //----------------------------------------------------------------------------
  const char* cmDocumentationPrintHTMLLink(std::ostream& os, const char* begin)
  {
***************
*** 98,101 ****
--- 123,128 ----
      }
  
+   std::string prefix = this->ComputeSectionLinkPrefix(name);
+ 
    const std::vector<cmDocumentationEntry> &entries = 
      section.GetEntries();
***************
*** 107,112 ****
      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>";
--- 134,140 ----
      if(op->Name.size())
        {
!       os << "    <li><a href=\"#" << prefix << ":";
!       cmDocumentationPrintHTMLId(os, op->Name.c_str());
!       os << "\"><b><code>";
        this->PrintHTMLEscapes(os, op->Name.c_str());
        os << "</code></b></a></li>";
***************
*** 126,131 ****
          if(op->Name.size())
            {
!           os << "    <a name=\"command_"<< 
!             op->Name.c_str() << "\"><b><code>";
            this->PrintHTMLEscapes(os, op->Name.c_str());
            os << "</code></b></a>: ";
--- 154,160 ----
          if(op->Name.size())
            {
!           os << "    <a name=\"" << prefix << ":";
!           cmDocumentationPrintHTMLId(os, op->Name.c_str());
!           os << "\"><b><code>";
            this->PrintHTMLEscapes(os, op->Name.c_str());
            os << "</code></b></a>: ";

Index: cmDocumentationFormatter.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentationFormatter.cxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C 2 -d -r1.1 -r1.1.2.1
*** cmDocumentationFormatter.cxx	19 Sep 2007 13:05:28 -0000	1.1
--- cmDocumentationFormatter.cxx	5 May 2008 17:38:19 -0000	1.1.2.1
***************
*** 72,73 ****
--- 72,156 ----
  }
  
+ //----------------------------------------------------------------------------
+ std::string
+ cmDocumentationFormatter::ComputeSectionLinkPrefix(std::string const& name)
+ {
+   // Map from section name to a prefix for links pointing within the
+   // section.  For example, the commands section should have HTML
+   // links to each command with names like #command:ADD_EXECUTABLE.
+   if(name.find("Command") != name.npos)
+     {
+     return "command";
+     }
+   else if(name.find("Propert") != name.npos)
+     {
+     if(name.find("Global") != name.npos)
+       {
+       return "prop_global";
+       }
+     else if(name.find("Direct") != name.npos)
+       {
+       return "prop_dir";
+       }
+     else if(name.find("Target") != name.npos)
+       {
+       return "prop_tgt";
+       }
+     else if(name.find("Test") != name.npos)
+       {
+       return "prop_test";
+       }
+     else if(name.find("Source") != name.npos)
+       {
+       return "prop_sf";
+       }
+     return "property";
+     }
+   else if(name.find("Variable") != name.npos)
+     {
+     return "variable";
+     }
+   else if(name.find("Polic") != name.npos)
+     {
+     return "policy";
+     }
+   else if(name.find("Module") != name.npos)
+     {
+     return "module";
+     }
+   else if(name.find("Name") != name.npos)
+     {
+     return "name";
+     }
+   else if(name.find("Usage") != name.npos)
+     {
+     return "usage";
+     }
+   else if(name.find("Description") != name.npos)
+     {
+     return "desc";
+     }
+   else if(name.find("Generators") != name.npos)
+     {
+     return "gen";
+     }
+   else if(name.find("Options") != name.npos)
+     {
+     return "opt";
+     }
+   else if(name.find("Copyright") != name.npos)
+     {
+     return "copy";
+     }
+   else if(name.find("See Also") != name.npos)
+     {
+     return "see";
+     }
+   else
+     {
+     std::cerr
+       << "WARNING: ComputeSectionLinkPrefix failed for \"" << name << "\""
+       << std::endl;
+     return "other";
+     }
+ }

Index: cmDocumentationFormatterDocbook.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentationFormatterDocbook.cxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C 2 -d -r1.1 -r1.1.2.1
*** cmDocumentationFormatterDocbook.cxx	19 Feb 2008 19:33:43 -0000	1.1
--- cmDocumentationFormatterDocbook.cxx	5 May 2008 17:38:19 -0000	1.1.2.1
***************
*** 130,133 ****
--- 130,135 ----
      }
  
+   std::string prefix = this->ComputeSectionLinkPrefix(name);
+ 
    const std::vector<cmDocumentationEntry> &entries = 
      section.GetEntries();
***************
*** 139,143 ****
      if(op->Name.size())
        {
!       os << "    <listitem><link linkend=\"command_";
        cmDocumentationPrintDocbookEscapes(os, op->Name.c_str());
        os << "\"><emphasis><literal>";
--- 141,145 ----
      if(op->Name.size())
        {
!       os << "    <listitem><link linkend=\"" << prefix << "_";
        cmDocumentationPrintDocbookEscapes(os, op->Name.c_str());
        os << "\"><emphasis><literal>";
***************
*** 157,169 ****
          if(op->Name.size())
            {
!           os << "    <para id=\"command_";
            cmDocumentationPrintDocbookEscapes(os, op->Name.c_str());
  
!           // make sure that each id exists only once, e.g. 
!           // command_COMPILE_DEFINITIONS exists at least twice. Since it seems
            // not easily possible to determine which link refers to which id, 
            // we have at least to make sure that the duplicated id's get a 
            // different name (by appending an increasing number), Alex
!           std::string id = "command_";
            id += op->Name;
            if (this->EmittedLinkIds.find(id) == this->EmittedLinkIds.end())
--- 159,171 ----
          if(op->Name.size())
            {
!           os << "    <para id=\"" << prefix << "_";
            cmDocumentationPrintDocbookEscapes(os, op->Name.c_str());
  
!           // make sure that each id exists only once.  Since it seems
            // not easily possible to determine which link refers to which id, 
            // we have at least to make sure that the duplicated id's get a 
            // different name (by appending an increasing number), Alex
!           std::string id = prefix;
!           id += "_";
            id += op->Name;
            if (this->EmittedLinkIds.find(id) == this->EmittedLinkIds.end())



More information about the Cmake-commits mailing list