aboutsummaryrefslogtreecommitdiff
path: root/src/google
diff options
context:
space:
mode:
authorJan Tattermusch <jtattermusch@users.noreply.github.com>2015-11-08 19:17:08 -0800
committerJan Tattermusch <jtattermusch@users.noreply.github.com>2015-11-08 19:17:08 -0800
commit64aa954daec2f6f2df460f9bcc1e2ca6ba42b640 (patch)
tree1516488c97abdffcf10dcd9f5b9c38b5f6eb1cc6 /src/google
parent1e54dcfc707bc6ba23ac9a087336836f95d7fbd0 (diff)
parentcff900e8f9e4b8f3a8f314f0f44eab222ebb870b (diff)
downloadprotobuf-64aa954daec2f6f2df460f9bcc1e2ca6ba42b640.tar.gz
protobuf-64aa954daec2f6f2df460f9bcc1e2ca6ba42b640.tar.bz2
protobuf-64aa954daec2f6f2df460f9bcc1e2ca6ba42b640.zip
Merge pull request #954 from jskeet/blank-lines-in-comments
Stop removing all blank lines in doc comments.
Diffstat (limited to 'src/google')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_doc_comment.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
index 9ad2cbb5..587e0222 100644
--- a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
@@ -56,10 +56,26 @@ void WriteDocCommentBodyImpl(io::Printer* printer, SourceLocation location) {
// node of a summary element, not part of an attribute.
comments = StringReplace(comments, "&", "&amp;", true);
comments = StringReplace(comments, "<", "&lt;", true);
- vector<string> lines = Split(comments, "\n");
+ vector<string> lines = Split(comments, "\n", false /* skip_empty */);
+ // TODO: We really should work out which part to put in the summary and which to put in the remarks...
+ // but that needs to be part of a bigger effort to understand the markdown better anyway.
printer->Print("/// <summary>\n");
+ bool last_was_empty = false;
+ // We squash multiple blank lines down to one, and remove any trailing blank lines. We need
+ // to preserve the blank lines themselves, as this is relevant in the markdown.
+ // Note that we can't remove leading or trailing whitespace as *that's* relevant in markdown too.
+ // (We don't skip "just whitespace" lines, either.)
for (std::vector<string>::iterator it = lines.begin(); it != lines.end(); ++it) {
- printer->Print("/// $line$\n", "line", *it);
+ string line = *it;
+ if (line.empty()) {
+ last_was_empty = true;
+ } else {
+ if (last_was_empty) {
+ printer->Print("///\n");
+ }
+ last_was_empty = false;
+ printer->Print("/// $line$\n", "line", *it);
+ }
}
printer->Print("/// </summary>\n");
}