Skip to content

Commit d8612f3

Browse files
Jabenclaude
andcommitted
Add comprehensive XML documentation to domain types
Completes Phase 6 by documenting three key domain types used throughout the client API. Documented classes: - PageRanges: Documented Chrome print format syntax ("1-5,8,11-13") and clarified that empty collection means all pages - ContentItem: Documented all three constructors with use cases (byte[] for binary, string for HTML/text, Stream for files) - ExtraUrlResourceItem: Documented resource injection for URL conversions with CSS vs JavaScript distinction Key improvements: - CRITICAL: PageRanges.Create() now documents the expected format - Explained when to use each ContentItem constructor - Clarified ExtraUrlResourceItem usage for CSS/JS injection - Added comprehensive exception documentation - Documented public properties and methods Users can now understand how to construct and use these types from IntelliSense without referring to external documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6e89d49 commit d8612f3

3 files changed

Lines changed: 82 additions & 2 deletions

File tree

src/Gotenberg.Sharp.Api.Client/Domain/Pages/PageRanges.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
namespace Gotenberg.Sharp.API.Client.Domain.Pages;
2020

21+
/// <summary>
22+
/// Represents a specification of which pages to include in a PDF. Supports individual pages and ranges.
23+
/// </summary>
24+
/// <remarks>
25+
/// Format follows Chrome print dialog syntax: "1-5,8,11-13" includes pages 1 through 5, page 8, and pages 11 through 13.
26+
/// </remarks>
2127
public sealed class PageRanges : IEquatable<PageRanges>
2228
{
2329
private static readonly Regex PageRangePattern =
@@ -28,15 +34,32 @@ private PageRanges(IReadOnlyCollection<int> pages)
2834
Pages = pages.OrderBy(p => p).ToArray();
2935
}
3036

37+
/// <summary>
38+
/// Represents all pages (no filtering applied).
39+
/// </summary>
3140
public static PageRanges All { get; } = new(Array.Empty<int>());
3241

42+
/// <summary>
43+
/// Gets the collection of page numbers included in this range. Empty collection means all pages.
44+
/// </summary>
3345
public IReadOnlyCollection<int> Pages { get; }
3446

47+
/// <summary>
48+
/// Determines whether this page range equals another page range.
49+
/// </summary>
50+
/// <param name="other">The page range to compare with.</param>
51+
/// <returns>True if the page ranges are equal.</returns>
3552
public bool Equals(PageRanges? other)
3653
{
3754
return other is not null && Pages.SequenceEqual(other.Pages);
3855
}
3956

57+
/// <summary>
58+
/// Creates a PageRanges instance from a string specification using Chrome print format.
59+
/// </summary>
60+
/// <param name="input">Page range string (e.g., "1-5,8,11-13") or null/empty for all pages.</param>
61+
/// <returns>A PageRanges instance representing the specified pages.</returns>
62+
/// <exception cref="ArgumentOutOfRangeException">Thrown when the format is invalid.</exception>
4063
public static PageRanges Create(string? input)
4164
{
4265
if (string.IsNullOrWhiteSpace(input))
@@ -102,16 +125,29 @@ private string GetPageRangeString()
102125
return string.Join(", ", ranges);
103126
}
104127

128+
/// <summary>
129+
/// Returns the page range as a string in Chrome print format (e.g., "1-5,8,11-13").
130+
/// </summary>
131+
/// <returns>Page range string, or empty string for all pages.</returns>
105132
public override string ToString()
106133
{
107134
return GetPageRangeString();
108135
}
109136

137+
/// <summary>
138+
/// Determines whether this page range equals another object.
139+
/// </summary>
140+
/// <param name="obj">The object to compare with.</param>
141+
/// <returns>True if the objects represent the same page range.</returns>
110142
public override bool Equals(object? obj)
111143
{
112144
return obj is PageRanges other && Pages.SequenceEqual(other.Pages);
113145
}
114146

