[Cmake-commits] CMake branch, next, updated. v2.8.12-4239-gf0eb914

Brad King brad.king at kitware.com
Mon Oct 21 15:47:12 EDT 2013


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  f0eb914254495717767db0e358f5ee51c512cbee (commit)
       via  2d0287dd5e12f57085d01badc9c0696924b61d94 (commit)
       via  7b9ae406f3f2fbe4de9d075a50ec0daae4fa1274 (commit)
      from  06db1883b8631f8b5ce86ab75249ca146dcfde07 (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=f0eb914254495717767db0e358f5ee51c512cbee
commit f0eb914254495717767db0e358f5ee51c512cbee
Merge: 06db188 2d0287d
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 21 15:47:06 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Oct 21 15:47:06 2013 -0400

    Merge topic 'rst-literal-blocks' into next
    
    2d0287d cmRST: Process literal blocks after paragraphs ending in '::'
    7b9ae40 cmRST: Do not process inline markup in code-block literals


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2d0287dd5e12f57085d01badc9c0696924b61d94
commit 2d0287dd5e12f57085d01badc9c0696924b61d94
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 21 15:31:44 2013 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 21 15:40:26 2013 -0400

    cmRST: Process literal blocks after paragraphs ending in '::'
    
    Teach cmRST to recognize non-markup lines ending in '::' followed by a
    blank line as starting a literal block.  Record the whole block as if it
    were a literal block directive and print it just like a code block.
    Extend the CMakeLib.testRST test to cover such cases.

diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index b64887d..d2eeb0c 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -22,6 +22,7 @@ cmRST::cmRST(std::ostream& os, std::string const& docroot):
   DocRoot(docroot),
   IncludeDepth(0),
   OutputLinePending(false),
+  LastLineEndedInColonColon(false),
   Markup(MarkupNone),
   Directive(DirectiveNone),
   CMakeDirective("^.. (cmake:)?("
@@ -125,6 +126,7 @@ void cmRST::Reset()
     {
     case DirectiveNone: break;
     case DirectiveParsedLiteral: this->ProcessDirectiveParsedLiteral(); break;
+    case DirectiveLiteralBlock: this->ProcessDirectiveLiteralBlock(); break;
     case DirectiveCodeBlock: this->ProcessDirectiveCodeBlock(); break;
     case DirectiveReplace: this->ProcessDirectiveReplace(); break;
     case DirectiveTocTree: this->ProcessDirectiveTocTree(); break;
@@ -137,6 +139,9 @@ void cmRST::Reset()
 //----------------------------------------------------------------------------
 void cmRST::ProcessLine(std::string const& line)
 {
+  bool lastLineEndedInColonColon = this->LastLineEndedInColonColon;
+  this->LastLineEndedInColonColon = false;
+
   // A line starting in .. is an explicit markup start.
   if(line == ".." || (line.size() >= 3 && line[0] == '.' &&
                       line[1] == '.' && isspace(line[2])))
@@ -211,10 +216,21 @@ void cmRST::ProcessLine(std::string const& line)
       this->MarkupLines.push_back(line);
       }
     }
+  // A blank line following a paragraph ending in "::" starts a literal block.
+  else if(lastLineEndedInColonColon && line.empty())
+    {
+    // Record the literal lines to output after whole block.
+    this->Markup = MarkupNormal;
+    this->Directive = DirectiveLiteralBlock;
+    this->MarkupLines.push_back("");
+    this->OutputLine("", false);
+    }
   // Print non-markup lines.
   else
     {
     this->NormalLine(line);
+    this->LastLineEndedInColonColon = (line.size() >= 2
+      && line[line.size()-2] == ':' && line[line.size()-1] == ':');
     }
 }
 
@@ -344,6 +360,12 @@ void cmRST::ProcessDirectiveParsedLiteral()
 }
 
 //----------------------------------------------------------------------------
