Skip to content

Commit 85d4236

Browse files
Jabenclaude
andcommitted
Add comprehensive XML documentation to faceted builders
Completes Phase 3 of documentation improvement by adding detailed XML documentation to all faceted builder classes. These builders configure specific aspects of PDF conversion requests. Documented classes: - ConfigBuilder: Request-level settings (page ranges, webhooks, trace ID) - HtmlConversionBehaviorBuilder: Chromium rendering behaviors (improved AddAdditionalHeaders docs) - WebhookBuilder: Async PDF generation callbacks - UrlHeaderFooterBuilder: Custom headers/footers for URL conversions - UrlExtraResourcesBuilder: CSS/JS injection for URL conversions Key improvements: - Explained webhook purpose and Docker networking considerations - Clarified trace ID usage for distributed system correlation - Documented extra resources (CSS/JS injection) purpose and usage - Added HTTP header injection use cases (authentication, correlation) - Explained error URL callback functionality All builder documentation follows consistent format with clear parameter descriptions, return types, and exception documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5ebf548 commit 85d4236

5 files changed

Lines changed: 217 additions & 41 deletions

File tree

src/Gotenberg.Sharp.Api.Client/Domain/Builders/Faceted/ConfigBuilder.cs

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

1818
namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;
1919

20+
/// <summary>
21+
/// Configures request-level settings including page ranges, webhooks, result filename, and trace ID for correlation.
22+
/// </summary>
2023
public sealed class ConfigBuilder
2124
{
2225
private readonly RequestConfig _requestConfig;
@@ -26,13 +29,23 @@ internal ConfigBuilder(RequestConfig requestConfig)
2629
this._requestConfig = requestConfig;
2730
}
2831

32+
/// <summary>
33+
/// Specifies which pages to include in the resulting PDF using Chrome print format (e.g., "1-3,5,7-9").
34+
/// </summary>
35+
/// <param name="pageRanges">Page range specification string, or null for all pages.</param>
36+
/// <returns>The builder instance for method chaining.</returns>
2937
public ConfigBuilder SetPageRanges(string? pageRanges)
3038
{
3139
this._requestConfig.PageRanges = Pages.PageRanges.Create(pageRanges);
3240

3341
return this;
3442
}
3543

44+
/// <summary>
45+
/// Sets page ranges using a PageRanges instance.
46+
/// </summary>
47+
/// <param name="pageRanges">Pre-configured PageRanges instance, or null for all pages.</param>
48+
/// <returns>The builder instance for method chaining.</returns>
3649
public ConfigBuilder SetPageRanges(PageRanges? pageRanges)
3750
{
3851
this._requestConfig.PageRanges = pageRanges ?? Pages.PageRanges.All;
@@ -46,6 +59,13 @@ public ConfigBuilder PageRanges(string pageRanges)
4659
return this.SetPageRanges(pageRanges);
4760
}
4861

62+
/// <summary>
63+
/// Sets the suggested filename for the resulting PDF when Gotenberg returns it.
64+
/// Useful when using webhooks to identify which request generated which PDF.
65+
/// </summary>
66+
/// <param name="resultFileName">Desired filename for the PDF result.</param>
67+
/// <returns>The builder instance for method chaining.</returns>
68+
/// <exception cref="ArgumentException">Thrown when filename is null or empty.</exception>
4969
public ConfigBuilder SetResultFileName(string resultFileName)
5070
{
5171
if (resultFileName.IsNotSet())
@@ -62,6 +82,13 @@ public ConfigBuilder ResultFileName(string resultFileName)
6282
return this.SetResultFileName(resultFileName);
6383
}
6484

85+
/// <summary>
86+
/// Sets a trace ID for correlating this request across logs and metrics in both your application and Gotenberg.
87+
/// Useful for debugging and monitoring distributed systems.
88+
/// </summary>
89+
/// <param name="trace">Trace or correlation ID for this request.</param>
90+
/// <returns>The builder instance for method chaining.</returns>
91+
/// <exception cref="ArgumentException">Thrown when trace is null or empty.</exception>
6592
public ConfigBuilder SetTrace(string trace)
6693
{
6794
if (trace.IsNotSet())
@@ -72,6 +99,12 @@ public ConfigBuilder SetTrace(string trace)
7299
return this;
73100
}
74101

102+
/// <summary>
103+
/// Configures webhook settings for asynchronous PDF generation. When configured, Gotenberg will POST the
104+
/// generated PDF to the specified URL instead of returning it in the response.
105+
/// </summary>
106+
/// <param name="action">Configuration action for webhook settings.</param>
107+
/// <returns>The builder instance for method chaining.</returns>
75108
public ConfigBuilder AddWebhook(Action<WebhookBuilder> action)
76109
{
77110
if (action == null) throw new ArgumentNullException(nameof(action));
@@ -83,6 +116,11 @@ public ConfigBuilder AddWebhook(Action<WebhookBuilder> action)
83116
return this;
84117
}
85118