147+
/// <summary>
148+
/// Returns a hash code for this page range.
149+
/// </summary>
150+
/// <returns>A hash code based on the included pages.</returns>
115151
public override int GetHashCode()
116152
{
117153
return Pages.Aggregate(0, (hash, page) => hash ^ page.GetHashCode());

src/Gotenberg.Sharp.Api.Client/Domain/Requests/Facets/ContentItem.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
namespace Gotenberg.Sharp.API.Client.Domain.Requests.Facets
1919
{
20+
/// <summary>
21+
/// Represents content for PDF conversion requests. Supports content from strings, byte arrays, or streams.
22+
/// Used for HTML, Markdown, headers, footers, and file assets.
23+
/// </summary>
2024
public sealed class ContentItem
2125
{
2226
readonly Func<HttpContent> _getHttpContent;
@@ -26,25 +30,44 @@ public sealed class ContentItem
2630
_getHttpContent = getHttpContent;
2731
}
2832

33+
/// <summary>
34+
/// Creates content from a byte array. Use for binary files like images, PDFs, or Office documents.
35+
/// </summary>
36+
/// <param name="bytes">The content as bytes.</param>
37+
/// <exception cref="ArgumentNullException">Thrown when bytes is null.</exception>
2938
public ContentItem(byte[] bytes)
3039
: this(() => new ByteArrayContent(bytes))
3140
{
3241
if (bytes == null) throw new ArgumentNullException(nameof(bytes));
3342
}
3443

44+
/// <summary>
45+
/// Creates content from a string. Use for HTML, Markdown, or text content.
46+
/// </summary>
47+
/// <param name="str">The content as a string.</param>
48+
/// <exception cref="ArgumentOutOfRangeException">Thrown when string is null or empty.</exception>
3549
public ContentItem(string str)
3650
: this(() => new StringContent(str))
3751
{
3852
if (str.IsNotSet())
3953
throw new ArgumentOutOfRangeException(nameof(str), "Must not be null or empty");
4054
}
4155

56+
/// <summary>
57+
/// Creates content from a stream. Use when loading content from files or network sources.
58+
/// </summary>
59+
/// <param name="stream">The content stream.</param>
60+
/// <exception cref="ArgumentNullException">Thrown when stream is null.</exception>
4261
public ContentItem(Stream stream)
4362
: this(() => new StreamContent(stream))
4463
{
4564
if (stream == null) throw new ArgumentNullException(nameof(stream));
4665
}
4766

67+
/// <summary>
68+
/// Converts this content item to HttpContent for transmission to Gotenberg.
69+
/// </summary>
70+
/// <returns>HttpContent representing this content item.</returns>
4871
public HttpContent ToHttpContentItem()
4972
{
5073
return _getHttpContent();

src/Gotenberg.Sharp.Api.Client/Domain/Requests/Facets/UrlExtras/ExtraUrlResourceItem.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,34 @@ namespace Gotenberg.Sharp.API.Client.Domain.Requests.Facets.UrlExtras;
2121

2222
using urlConstants = Constants.Gotenberg.Chromium.Routes.Url;
2323

24+
/// <summary>
25+
/// Represents an external resource (CSS stylesheet or JavaScript file) to inject into URL-based PDF conversions.
26+
/// </summary>
2427
public class ExtraUrlResourceItem
2528
{
2629
const string LinkFieldName = urlConstants.ExtraLinkTags;
2730

2831
const string ScriptFieldName = urlConstants.ExtraScriptTags;
2932

33+
/// <summary>
34+
/// Creates an extra resource item from a URL string.
35+
/// </summary>
36+
/// <param name="url">Absolute URL of the CSS or JavaScript resource.</param>
37+
/// <param name="itemType">Type of resource (LinkTag for CSS, ScriptTag for JavaScript).</param>
38+
/// <exception cref="InvalidOperationException">Thrown when URL is not absolute.</exception>
3039
public ExtraUrlResourceItem(string url, ExtraUrlResourceType itemType)
3140
: this(new Uri(url), itemType)
3241
{
3342
}
3443

44+
/// <summary>
45+
/// Creates an extra resource item from a URI.
46+
/// </summary>
47+
/// <param name="url">Absolute URI of the CSS or JavaScript resource.</param>
48+
/// <param name="itemType">Type of resource (LinkTag for CSS, ScriptTag for JavaScript).</param>
49+
/// <exception cref="ArgumentNullException">Thrown when URL is null.</exception>
50+
/// <exception cref="InvalidOperationException">Thrown when URL is not absolute.</exception>
51+
/// <exception cref="InvalidEnumArgumentException">Thrown when itemType is not valid.</exception>
3552
public ExtraUrlResourceItem(Uri url, ExtraUrlResourceType itemType)
3653
{
3754
Url = url ?? throw new ArgumentNullException(nameof(url));
@@ -44,10 +61,14 @@ public ExtraUrlResourceItem(Uri url, ExtraUrlResourceType itemType)
4461
itemType == ExtraUrlResourceType.LinkTag ? LinkFieldName : ScriptFieldName;
4562
}
4663

47-
64+
/// <summary>
65+
/// Gets the URL of the resource to inject.
66+
/// </summary>
4867
public Uri Url { get; }
4968

50-
69+
/// <summary>
70+
/// Gets the type of resource (LinkTag for CSS, ScriptTag for JavaScript).
71+
/// </summary>
5172
public ExtraUrlResourceType ItemType { get; }
5273

5374
internal string FormDataFieldName { get; }

0 commit comments

Comments
 (0)