aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2012-08-08 22:10:24 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2012-08-08 22:10:24 +0000
commit6cd4420945489e7331012103048f162288a6c7d8 (patch)
tree96a1811db0c4bb85ba1d0acd9400d5fced0b5f25
parentc3b2308f66fe8abd2c1a911b500c0b989c295819 (diff)
Comment XML: use xml:space="preserve" in Verbatim tags, so that XML tidy does
not compress spaces in verbatim content. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161531 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--bindings/xml/comment-xml-schema.rng3
-rw-r--r--test/Index/Inputs/CommentXML/valid-function-07.xml1
-rw-r--r--test/Index/annotate-comments.cpp2
-rw-r--r--tools/libclang/CXComment.cpp6
4 files changed, 8 insertions, 4 deletions
diff --git a/bindings/xml/comment-xml-schema.rng b/bindings/xml/comment-xml-schema.rng
index 69d8229d6b..a0329f8c3d 100644
--- a/bindings/xml/comment-xml-schema.rng
+++ b/bindings/xml/comment-xml-schema.rng
@@ -385,6 +385,9 @@
</zeroOrMore>
</element>
<element name="Verbatim">
+ <attribute name="xml:space">
+ <value>preserve</value>
+ </attribute>
<attribute name="kind">
<!-- TODO: add all Doxygen verbatim kinds -->
<choice>
diff --git a/test/Index/Inputs/CommentXML/valid-function-07.xml b/test/Index/Inputs/CommentXML/valid-function-07.xml
index 1521e2aa16..89b8a0ca6f 100644
--- a/test/Index/Inputs/CommentXML/valid-function-07.xml
+++ b/test/Index/Inputs/CommentXML/valid-function-07.xml
@@ -24,6 +24,7 @@
<ResultDiscussion><Para>Eee.</Para></ResultDiscussion>
<Discussion>
<Para>Fff</Para>
+ <Verbatim xml:space="preserve" kind="verbatim">Ggg</Verbatim>
</Discussion>
</Function>
diff --git a/test/Index/annotate-comments.cpp b/test/Index/annotate-comments.cpp
index fbaefca6d5..765d996494 100644
--- a/test/Index/annotate-comments.cpp
+++ b/test/Index/annotate-comments.cpp
@@ -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
diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp
index 4e7bf76951..4606fdced9 100644
--- a/tools/libclang/CXComment.cpp
+++ b/tools/libclang/CXComment.cpp
@@ -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>";
}