Skip to content

Commit 85bf2d4

Browse files
authored
Merge pull request #175 from octokit/add-input-object-comments
Add doc comments to input objects
2 parents 37402a3 + 5031f2c commit 85bf2d4

File tree

72 files changed

+778
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+778
-14
lines changed

Octokit.GraphQL.Core.Generation.UnitTests/InputObjectGenerationTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,31 @@ public void Generates_Property_For_List_Field()
6666
CompareModel("InputObject.cs", expected, result);
6767
}
6868

69+
[Fact]
70+
public void Generates_Property_For_List_Field_With_Description()
71+
{
72+
var expected = FormatMemberTemplate("/// <summary>\r\n /// Field foo for InputObject\r\n /// </summary>\r\n public IEnumerable<int?> Foo { get; set; }");
73+
74+
var model = new TypeModel
75+
{
76+
Name = "InputObject",
77+
Kind = TypeKind.InputObject,
78+
InputFields = new[]
79+
{
80+
new InputValueModel
81+
{
82+
Description = "Field foo for InputObject",
83+
Name = "foo",
84+
Type = TypeModel.List(TypeModel.Int())
85+
},
86+
}
87+
};
88+
89+
var result = CodeGenerator.Generate(model, "Test", null);
90+
91+
CompareModel("InputObject.cs", expected, result);
92+
}
93+
6994
private string FormatMemberTemplate(string members)
7095
{
7196
if (members != null)

Octokit.GraphQL.Core.Generation/InputObjectGenerator.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ private static string GenerateFields(TypeModel type)
5252

5353
private static string GenerateField(InputValueModel field)
5454
{
55+
var result = GenerateDocComments(field);
5556
var name = TypeUtilities.PascalCase(field.Name);
5657
var typeName = TypeUtilities.GetCSharpArgType(field.Type);
57-
return $" public {typeName} {name} {{ get; set; }}";
58+
return result + $" public {typeName} {name} {{ get; set; }}";
5859
}
5960

6061
private static string GenerateDocComments(TypeModel type)
@@ -72,24 +73,12 @@ private static string GenerateDocComments(TypeModel type)
7273
}
7374
}
7475

75-
private static string GenerateDocComments(FieldModel field)
76+
private static string GenerateDocComments(InputValueModel field)
7677
{
7778
if (!string.IsNullOrWhiteSpace(field.Description))
7879
{
7980
var builder = new StringBuilder();
8081
DocCommentGenerator.GenerateSummary(field.Description, 8, builder);
81-
82-
if (field.Args != null)
83-
{
84-
foreach (var arg in field.Args)
85-
{
86-
if (!string.IsNullOrWhiteSpace(arg.Description))
87-
{
88-
builder.AppendLine($" /// <param name=\"{arg.Name}\">{arg.Description}</param>");
89-
}
90-
}
91-
}
92-
9382
return builder.ToString();
9483
}
9584
else

Octokit.GraphQL/Model/AcceptTopicSuggestionInput.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ namespace Octokit.GraphQL.Model
88
/// </summary>
99
public class AcceptTopicSuggestionInput
1010
{
11+
/// <summary>
12+
/// The Node ID of the repository.
13+
/// </summary>
1114
public ID RepositoryId { get; set; }
1215

16+
/// <summary>
17+
/// The name of the suggested topic.
18+
/// </summary>
1319
public string Name { get; set; }
1420

21+
/// <summary>
22+
/// A unique identifier for the client performing the mutation.
23+
/// </summary>
1524
public string ClientMutationId { get; set; }
1625
}
1726
}

Octokit.GraphQL/Model/AddCommentInput.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ namespace Octokit.GraphQL.Model
88
/// </summary>
99
public class AddCommentInput
1010
{
11+
/// <summary>
12+
/// The Node ID of the subject to modify.
13+
/// </summary>
1114
public ID SubjectId { get; set; }
1215

16+
/// <summary>
17+
/// The contents of the comment.
18+
/// </summary>
1319
public string Body { get; set; }
1420

21+
/// <summary>
22+
/// A unique identifier for the client performing the mutation.
23+
/// </summary>
1524
public string ClientMutationId { get; set; }
1625
}
1726
}

Octokit.GraphQL/Model/AddProjectCardInput.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,24 @@ namespace Octokit.GraphQL.Model
88
/// </summary>
99
public class AddProjectCardInput
1010
{
11+
/// <summary>
12+
/// The Node ID of the ProjectColumn.
13+
/// </summary>
1114
public ID ProjectColumnId { get; set; }
1215

16+
/// <summary>
17+
/// The content of the card. Must be a member of the ProjectCardItem union
18+
/// </summary>
1319
public ID? ContentId { get; set; }
1420

21+
/// <summary>
22+
/// The note on the card.
23+
/// </summary>
1524
public string Note { get; set; }
1625

26+
/// <summary>
27+
/// A unique identifier for the client performing the mutation.
28+
/// </summary>
1729
public string ClientMutationId { get; set; }
1830
}
1931
}

