-
Notifications
You must be signed in to change notification settings - Fork 48
/
DocCommentGenerator.cs
36 lines (33 loc) · 1.12 KB
/
DocCommentGenerator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Text;
namespace Octokit.GraphQL.Core.Generation
{
internal static class DocCommentGenerator
{
public static void GenerateSummary(string summary, int indentation, StringBuilder builder)
{
if (!string.IsNullOrWhiteSpace(summary))
{
var indent = new string(' ', indentation);
builder.Append(indent);
builder.AppendLine("/// <summary>");
GenerateCommentBlock(summary, indent, builder);
builder.Append(indent);
builder.AppendLine(@"/// </summary>");
}
}
private static void GenerateCommentBlock(string text, string indent, StringBuilder builder)
{
text = text.Replace("<", "<").Replace(">", ">");
foreach (var line in text.Split('\r', '\n'))
{
if (!string.IsNullOrWhiteSpace(line))
{
builder.Append(indent);
builder.Append("/// ");
builder.AppendLine(line);
}
}
}
}
}