+void cmRST::ProcessDirectiveLiteralBlock()
+{
+  this->OutputMarkupLines(false);
+}
+
+//----------------------------------------------------------------------------
 void cmRST::ProcessDirectiveCodeBlock()
 {
   this->OutputMarkupLines(false);
diff --git a/Source/cmRST.h b/Source/cmRST.h
index a3b9c32..faae25f 100644
--- a/Source/cmRST.h
+++ b/Source/cmRST.h
@@ -38,6 +38,7 @@ private:
   {
     DirectiveNone,
     DirectiveParsedLiteral,
+    DirectiveLiteralBlock,
     DirectiveCodeBlock,
     DirectiveReplace,
     DirectiveTocTree
@@ -53,6 +54,7 @@ private:
   void OutputMarkupLines(bool inlineMarkup);
   bool ProcessInclude(std::string file, IncludeType type);
   void ProcessDirectiveParsedLiteral();
+  void ProcessDirectiveLiteralBlock();
   void ProcessDirectiveCodeBlock();
   void ProcessDirectiveReplace();
   void ProcessDirectiveTocTree();
@@ -62,6 +64,7 @@ private:
   std::string DocRoot;
   int IncludeDepth;
   bool OutputLinePending;
+  bool LastLineEndedInColonColon;
   MarkupType Markup;
   DirectiveType Directive;
   cmsys::RegularExpression CMakeDirective;
diff --git a/Tests/CMakeLib/testRST.expect b/Tests/CMakeLib/testRST.expect
index 28981bf..9bd0ca4 100644
--- a/Tests/CMakeLib/testRST.expect
+++ b/Tests/CMakeLib/testRST.expect
@@ -53,6 +53,23 @@ More CMake Module Content
  endif()
  # |not replaced in literal|
 
+A literal block starts after a line consisting of two colons
+
+::
+
+  Literal block.
+ Common Indentation Removed
+ # |not replaced in literal|
+
+or after a paragraph ending in two colons::
+
+  Literal block.
+ Common Indentation Removed
+ # |not replaced in literal|
+
+but not after a line ending in two colons::
+in the middle of a paragraph.
+
 substituted text with multiple lines becomes one line
 
 End of first include.
diff --git a/Tests/CMakeLib/testRST.rst b/Tests/CMakeLib/testRST.rst
index 46ec771..5cb6d91 100644
--- a/Tests/CMakeLib/testRST.rst
+++ b/Tests/CMakeLib/testRST.rst
@@ -66,6 +66,23 @@ Generator :generator:`Some Generator` with space.
    endif()
    # |not replaced in literal|
 
+A literal block starts after a line consisting of two colons
+
+::
+
+    Literal block.
+   Common Indentation Removed
+   # |not replaced in literal|
+
+or after a paragraph ending in two colons::
+
+    Literal block.
+   Common Indentation Removed
+   # |not replaced in literal|
+
+but not after a line ending in two colons::
+in the middle of a paragraph.
+
 .. |substitution| replace::
    |nested substitution|
    with multiple lines becomes one line

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7b9ae406f3f2fbe4de9d075a50ec0daae4fa1274
commit 7b9ae406f3f2fbe4de9d075a50ec0daae4fa1274
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 21 14:53:25 2013 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 21 14:56:26 2013 -0400

    cmRST: Do not process inline markup in code-block literals
    
    Move the ProcessDirectiveParsedLiteral and ProcessDirectiveCodeBlock
    method internals into an OutputMarkupLines helper.  Pass through it a
    new "inlineMarkup" parameter and teach OutputLine to understand it.
    When false, do not process inline markup.  Extend the CMakeLib.testRST
    test to cover the two cases.

diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index 18a197b..b64887d 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -222,35 +222,42 @@ void cmRST::ProcessLine(std::string const& line)
 void cmRST::NormalLine(std::string const& line)
 {
   this->Reset();
-  this->OutputLine(line);
+  this->OutputLine(line, true);
 }
 
 //----------------------------------------------------------------------------
-void cmRST::OutputLine(std::string const& line_in)
+void cmRST::OutputLine(std::string const& line_in, bool inlineMarkup)
 {
   if(this->OutputLinePending)
     {
     this->OS << "\n";
     this->OutputLinePending = false;
     }
-  std::string line = this->ReplaceSubstitutions(line_in);
-  std::string::size_type pos = 0;
-  while(this->CMakeRole.find(line.c_str()+pos))
+  if(inlineMarkup)
     {
-    this->OS << line.substr(pos, this->CMakeRole.start());
-    std::string text = this->CMakeRole.match(3);
-    // If a command reference has no explicit target and
-    // no explicit "(...)" then add "()" to the text.
-    if(this->CMakeRole.match(2) == "command" &&
-       this->CMakeRole.match(5).empty() &&
-       text.find_first_of("()") == text.npos)
+    std::string line = this->ReplaceSubstitutions(line_in);
+    std::string::size_type pos = 0;
+    while(this->CMakeRole.find(line.c_str()+pos))
       {
-      text += "()";
+      this->OS << line.substr(pos, this->CMakeRole.start());
+      std::string text = this->CMakeRole.match(3);
+      // If a command reference has no explicit target and
+      // no explicit "(...)" then add "()" to the text.
+      if(this->CMakeRole.match(2) == "command" &&
+         this->CMakeRole.match(5).empty() &&
+         text.find_first_of("()") == text.npos)
+        {
+        text += "()";
+        }
+      this->OS << "``" << text << "``";
+      pos += this->CMakeRole.end();
       }
-    this->OS << "``" << text << "``";
-    pos += this->CMakeRole.end();
+    this->OS << line.substr(pos) << "\n";
+    }
+  else
+    {
+    this->OS << line_in << "\n";
     }
-  this->OS << line.substr(pos) << "\n";
 }
 
 //----------------------------------------------------------------------------
@@ -284,6 +291,22 @@ std::string cmRST::ReplaceSubstitutions(std::string const& line)
 }
 
 //----------------------------------------------------------------------------
+void cmRST::OutputMarkupLines(bool inlineMarkup)
+{
+  for(std::vector<std::string>::iterator i = this->MarkupLines.begin();
+      i != this->MarkupLines.end(); ++i)
+    {
+    std::string line = *i;
+    if(!line.empty())
+      {
+      line = " " + line;
+      }
+    this->OutputLine(line, inlineMarkup);
+    }
+  this->OutputLinePending = true;
+}
+
+//----------------------------------------------------------------------------
 bool cmRST::ProcessInclude(std::string file, IncludeType type)
 {
   bool found = false;
@@ -317,25 +340,13 @@ bool cmRST::ProcessInclude(std::string file, IncludeType type)
 //----------------------------------------------------------------------------
 void cmRST::ProcessDirectiveParsedLiteral()
 {
-  // Output markup lines as literal text.
-  for(std::vector<std::string>::iterator i = this->MarkupLines.begin();
-      i != this->MarkupLines.end(); ++i)
-    {
-    std::string line = *i;
-    if(!line.empty())
-      {
-      line = " " + line;
-      }
-    this->OutputLine(line);
-    }
-  this->OutputLinePending = true;
+  this->OutputMarkupLines(true);
 }
 
 //----------------------------------------------------------------------------
 void cmRST::ProcessDirectiveCodeBlock()
 {
-  // Treat markup lines the same as a parsed literal.
-  this->ProcessDirectiveParsedLiteral();
+  this->OutputMarkupLines(false);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmRST.h b/Source/cmRST.h
index 9352941..a3b9c32 100644
--- a/Source/cmRST.h
+++ b/Source/cmRST.h
@@ -48,8 +48,9 @@ private:
   void Reset();
   void ProcessLine(std::string const& line);
   void NormalLine(std::string const& line);
-  void OutputLine(std::string const& line);
+  void OutputLine(std::string const& line, bool inlineMarkup);
   std::string ReplaceSubstitutions(std::string const& line);
+  void OutputMarkupLines(bool inlineMarkup);
   bool ProcessInclude(std::string file, IncludeType type);
   void ProcessDirectiveParsedLiteral();
   void ProcessDirectiveCodeBlock();
diff --git a/Tests/CMakeLib/testRST.expect b/Tests/CMakeLib/testRST.expect
index 6a89002..28981bf 100644
--- a/Tests/CMakeLib/testRST.expect
+++ b/Tests/CMakeLib/testRST.expect
@@ -45,11 +45,13 @@ More CMake Module Content
 
   Parsed-literal included without directive.
  Common Indentation Removed
+ # replaced in parsed literal
 
  # Sample CMake code block
  if(condition)
    message(indented)
  endif()
+ # |not replaced in literal|
 
 substituted text with multiple lines becomes one line
 
diff --git a/Tests/CMakeLib/testRST.rst b/Tests/CMakeLib/testRST.rst
index f7059cf..46ec771 100644
--- a/Tests/CMakeLib/testRST.rst
+++ b/Tests/CMakeLib/testRST.rst
@@ -26,6 +26,7 @@ Variable :variable:`VARIABLE_<PLACEHOLDER> <target>` with trailing placeholder a
 Generator :generator:`Some Generator` with space.
 
 .. |not replaced| replace:: not replaced through toctree
+.. |not replaced in literal| replace:: replaced in parsed literal
 
 .. toctree::
    :maxdepth: 2
@@ -55,6 +56,7 @@ Generator :generator:`Some Generator` with space.
 
     Parsed-literal included without directive.
    Common Indentation Removed
+   # |not replaced in literal|
 
 .. code-block:: cmake
 
@@ -62,6 +64,7 @@ Generator :generator:`Some Generator` with space.
    if(condition)
      message(indented)
    endif()
+   # |not replaced in literal|
 
 .. |substitution| replace::
    |nested substitution|

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

Summary of changes:
 Source/cmRST.cxx              |   93 +++++++++++++++++++++++++++-------------
 Source/cmRST.h                |    6 ++-
 Tests/CMakeLib/testRST.expect |   19 ++++++++
 Tests/CMakeLib/testRST.rst    |   20 +++++++++
 4 files changed, 107 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list