119+
/// <summary>
120+
/// Sets pre-configured webhook settings.
121+
/// </summary>
122+
/// <param name="webhook">Pre-configured Webhook instance.</param>
123+
/// <returns>The builder instance for method chaining.</returns>
86124
public ConfigBuilder SetWebhook(Webhook webhook)
87125
{
88126
this._requestConfig.Webhook = webhook ?? throw new ArgumentNullException(nameof(webhook));

src/Gotenberg.Sharp.Api.Client/Domain/Builders/Faceted/HtmlConversionBehaviorBuilder.cs

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

1818
namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;
1919

20+
/// <summary>
21+
/// Configures Chromium rendering behaviors for HTML and URL to PDF conversions.
22+
/// Includes settings for wait delays, HTTP headers, cookies, metadata, PDF format, and accessibility.
23+
/// </summary>
2024
public sealed class HtmlConversionBehaviorBuilder
2125
{
2226
private readonly HtmlConversionBehaviors _htmlConversionBehaviors;
@@ -79,13 +83,13 @@ public HtmlConversionBehaviorBuilder SetUserAgent(string userAgent)
7983
}
8084

8185
/// <summary>
82-
/// Sets extra HTTP headers that Chromium will send when loading the HTML
86+
/// Adds custom HTTP headers that Chromium will send when loading the HTML. Useful for authentication tokens,
87+
/// custom request identification, or triggering specific server behavior.
8388
/// </summary>
84-
/// <param name="headerName"></param>
85-
/// <param name="headerValue"></param>
86-
/// <returns></returns>
87-
/// <exception cref="InvalidOperationException"></exception>
88-
/// <exception cref="JsonReaderException"></exception>
89+
/// <param name="headerName">HTTP header name.</param>
90+
/// <param name="headerValue">HTTP header value.</param>
91+
/// <returns>The builder instance for method chaining.</returns>
92+
/// <exception cref="InvalidOperationException">Thrown when header name or value is invalid.</exception>
8993
public HtmlConversionBehaviorBuilder AddAdditionalHeaders(string headerName, string headerValue)
9094
{
9195
var header = string.Format("{0}{2}{1}", "{", "}", $"{'"'}{headerName}{'"'} : {'"'}{headerValue}{'"'}");
@@ -94,11 +98,11 @@ public HtmlConversionBehaviorBuilder AddAdditionalHeaders(string headerName, str
9498
}
9599

96100
/// <summary>
97-
/// Sets extra HTTP headers that Chromium will send when loading the HTML
101+
/// Adds multiple custom HTTP headers as a JSON object. Useful for adding several headers at once.
98102
/// </summary>
99-
/// <param name="extraHeaders"></param>
100-
/// <returns></returns>
101-
/// <exception cref="InvalidOperationException"></exception>
103+
/// <param name="extraHeaders">JSON object containing header name-value pairs.</param>
104+
/// <returns>The builder instance for method chaining.</returns>
105+
/// <exception cref="InvalidOperationException">Thrown when extraHeaders is null.</exception>
102106
public HtmlConversionBehaviorBuilder AddAdditionalHeaders(JObject extraHeaders)
103107
{
104108
if (extraHeaders == null)

src/Gotenberg.Sharp.Api.Client/Domain/Builders/Faceted/UrlExtraResourcesBuilder.cs

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,38 @@
1919

2020
namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;
2121

22+
/// <summary>
23+
/// Injects additional CSS stylesheets or JavaScript files into a URL-based PDF conversion before rendering.
24+
/// Useful for adding custom styling or scripts to pages you don't control.
25+
/// </summary>
26+
/// <remarks>
27+
/// Link tags inject CSS stylesheets (&lt;link rel="stylesheet"&gt;).
28+
/// Script tags inject JavaScript files (&lt;script src="..."&gt;).
29+
/// </remarks>
2230
public sealed class UrlExtraResourcesBuilder(ExtraUrlResources extraUrlResources)
2331
{
2432
#region add one
2533

2634
#region link tag
2735

28-
36+
/// <summary>
37+
/// Injects a CSS stylesheet link tag into the page before rendering.
38+
/// </summary>
39+
/// <param name="url">URL of the CSS stylesheet to inject.</param>
40+
/// <returns>The builder instance for method chaining.</returns>
41+
/// <exception cref="InvalidOperationException">Thrown when URL is null or empty.</exception>
2942
public UrlExtraResourcesBuilder AddLinkTag(string url)
3043
{
3144
if (url.IsNotSet()) throw new InvalidOperationException(nameof(url));
3245

3346
return this.AddLinkTag(new Uri(url));
3447
}
3548

36-
49+
/// <summary>
50+
/// Injects a CSS stylesheet link tag into the page before rendering.
51+
/// </summary>
52+
/// <param name="url">URI of the CSS stylesheet to inject.</param>
53+
/// <returns>The builder instance for method chaining.</returns>
3754
public UrlExtraResourcesBuilder AddLinkTag(Uri url)
3855
{
3956
return this.AddItem(new ExtraUrlResourceItem(url, ExtraUrlResourceType.LinkTag));
@@ -43,15 +60,24 @@ public UrlExtraResourcesBuilder AddLinkTag(Uri url)
4360

4461
#region script tag
4562

46-
63+
/// <summary>
64+
/// Injects a JavaScript script tag into the page before rendering.
65+
/// </summary>
66+
/// <param name="url">URL of the JavaScript file to inject.</param>
67+
/// <returns>The builder instance for method chaining.</returns>
68+
/// <exception cref="InvalidOperationException">Thrown when URL is null or empty.</exception>
4769
public UrlExtraResourcesBuilder AddScriptTag(string url)
4870
{
4971
if (url.IsNotSet()) throw new InvalidOperationException(nameof(url));
5072

5173
return this.AddScriptTag(new Uri(url));
5274
}
5375

54-
76+
/// <summary>
77+
/// Injects a JavaScript script tag into the page before rendering.
78+
/// </summary>
79+
/// <param name="url">URI of the JavaScript file to inject.</param>
80+
/// <returns>The builder instance for method chaining.</returns>
5581
public UrlExtraResourcesBuilder AddScriptTag(Uri url)
5682
{
5783
return this.AddItem(new ExtraUrlResourceItem(url, ExtraUrlResourceType.ScriptTag));
@@ -61,7 +87,11 @@ public UrlExtraResourcesBuilder AddScriptTag(Uri url)
6187

6288
#region caller specifies type
6389

64-
90+
/// <summary>
91+
/// Adds a single extra resource with explicit type specification.
92+
/// </summary>
93+
/// <param name="item">Resource item with URL and type (LinkTag or ScriptTag).</param>
94+
/// <returns>The builder instance for method chaining.</returns>
6595
public UrlExtraResourcesBuilder AddItem(ExtraUrlResourceItem item)
6696
{
6797
return this.AddItems(new[] { item ?? throw new ArgumentNullException(nameof(item)) });
@@ -75,13 +105,21 @@ public UrlExtraResourcesBuilder AddItem(ExtraUrlResourceItem item)
75105

76106
#region link tags
77107

78-
108+
/// <summary>
109+
/// Injects multiple CSS stylesheet link tags into the page.
110+
/// </summary>
111+
/// <param name="urls">Collection of CSS stylesheet URLs to inject.</param>
112+
/// <returns>The builder instance for method chaining.</returns>
79113
public UrlExtraResourcesBuilder AddLinkTags(IEnumerable<string> urls)
80114
{
81115
return this.AddLinkTags(urls.IfNullEmpty().Select(u => new Uri(u)));
82116
}
83117

84-
118+
/// <summary>
119+
/// Injects multiple CSS stylesheet link tags into the page.
120+
/// </summary>
121+
/// <param name="urls">Collection of CSS stylesheet URIs to inject.</param>
122+
/// <returns>The builder instance for method chaining.</returns>
85123
public UrlExtraResourcesBuilder AddLinkTags(IEnumerable<Uri> urls)
86124
{
87125
return this.AddItems(
@@ -93,13 +131,21 @@ public UrlExtraResourcesBuilder AddLinkTags(IEnumerable<Uri> urls)
93131

94132
#region script tags
95133

96-
134+
/// <summary>
135+
/// Injects multiple JavaScript script tags into the page.
136+
/// </summary>
137+
/// <param name="urls">Collection of JavaScript file URLs to inject.</param>
138+
/// <returns>The builder instance for method chaining.</returns>
97139
public UrlExtraResourcesBuilder AddScriptTags(IEnumerable<string> urls)
98140
{
99141
return this.AddScriptTags(urls.IfNullEmpty().Select(u => new Uri(u)));
100142
}
101143

102-
144+
/// <summary>
145+
/// Injects multiple JavaScript script tags into the page.
146+
/// </summary>
147+
/// <param name="urls">Collection of JavaScript file URIs to inject.</param>
148+
/// <returns>The builder instance for method chaining.</returns>
103149
public UrlExtraResourcesBuilder AddScriptTags(IEnumerable<Uri> urls)
104150
{
105151
return this.AddItems(
@@ -111,7 +157,11 @@ public UrlExtraResourcesBuilder AddScriptTags(IEnumerable<Uri> urls)
111157

112158
#region caller specifies type
113159

114-
160+
/// <summary>
161+
/// Adds multiple extra resources with explicit type specifications.
162+
/// </summary>
163+
/// <param name="items">Collection of resource items with URLs and types.</param>
164+
/// <returns>The builder instance for method chaining.</returns>
115165
public UrlExtraResourcesBuilder AddItems(IEnumerable<ExtraUrlResourceItem> items)
116166
{
117167
extraUrlResources.Items.AddRange(items.IfNullEmpty());

src/Gotenberg.Sharp.Api.Client/Domain/Builders/Faceted/UrlHeaderFooterBuilder.cs

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,51 @@
1717

1818
namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;
1919

20+
/// <summary>
21+
/// Configures custom HTML header and footer for URL to PDF conversions.
22+
/// Header appears at the top of each page, footer at the bottom.
23+
/// </summary>
2024
public sealed class UrlHeaderFooterBuilder(HeaderFooterDocument headerFooterDocument)
2125
{
2226
#region header
2327

24-
28+
/// <summary>
29+
/// Sets HTML content to appear at the top of every page.
30+
/// </summary>
31+
/// <param name="header">HTML content for the header.</param>
32+
/// <returns>The builder instance for method chaining.</returns>
2533
public UrlHeaderFooterBuilder SetHeader(ContentItem header)
2634
{
2735
headerFooterDocument.Header =
2836
header ?? throw new ArgumentNullException(nameof(header));
2937
return this;
3038
}
3139

32-
40+
/// <summary>
41+
/// Sets HTML header content from a string.
42+
/// </summary>
43+
/// <param name="header">HTML string for the header.</param>
44+
/// <returns>The builder instance for method chaining.</returns>
3345
public UrlHeaderFooterBuilder SetHeader(string header)
3446
{
3547
return this.SetHeader(new ContentItem(header));
3648
}
3749

38-
50+
/// <summary>
51+
/// Sets HTML header content from a byte array.
52+
/// </summary>
53+
/// <param name="header">HTML content as bytes.</param>
54+
/// <returns>The builder instance for method chaining.</returns>
3955
public UrlHeaderFooterBuilder SetHeader(byte[] header)
4056
{
4157
return this.SetHeader(new ContentItem(header));
4258
}
4359

44-
60+
/// <summary>
61+
/// Sets HTML header content from a stream.
62+
/// </summary>
63+
/// <param name="header">Stream containing HTML content.</param>
64+
/// <returns>The builder instance for method chaining.</returns>
4565
public UrlHeaderFooterBuilder SetHeader(Stream header)
4666
{
4767
return this.SetHeader(new ContentItem(header));
@@ -51,27 +71,43 @@ public UrlHeaderFooterBuilder SetHeader(Stream header)
5171

5272
#region footer
5373

54-
74+
/// <summary>
75+
/// Sets HTML content to appear at the bottom of every page.
76+
/// </summary>
77+
/// <param name="footer">HTML content for the footer.</param>
78+
/// <returns>The builder instance for method chaining.</returns>
5579
public UrlHeaderFooterBuilder SetFooter(ContentItem footer)
5680
{
5781
headerFooterDocument.Footer =
5882
footer ?? throw new ArgumentNullException(nameof(footer));
5983
return this;
6084
}
6185

62-
86+
/// <summary>
87+
/// Sets HTML footer content from a string.
88+
/// </summary>
89+
/// <param name="footer">HTML string for the footer.</param>
90+
/// <returns>The builder instance for method chaining.</returns>
6391
public UrlHeaderFooterBuilder SetFooter(string footer)
6492
{
6593
return this.SetFooter(new ContentItem(footer));
6694
}
6795

68-
96+
/// <summary>
97+
/// Sets HTML footer content from a byte array.
98+
/// </summary>
99+
/// <param name="footer">HTML content as bytes.</param>
100+
/// <returns>The builder instance for method chaining.</returns>
69101
public UrlHeaderFooterBuilder SetFooter(byte[] footer)
70102
{
71103
return this.SetFooter(new ContentItem(footer));
72104
}
73105

74-
106+
/// <summary>
107+
/// Sets HTML footer content from a stream.
108+
/// </summary>
109+
/// <param name="footer">Stream containing HTML content.</param>
110+
/// <returns>The builder instance for method chaining.</returns>
75111
public UrlHeaderFooterBuilder SetFooter(Stream footer)
76112
{
77113
return this.SetFooter(new ContentItem(footer));

0 commit comments

Comments
 (0)