private static void FormatComment(ITextGenerator textGenerator, List <Section> sections, CommentKind kind) { var commentPrefix = Comment.GetMultiLineCommentPrologue(kind); sections.Sort((x, y) => x.Type.CompareTo(y.Type)); var remarks = sections.Where(s => s.Type == CommentElement.Remarks).ToList(); if (remarks.Any()) { remarks.First().GetLines().AddRange(remarks.Skip(1).SelectMany(s => s.GetLines())); } if (remarks.Count > 1) { sections.RemoveRange(sections.IndexOf(remarks.First()) + 1, remarks.Count - 1); } foreach (var section in sections.Where(s => s.HasLines)) { var lines = section.GetLines(); var tag = section.Type.ToString().ToLowerInvariant(); var attributes = string.Empty; if (section.Attributes.Any()) { attributes = ' ' + string.Join(" ", section.Attributes); } textGenerator.Write($"{commentPrefix} <{tag}{attributes}>"); if (lines.Count == 1) { textGenerator.Write(lines[0]); } else { textGenerator.NewLine(); foreach (var line in lines) { textGenerator.WriteLine($"{commentPrefix} <para>{line}</para>"); } textGenerator.Write($"{commentPrefix} "); } textGenerator.WriteLine($"</{tag}>"); } }