Browse Source

Included the comments plain text to the remarks block. (#907)

pull/908/head
Kimon Topouzidis 8 years ago committed by Dimitar Dobrev
parent
commit
b4735df891
  1. 22
      src/Generator/Generators/CSharp/CSharpCommentPrinter.cs

22
src/Generator/Generators/CSharp/CSharpCommentPrinter.cs

@ -50,6 +50,8 @@ namespace CppSharp.Generators.CSharp
if (inlineContentComment.HasTrailingNewline) if (inlineContentComment.HasTrailingNewline)
sections.Last().NewLine(); sections.Last().NewLine();
} }
if (!string.IsNullOrEmpty(sections.Last().CurrentLine.ToString()))
sections.Add(new Section(CommentElement.Remarks));
break; break;
case DocumentationCommentKind.TParamCommandComment: case DocumentationCommentKind.TParamCommandComment:
break; break;
@ -60,13 +62,18 @@ namespace CppSharp.Generators.CSharp
case DocumentationCommentKind.ParagraphComment: case DocumentationCommentKind.ParagraphComment:
var summaryParagraph = sections.Count == 1; var summaryParagraph = sections.Count == 1;
var paragraphComment = (ParagraphComment) comment; var paragraphComment = (ParagraphComment) comment;
var lastParagraphSection = sections.Last();
foreach (var inlineContentComment in paragraphComment.Content) foreach (var inlineContentComment in paragraphComment.Content)
{ {
inlineContentComment.GetCommentSections(sections); inlineContentComment.GetCommentSections(sections);
if (inlineContentComment.HasTrailingNewline) if (inlineContentComment.HasTrailingNewline)
sections.Last().NewLine(); lastParagraphSection.NewLine();
} }
if (summaryParagraph)
if (!string.IsNullOrEmpty(lastParagraphSection.CurrentLine.ToString()))
lastParagraphSection.NewLine();
if (sections[0].GetLines().Count > 0 && summaryParagraph)
{ {
sections[0].GetLines().AddRange(sections.Skip(1).SelectMany(s => s.GetLines())); sections[0].GetLines().AddRange(sections.Skip(1).SelectMany(s => s.GetLines()));
sections.RemoveRange(1, sections.Count - 1); sections.RemoveRange(1, sections.Count - 1);
@ -80,20 +87,21 @@ namespace CppSharp.Generators.CSharp
case DocumentationCommentKind.HTMLEndTagComment: case DocumentationCommentKind.HTMLEndTagComment:
break; break;
case DocumentationCommentKind.TextComment: case DocumentationCommentKind.TextComment:
var section = sections.Last(); var lastTextsection = sections.Last();
section.CurrentLine.Append(GetText(comment, lastTextsection.CurrentLine.Append(GetText(comment,
section.Type == CommentElement.Returns || section.Type == CommentElement.Param).Trim()); lastTextsection.Type == CommentElement.Returns ||
lastTextsection.Type == CommentElement.Param).Trim());
break; break;
case DocumentationCommentKind.InlineContentComment: case DocumentationCommentKind.InlineContentComment:
break; break;
case DocumentationCommentKind.InlineCommandComment: case DocumentationCommentKind.InlineCommandComment:
var lastSection = sections.Last(); var lastInlineSection = sections.Last();
var inlineCommand = (InlineCommandComment) comment; var inlineCommand = (InlineCommandComment) comment;
if (inlineCommand.CommandKind == CommentCommandKind.B) if (inlineCommand.CommandKind == CommentCommandKind.B)
{ {
var argText = $" <c>{inlineCommand.Arguments[0].Text}</c> "; var argText = $" <c>{inlineCommand.Arguments[0].Text}</c> ";
lastSection.CurrentLine.Append(argText); lastInlineSection.CurrentLine.Append(argText);
} }
break; break;
case DocumentationCommentKind.VerbatimBlockLineComment: case DocumentationCommentKind.VerbatimBlockLineComment:

Loading…
Cancel
Save