]> granicus.if.org Git - clang/commitdiff
Comment XML: use xml:space="preserve" in Verbatim tags, so that XML tidy does
authorDmitri Gribenko <gribozavr@gmail.com>
Wed, 8 Aug 2012 22:10:24 +0000 (22:10 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Wed, 8 Aug 2012 22:10:24 +0000 (22:10 +0000)
not compress spaces in verbatim content.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161531 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/xml/comment-xml-schema.rng
test/Index/Inputs/CommentXML/valid-function-07.xml
test/Index/annotate-comments.cpp
tools/libclang/CXComment.cpp

index 69d8229d6b4d6842e85381b51a50968db831bf9a..a0329f8c3d7b95a25cf2f554d80ac7699b0eec8b 100644 (file)
         </zeroOrMore>
       </element>
       <element name="Verbatim">
+        <attribute name="xml:space">
+          <value>preserve</value>
+        </attribute>
         <attribute name="kind">
           <!-- TODO: add all Doxygen verbatim kinds -->
           <choice>
index 1521e2aa164782dd8c7c239f6c445b4f7e1d69e0..89b8a0ca6fc8338c7e9ec69bb7a64d27499926e5 100644 (file)
@@ -24,6 +24,7 @@
 <ResultDiscussion><Para>Eee.</Para></ResultDiscussion>
 <Discussion>
   <Para>Fff</Para>
+  <Verbatim xml:space="preserve" kind="verbatim">Ggg</Verbatim>
 </Discussion>
 </Function>
 
index fbaefca6d5574ee125a5246c4c223a5f041b7964..765d99649473d5590eb0b6163492cf7999aadae8 100644 (file)
@@ -778,7 +778,7 @@ enum class comment_to_xml_conversion_17 {
 // CHECK-NEXT:         (CXComment_HTMLStartTag Name=[a] Attrs: href=http://example.com/)
 // CHECK-NEXT:         (CXComment_Text Text=[Aaa])
 // CHECK-NEXT:         (CXComment_HTMLEndTag Name=[a])))]
-// CHECK: annotate-comments.cpp:338:6: FunctionDecl=comment_to_html_conversion_24:{{.*}} FullCommentAsHTML=[<pre> &lt;a href=&quot;http:&#47;&#47;example.com&#47;&quot;&gt;Aaa&lt;&#47;a&gt;\n &lt;a href=&#39;http:&#47;&#47;example.com&#47;&#39;&gt;Aaa&lt;&#47;a&gt;</pre>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="338" column="6"><Name>comment_to_html_conversion_24</Name><USR>c:@F@comment_to_html_conversion_24#</USR><Discussion><Verbatim kind="verbatim"> &lt;a href=&quot;http://example.com/&quot;&gt;Aaa&lt;/a&gt;\n &lt;a href=&apos;http://example.com/&apos;&gt;Aaa&lt;/a&gt;</Verbatim></Discussion></Function>]
+// CHECK: annotate-comments.cpp:338:6: FunctionDecl=comment_to_html_conversion_24:{{.*}} FullCommentAsHTML=[<pre> &lt;a href=&quot;http:&#47;&#47;example.com&#47;&quot;&gt;Aaa&lt;&#47;a&gt;\n &lt;a href=&#39;http:&#47;&#47;example.com&#47;&#39;&gt;Aaa&lt;&#47;a&gt;</pre>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="338" column="6"><Name>comment_to_html_conversion_24</Name><USR>c:@F@comment_to_html_conversion_24#</USR><Discussion><Verbatim xml:space="preserve" kind="verbatim"> &lt;a href=&quot;http://example.com/&quot;&gt;Aaa&lt;/a&gt;\n &lt;a href=&apos;http://example.com/&apos;&gt;Aaa&lt;/a&gt;</Verbatim></Discussion></Function>]
 // CHECK-NEXT:  CommentAST=[
 // CHECK-NEXT:    (CXComment_FullComment
 // CHECK-NEXT:       (CXComment_Paragraph IsWhitespace
index 4e7bf7695134fcb493d33418fa0d977712a07b31..4606fdced987fbb8057692eb468df1757bfbe2dd 100644 (file)
@@ -982,8 +982,8 @@ void CommentASTToXMLConverter::visitVerbatimBlockComment(
     return;
 
   Result << llvm::StringSwitch<const char *>(C->getCommandName())
-      .Case("code", "<Verbatim kind=\"code\">")
-      .Default("<Verbatim kind=\"verbatim\">");
+      .Case("code", "<Verbatim xml:space=\"preserve\" kind=\"code\">")
+      .Default("<Verbatim xml:space=\"preserve\" kind=\"verbatim\">");
   for (unsigned i = 0; i != NumLines; ++i) {
     appendToResultWithXMLEscaping(C->getText(i));
     if (i + 1 != NumLines)
@@ -999,7 +999,7 @@ void CommentASTToXMLConverter::visitVerbatimBlockLineComment(
 
 void CommentASTToXMLConverter::visitVerbatimLineComment(
                                   const VerbatimLineComment *C) {
-  Result << "<Verbatim kind=\"verbatim\">";
+  Result << "<Verbatim xml:space=\"preserve\" kind=\"verbatim\">";
   appendToResultWithXMLEscaping(C->getText());
   Result << "</Verbatim>";
 }