Octokit.GraphQL/Model/AddProjectColumnInput.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ namespace Octokit.GraphQL.Model
88
/// </summary>
99
public class AddProjectColumnInput
1010
{
11+
/// <summary>
12+
/// The Node ID of the project.
13+
/// </summary>
1114
public ID ProjectId { get; set; }
1215

16+
/// <summary>
17+
/// The name of the column.
18+
/// </summary>
1319
public string Name { get; set; }
1420

21+
/// <summary>
22+
/// A unique identifier for the client performing the mutation.
23+
/// </summary>
1524
public string ClientMutationId { get; set; }
1625
}
1726
}

Octokit.GraphQL/Model/AddPullRequestReviewCommentInput.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,39 @@ namespace Octokit.GraphQL.Model
88
/// </summary>
99
public class AddPullRequestReviewCommentInput
1010
{
11+
/// <summary>
12+
/// The Node ID of the review to modify.
13+
/// </summary>
1114
public ID PullRequestReviewId { get; set; }
1215

16+
/// <summary>
17+
/// The SHA of the commit to comment on.
18+
/// </summary>
1319
public string CommitOID { get; set; }
1420

21+
/// <summary>
22+
/// The text of the comment.
23+
/// </summary>
1524
public string Body { get; set; }
1625

26+
/// <summary>
27+
/// The relative path of the file to comment on.
28+
/// </summary>
1729
public string Path { get; set; }
1830

31+
/// <summary>
32+
/// The line index in the diff to comment on.
33+
/// </summary>
1934
public int? Position { get; set; }
2035

36+
/// <summary>
37+
/// The comment id to reply to.
38+
/// </summary>
2139
public ID? InReplyTo { get; set; }
2240

41+
/// <summary>
42+
/// A unique identifier for the client performing the mutation.
43+
/// </summary>
2344
public string ClientMutationId { get; set; }
2445
}
2546
}

Octokit.GraphQL/Model/AddPullRequestReviewInput.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,34 @@ namespace Octokit.GraphQL.Model
88
/// </summary>
99
public class AddPullRequestReviewInput
1010
{
11+
/// <summary>
12+
/// The Node ID of the pull request to modify.
13+
/// </summary>
1114
public ID PullRequestId { get; set; }
1215

16+
/// <summary>
17+
/// The commit OID the review pertains to.
18+
/// </summary>
1319
public string CommitOID { get; set; }
1420

21+
/// <summary>
22+
/// The contents of the review body comment.
23+
/// </summary>
1524
public string Body { get; set; }
1625

26+
/// <summary>
27+
/// The event to perform on the pull request review.
28+
/// </summary>
1729
public PullRequestReviewEvent? Event { get; set; }
1830

31+
/// <summary>
32+
/// The review line comments.
33+
/// </summary>
1934
public IEnumerable<DraftPullRequestReviewComment> Comments { get; set; }
2035

36+
/// <summary>
37+
/// A unique identifier for the client performing the mutation.
38+
/// </summary>
2139
public string ClientMutationId { get; set; }
2240
}
2341
}

Octokit.GraphQL/Model/AddReactionInput.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ namespace Octokit.GraphQL.Model
88
/// </summary>
99
public class AddReactionInput
1010
{
11+
/// <summary>
12+
/// The Node ID of the subject to modify.
13+
/// </summary>
1114
public ID SubjectId { get; set; }
1215

16+
/// <summary>
17+
/// The name of the emoji to react with.
18+
/// </summary>
1319
public ReactionContent Content { get; set; }
1420

21+
/// <summary>
22+
/// A unique identifier for the client performing the mutation.
23+
/// </summary>
1524
public string ClientMutationId { get; set; }
1625
}
1726
}

Octokit.GraphQL/Model/AddStarInput.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ namespace Octokit.GraphQL.Model
88
/// </summary>
99
public class AddStarInput
1010
{
11+
/// <summary>
12+
/// The Starrable ID to star.
13+
/// </summary>
1114
public ID StarrableId { get; set; }
1215

16+
/// <summary>
17+
/// A unique identifier for the client performing the mutation.
18+
/// </summary>
1319
public string ClientMutationId { get; set; }
1420
}
1521
}

0 commit comments

Comments
 (0)