Skip to content

Commit 4cd2a24

Browse files
committed
Fixes to doc-comments to improve layout of generated API documentation
1 parent 4962e90 commit 4cd2a24

12 files changed

Lines changed: 87 additions & 52 deletions

File tree

src/Examples/NoEntityFrameworkExample/NullSafeExpressionRewriter.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ namespace NoEntityFrameworkExample;
66
/// <summary>
77
/// Inserts a null check on member dereference and extension method invocation, to prevent a <see cref="NullReferenceException" /> from being thrown when
88
/// the expression is compiled and executed.
9-
/// </summary>
10-
/// For example,
11-
/// <code><![CDATA[
9+
/// <example>
10+
/// For example, <code><![CDATA[
1211
/// Database.TodoItems.Where(todoItem => todoItem.Assignee.Id == todoItem.Owner.Id)
13-
/// ]]> </code>
14-
/// would throw if the database contains a
15-
/// TodoItem that doesn't have an assignee.
16-
/// <example></example>
12+
/// ]]></code> would throw if the database
13+
/// contains a TodoItem that doesn't have an assignee.
14+
/// </example>
15+
/// </summary>
1716
public sealed class NullSafeExpressionRewriter : ExpressionVisitor
1817
{
1918
private const string MinValueName = nameof(long.MinValue);

src/JsonApiDotNetCore.Annotations/Resources/Annotations/EagerLoadAttribute.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ namespace JsonApiDotNetCore.Resources.Annotations;
88
/// </summary>
99
/// <remarks>
1010
/// This is intended for calculated properties that are exposed as JSON:API attributes, which depend on a related entity to always be loaded.
11-
/// <example><![CDATA[
12-
/// public class User : Identifiable
11+
/// <example>
12+
/// <code><![CDATA[
13+
/// public class User : Identifiable<long>
1314
/// {
1415
/// [Attr(AttrCapabilities.AllowFilter | AttrCapabilities.AllowSort)]
1516
/// [NotMapped]
@@ -25,12 +26,13 @@ namespace JsonApiDotNetCore.Resources.Annotations;
2526
/// public string Last { get; set; }
2627
/// }
2728
///
28-
/// public class Blog : Identifiable
29+
/// public class Blog : Identifiable<long>
2930
/// {
3031
/// [HasOne]
3132
/// public User Author { get; set; }
3233
/// }
33-
/// ]]></example>
34+
/// ]]></code>
35+
/// </example>
3436
/// </remarks>
3537
[PublicAPI]
3638
[AttributeUsage(AttributeTargets.Property)]

src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasManyAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace JsonApiDotNetCore.Resources.Annotations;
1111
/// </summary>
1212
/// <example>
1313
/// <code><![CDATA[
14-
/// public class Author : Identifiable
14+
/// public class Author : Identifiable<long>
1515
/// {
1616
/// [HasMany]
1717
/// public ISet<Article> Articles { get; set; }

src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasOneAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace JsonApiDotNetCore.Resources.Annotations;
99
/// </summary>
1010
/// <example>
1111
/// <code><![CDATA[
12-
/// public class Article : Identifiable
12+
/// public class Article : Identifiable<long>
1313
/// {
1414
/// [HasOne]
1515
/// public Author Author { get; set; }

src/JsonApiDotNetCore.Annotations/Resources/Annotations/RelationshipAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ public abstract class RelationshipAttribute : ResourceFieldAttribute
2525
/// </summary>
2626
/// <example>
2727
/// <code><![CDATA[
28-
/// public class Article : Identifiable
28+
/// public class Article : Identifiable<long>
2929
/// {
3030
/// [HasOne] // InverseNavigationProperty: Person.Articles
3131
/// public Person Owner { get; set; }
3232
/// }
3333
///
34-
/// public class Person : Identifiable
34+
/// public class Person : Identifiable<long>
3535
/// {
3636
/// [HasMany] // InverseNavigationProperty: Article.Owner
3737
/// public ICollection<Article> Articles { get; set; }

src/JsonApiDotNetCore.Annotations/Resources/RuntimeTypeConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ public static bool CanContainNull(Type type)
167167

168168
/// <summary>
169169
/// Gets the name of a type, including the names of its generic type arguments, without any namespaces.
170-
/// <example>
171-
/// <code><![CDATA[
170+
/// </summary>
171+
/// <returns>
172+
/// Example return value: <code><![CDATA[
172173
/// KeyValuePair<TimeSpan, Nullable<DateTimeOffset>>
173174
/// ]]></code>
174-
/// </example>
175-
/// </summary>
175+
/// </returns>
176176
public static string GetFriendlyTypeName(Type type)
177177
{
178178
ArgumentNullException.ThrowIfNull(type);

src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public interface IJsonApiOptions
191191
/// Enables to customize the settings that are used by the <see cref="JsonSerializer" />.
192192
/// </summary>
193193
/// <example>
194-
/// The next example sets the naming convention to camel casing.
194+
/// The following example sets the naming convention to camel casing.
195195
/// <code><![CDATA[
196196
/// options.SerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
197197
/// options.SerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;

src/JsonApiDotNetCore/Controllers/Annotations/DisableQueryStringAttribute.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ namespace JsonApiDotNetCore.Controllers.Annotations;
66
/// <summary>
77
/// Used on an ASP.NET controller class to indicate which query string parameters are blocked.
88
/// </summary>
9-
/// <example><![CDATA[
9+
/// <example>
10+
/// <code><![CDATA[
1011
/// [DisableQueryString(JsonApiQueryStringParameters.Sort | JsonApiQueryStringParameters.Page)]
1112
/// public class CustomersController : JsonApiController<Customer> { }
12-
/// ]]></example>
13-
/// <example><![CDATA[
13+
/// ]]></code>
14+
/// <code><![CDATA[
1415
/// [DisableQueryString("skipCache")]
1516
/// public class CustomersController : JsonApiController<Customer> { }
16-
/// ]]></example>
17+
/// ]]></code>
18+
/// </example>
1719
[PublicAPI]
1820
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
1921
public sealed class DisableQueryStringAttribute : Attribute

src/JsonApiDotNetCore/Controllers/Annotations/DisableRoutingConventionAttribute.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ namespace JsonApiDotNetCore.Controllers.Annotations;
55
/// <summary>
66
/// Used on an ASP.NET controller class to indicate that a custom route is used instead of the built-in routing convention.
77
/// </summary>
8-
/// <example><![CDATA[
8+
/// <example>
9+
/// <code><![CDATA[
910
/// [DisableRoutingConvention, Route("some/custom/route/to/customers")]
1011
/// public class CustomersController : JsonApiController<Customer> { }
11-
/// ]]></example>
12+
/// ]]></code>
13+
/// </example>
1214
[PublicAPI]
1315
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
1416
public sealed class DisableRoutingConventionAttribute : Attribute;

src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resource
8686
}
8787

8888
/// <summary>
89-
/// Gets a collection of primary resources. Example: <code><![CDATA[
89+
/// Gets a collection of primary resources.
90+
/// <para>
91+
/// Example endpoint: <code language="http"><![CDATA[
9092
/// GET /articles HTTP/1.1
9193
/// ]]></code>
94+
/// </para>
9295
/// </summary>
9396
public virtual async Task<IActionResult> GetAsync(CancellationToken cancellationToken)
9497
{
@@ -105,9 +108,12 @@ public virtual async Task<IActionResult> GetAsync(CancellationToken cancellation
105108
}
106109

107110
/// <summary>
108-
/// Gets a single primary resource by ID. Example: <code><![CDATA[
111+
/// Gets a single primary resource by ID.
112+
/// <para>
113+
/// Example endpoint: <code language="http"><![CDATA[
109114
/// GET /articles/1 HTTP/1.1
110115
/// ]]></code>
116+
/// </para>
111117
/// </summary>
112118
public virtual async Task<IActionResult> GetAsync([DisallowNull] TId id, CancellationToken cancellationToken)
113119
{
@@ -127,12 +133,15 @@ public virtual async Task<IActionResult> GetAsync([DisallowNull] TId id, Cancell
127133
}
128134

129135
/// <summary>
130-
/// Gets a secondary resource or collection of secondary resources. Example: <code><![CDATA[
136+
/// Gets a secondary resource or collection of secondary resources.
137+
/// <para>
138+
/// Example endpoints: <code language="http"><![CDATA[
131139
/// GET /articles/1/author HTTP/1.1
132-
/// ]]></code> Example:
133-
/// <code><![CDATA[
140+
/// ]]></code>
141+
/// <code language="http"><![CDATA[
134142
/// GET /articles/1/revisions HTTP/1.1
135143
/// ]]></code>
144+
/// </para>
136145
/// </summary>
137146
public virtual async Task<IActionResult> GetSecondaryAsync([DisallowNull] TId id, [PreserveEmptyString] string relationshipName,
138147
CancellationToken cancellationToken)
@@ -156,13 +165,15 @@ public virtual async Task<IActionResult> GetSecondaryAsync([DisallowNull] TId id
156165
}
157166

158167
/// <summary>
159-
/// Gets a relationship value, which can be a <c>null</c>, a single object or a collection. Example:
160-
/// <code><![CDATA[
168+
/// Gets a relationship value, which can be a <c>null</c>, a single object or a collection.
169+
/// <para>
170+
/// Example endpoints: <code language="http"><![CDATA[
161171
/// GET /articles/1/relationships/author HTTP/1.1
162-
/// ]]></code> Example:
163-
/// <code><![CDATA[
172+
/// ]]></code>
173+
/// <code language="http"><![CDATA[
164174
/// GET /articles/1/relationships/revisions HTTP/1.1
165175
/// ]]></code>
176+
/// </para>
166177
/// </summary>
167178
public virtual async Task<IActionResult> GetRelationshipAsync([DisallowNull] TId id, [PreserveEmptyString] string relationshipName,
168179
CancellationToken cancellationToken)
@@ -186,9 +197,12 @@ public virtual async Task<IActionResult> GetRelationshipAsync([DisallowNull] TId
186197
}
187198

188199
/// <summary>
189-
/// Creates a new resource with attributes, relationships or both. Example: <code><![CDATA[
200+
/// Creates a new resource with attributes, relationships or both.
201+
/// <para>
202+
/// Example endpoint: <code language="http"><![CDATA[
190203
/// POST /articles HTTP/1.1
191204
/// ]]></code>
205+
/// </para>
192206
/// </summary>
193207
public virtual async Task<IActionResult> PostAsync([FromBody] TResource resource, CancellationToken cancellationToken)
194208
{
@@ -233,9 +247,12 @@ private string GetLocationUrl(string resourceId)
233247
}
234248

235249
/// <summary>
236-
/// Adds resources to a to-many relationship. Example: <code><![CDATA[
250+
/// Adds resources to a to-many relationship.
251+
/// <para>
252+
/// Example endpoint: <code language="http"><![CDATA[
237253
/// POST /articles/1/revisions HTTP/1.1
238254
/// ]]></code>
255+
/// </para>
239256
/// </summary>
240257
/// <param name="id">
241258
/// Identifies the left side of the relationship.
@@ -274,9 +291,12 @@ public virtual async Task<IActionResult> PostRelationshipAsync([DisallowNull] TI
274291

275292
/// <summary>
276293
/// Updates the attributes and/or relationships of an existing resource. Only the values of sent attributes are replaced. And only the values of sent
277-
/// relationships are replaced. Example: <code><![CDATA[
294+
/// relationships are replaced.
295+
/// <para>
296+
/// Example endpoint: <code language="http"><![CDATA[
278297
/// PATCH /articles/1 HTTP/1.1
279298
/// ]]></code>
299+
/// </para>
280300
/// </summary>
281301
public virtual async Task<IActionResult> PatchAsync([DisallowNull] TId id, [FromBody] TResource resource, CancellationToken cancellationToken)
282302
{
@@ -304,13 +324,15 @@ public virtual async Task<IActionResult> PatchAsync([DisallowNull] TId id, [From
304324
}
305325

306326
/// <summary>
307-
/// Performs a complete replacement of a relationship on an existing resource. Example:
308-
/// <code><![CDATA[
327+
/// Performs a complete replacement of a relationship on an existing resource.
328+
/// <para>
329+
/// Example endpoints: <code language="http"><![CDATA[
309330
/// PATCH /articles/1/relationships/author HTTP/1.1
310-
/// ]]></code> Example:
311-
/// <code><![CDATA[
331+
/// ]]></code>
332+
/// <code language="http"><![CDATA[
312333
/// PATCH /articles/1/relationships/revisions HTTP/1.1
313334
/// ]]></code>
335+
/// </para>
314336
/// </summary>
315337
/// <param name="id">
316338
/// Identifies the left side of the relationship.
@@ -347,9 +369,12 @@ public virtual async Task<IActionResult> PatchRelationshipAsync([DisallowNull] T
347369
}
348370

349371
/// <summary>
350-
/// Deletes an existing resource. Example: <code><![CDATA[
372+
/// Deletes an existing resource.
373+
/// <para>
374+
/// Example endpoint: <code language="http"><![CDATA[
351375
/// DELETE /articles/1 HTTP/1.1
352376
/// ]]></code>
377+
/// </para>
353378
/// </summary>
354379
public virtual async Task<IActionResult> DeleteAsync([DisallowNull] TId id, CancellationToken cancellationToken)
355380
{
@@ -369,9 +394,12 @@ public virtual async Task<IActionResult> DeleteAsync([DisallowNull] TId id, Canc
369394
}
370395

371396
/// <summary>
372-
/// Removes resources from a to-many relationship. Example: <code><![CDATA[
397+
/// Removes resources from a to-many relationship.
398+
/// <para>
399+
/// Example endpoint: <code language="http"><![CDATA[
373400
/// DELETE /articles/1/relationships/revisions HTTP/1.1
374401
/// ]]></code>
402+
/// </para>
375403
/// </summary>
376404
/// <param name="id">
377405
/// Identifies the left side of the relationship.

0 commit comments

Comments
 (0)