Skip to content

Commit 130257d

Browse files
authored
Merge pull request #65 from ChangemakerStudios/feature/documentation-improvement
Add comprehensive XML documentation to public APIs
2 parents a5b8338 + b29bb47 commit 130257d

28 files changed

+906
-116
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,4 @@ __pycache__/
288288
*.odx.cs
289289
*.xsd.cs
290290

291+
settings.local.json

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ PM> Install-Package Gotenberg.Sharp.Api.Client
4141

4242
*Note: Use v1.x nugets for Gotenberg v6.*
4343

44+
## IntelliSense Documentation
45+
All public APIs include comprehensive XML documentation with clear descriptions, parameter details, and links to official Gotenberg documentation. IntelliSense provides:
46+
- Method descriptions with Gotenberg route documentation links
47+
- Parameter explanations and valid value ranges
48+
- Exception documentation for error handling
49+
- Usage notes and best practices
50+
4451
## AppSettings
4552
```json
4653
"GotenbergSharpClient": {

src/Gotenberg.Sharp.Api.Client/Domain/Builders/BaseBuilder.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
namespace Gotenberg.Sharp.API.Client.Domain.Builders;
1717

18+
/// <summary>
19+
/// Base class for all Gotenberg request builders. Provides core functionality for building and configuring requests.
20+
/// </summary>
21+
/// <typeparam name="TRequest">The type of request being built.</typeparam>
22+
/// <typeparam name="TBuilder">The concrete builder type for fluent interface chaining.</typeparam>
1823
public abstract class BaseBuilder<TRequest, TBuilder>(TRequest request)
1924
where TRequest : BuildRequestBase
2025
where TBuilder : BaseBuilder<TRequest, TBuilder>
@@ -26,6 +31,11 @@ public abstract class BaseBuilder<TRequest, TBuilder>(TRequest request)
2631

2732
protected virtual TRequest Request { get; } = request;
2833

34+
/// <summary>
35+
/// Configures request-level settings such as webhooks, page ranges, result filename, and trace ID.
36+
/// </summary>
37+
/// <param name="action">Configuration action for request settings.</param>
38+
/// <returns>The builder instance for method chaining.</returns>
2939
public TBuilder ConfigureRequest(Action<ConfigBuilder> action)
3040
{
3141
if (action == null) throw new ArgumentNullException(nameof(action));
@@ -37,20 +47,35 @@ public TBuilder ConfigureRequest(Action<ConfigBuilder> action)
3747
return (TBuilder)this;
3848
}
3949

50+
/// <summary>
51+
/// Sets pre-configured request settings.
52+
/// </summary>
53+
/// <param name="config">Pre-configured RequestConfig instance.</param>
54+
/// <returns>The builder instance for method chaining.</returns>
4055
public TBuilder ConfigureRequest(RequestConfig config)
4156
{
4257
this.Request.Config = config ?? throw new ArgumentNullException(nameof(config));
4358

4459
return (TBuilder)this;
4560
}
4661

62+
/// <summary>
63+
/// Builds the request synchronously. Use when all content is already in memory (no async operations).
64+
/// </summary>
65+
/// <returns>The configured request ready to send to Gotenberg.</returns>
66+
/// <exception cref="InvalidOperationException">Thrown when async methods (AddAsync*, WithAsync*) were used. Use BuildAsync instead.</exception>
4767
public virtual TRequest Build()
4868
{
4969
if (this.BuildTasks.Any()) throw new InvalidOperationException(CallBuildAsyncErrorMessage);
5070

5171
return this.Request;
5272
}
5373

74+
/// <summary>
75+
/// Builds the request asynchronously. Use when loading content from streams, files, or using any AddAsync* or WithAsync* methods.
76+
/// Safe to use even when no async operations were performed.
77+
/// </summary>
78+
/// <returns>The configured request ready to send to Gotenberg.</returns>
5479
public virtual async Task<TRequest> BuildAsync()
5580
{
5681
if (this.BuildTasks.Any()) await Task.WhenAll(this.BuildTasks).ConfigureAwait(false);

src/Gotenberg.Sharp.Api.Client/Domain/Builders/BaseChromiumBuilder.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515

1616
namespace Gotenberg.Sharp.API.Client.Domain.Builders;
1717

18+
/// <summary>
19+
/// Base class for builders that use Gotenberg's Chromium module for HTML and URL to PDF conversions.
20+
/// Provides configuration for page properties, assets, and Chromium rendering behaviors.
21+
/// </summary>
22+
/// <typeparam name="TRequest">The type of Chromium-based request being built.</typeparam>
23+
/// <typeparam name="TBuilder">The concrete builder type for fluent interface chaining.</typeparam>
1824
public abstract class BaseChromiumBuilder<TRequest, TBuilder>(TRequest request)
1925
: BaseBuilder<TRequest, TBuilder>(request)
2026
where TRequest : ChromeRequest
@@ -41,6 +47,11 @@ public TBuilder WithDimensions(PageProperties pageProperties)
4147
return (TBuilder)this;
4248
}
4349

50+
/// <summary>
51+
/// Configures page properties including size, margins, orientation, scale, and rendering options.
52+
/// </summary>
53+
/// <param name="action">Configuration action for page properties.</param>
54+
/// <returns>The builder instance for method chaining.</returns>
4455
public TBuilder WithPageProperties(Action<PagePropertyBuilder> action)
4556
{
4657
if (action == null) throw new ArgumentNullException(nameof(action));
@@ -54,20 +65,36 @@ public TBuilder WithPageProperties(Action<PagePropertyBuilder> action)
5465
return (TBuilder)this;
5566
}
5667

68+
/// <summary>
69+
/// Sets pre-configured page properties.
70+
/// </summary>
71+
/// <param name="pageProperties">Pre-configured PageProperties instance.</param>
72+
/// <returns>The builder instance for method chaining.</returns>
5773
public TBuilder WithPageProperties(PageProperties pageProperties)
5874
{
5975
this.Request.PageProperties = pageProperties ?? throw new ArgumentNullException(nameof(pageProperties));
6076

6177
return (TBuilder)this;
6278
}
6379

80+
/// <summary>
81+
/// Adds embedded resources (images, fonts, CSS, JavaScript files) referenced by the HTML content.
82+
/// The asset filename must match how it's referenced in your HTML.
83+
/// </summary>
84+
/// <param name="action">Configuration action for adding assets.</param>
85+
/// <returns>The builder instance for method chaining.</returns>
6486
public TBuilder WithAssets(Action<AssetBuilder> action)
6587
{
6688
if (action == null) throw new ArgumentNullException(nameof(action));
6789
action(new AssetBuilder(this.Request.Assets ??= new AssetDictionary()));
6890
return (TBuilder)this;
6991
}
7092

93+
/// <summary>
94+
/// Asynchronously adds embedded resources. Use when loading assets from streams or files.
95+
/// </summary>
96+
/// <param name="asyncAction">Async configuration action for adding assets.</param>
97+
/// <returns>The builder instance for method chaining.</returns>
7198
public TBuilder WithAsyncAssets(Func<AssetBuilder, Task> asyncAction)
7299
{
73100
if (asyncAction == null) throw new ArgumentNullException(nameof(asyncAction));
@@ -76,13 +103,23 @@ public TBuilder WithAsyncAssets(Func<AssetBuilder, Task> asyncAction)
76103
return (TBuilder)this;
77104
}
78105

106+
/// <summary>
107+
/// Configures Chromium rendering behaviors including wait delays, cookies, HTTP headers, metadata, PDF format, and accessibility options.
108+
/// </summary>
109+
/// <param name="action">Configuration action for conversion behaviors.</param>
110+
/// <returns>The builder instance for method chaining.</returns>
79111
public TBuilder SetConversionBehaviors(Action<HtmlConversionBehaviorBuilder> action)
80112
{
81113
if (action == null) throw new ArgumentNullException(nameof(action));
82114
action(new HtmlConversionBehaviorBuilder(this.Request.ConversionBehaviors));
83115
return (TBuilder)this;
84116
}
85117

118+
/// <summary>
119+
/// Sets pre-configured Chromium conversion behaviors.
120+
/// </summary>
121+
/// <param name="behaviors">Pre-configured HtmlConversionBehaviors instance.</param>
122+
/// <returns>The builder instance for method chaining.</returns>
86123
public TBuilder SetConversionBehaviors(HtmlConversionBehaviors behaviors)
87124
{
88125
this.Request.ConversionBehaviors =

src/Gotenberg.Sharp.Api.Client/Domain/Builders/BaseMergeBuilder.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,21 @@
1515

1616
namespace Gotenberg.Sharp.API.Client.Domain.Builders;
1717

18+
/// <summary>
19+
/// Base class for builders that merge documents (PDFs or Office files) using Gotenberg's merge capabilities.
20+
/// Provides functionality for adding files to merge.
21+
/// </summary>
22+
/// <typeparam name="TRequest">The type of merge request being built.</typeparam>
23+
/// <typeparam name="TBuilder">The concrete builder type for fluent interface chaining.</typeparam>
1824
public abstract class BaseMergeBuilder<TRequest, TBuilder>(TRequest request) : BaseBuilder<TRequest, TBuilder>(request)
1925
where TRequest : BuildRequestBase where TBuilder : BaseMergeBuilder<TRequest, TBuilder>
2026
{
27+
/// <summary>
28+
/// Adds files to merge. For PDF merges, add PDF files. For Office merges, add Office documents (.docx, .xlsx, .pptx, etc.).
29+
/// Files are merged in the order they are added.
30+
/// </summary>
31+
/// <param name="action">Configuration action for adding files.</param>
32+
/// <returns>The builder instance for method chaining.</returns>
2133
public TBuilder WithAssets(Action<AssetBuilder> action)
2234
{
2335
if (action == null) throw new ArgumentNullException(nameof(action));
@@ -27,6 +39,11 @@ public TBuilder WithAssets(Action<AssetBuilder> action)
2739
return (TBuilder)this;
2840
}
2941

42+
/// <summary>
43+
/// Asynchronously adds files to merge. Use when loading files from streams or the file system.
44+
/// </summary>
45+
/// <param name="asyncAction">Async configuration action for adding files.</param>
46+
/// <returns>The builder instance for method chaining.</returns>
3047
public TBuilder WithAsyncAssets(Func<AssetBuilder, Task> asyncAction)
3148
{
3249
if (asyncAction == null) throw new ArgumentNullException(nameof(asyncAction));

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted
1717
{
18+
/// <summary>
19+
/// Adds embedded resources (assets) to PDF conversion requests. Assets are files referenced by your HTML content
20+
/// such as images, fonts, CSS stylesheets, and JavaScript files. The asset name must match exactly how it's
21+
/// referenced in your HTML (e.g., "logo.png" for &lt;img src="logo.png"/&gt;).
22+
/// </summary>
1823
public sealed class AssetBuilder
1924
{
2025
private readonly AssetDictionary _assets;
@@ -24,6 +29,13 @@ internal AssetBuilder(AssetDictionary assets)
2429
this._assets = assets;
2530
}
2631

32+
/// <summary>
33+
/// Adds a single asset file. The name must be a relative filename with extension, matching the reference in your HTML.
34+
/// </summary>
35+
/// <param name="name">Filename as referenced in HTML (e.g., "styles.css", "logo.png"). Must include extension and not contain path separators.</param>
36+
/// <param name="value">The file content.</param>
37+
/// <returns>The builder instance for method chaining.</returns>
38+
/// <exception cref="ArgumentOutOfRangeException">Thrown when name is invalid (missing extension or contains path separators).</exception>
2739
public AssetBuilder AddItem(string name, ContentItem value)
2840
{
2941
// ReSharper disable once ComplexConditionExpression
@@ -39,16 +51,39 @@ public AssetBuilder AddItem(string name, ContentItem value)
3951
return this;
4052
}
4153

54+
/// <summary>
55+
/// Adds a single asset from string content (typically for text files like CSS or JavaScript).
56+
/// </summary>
57+
/// <param name="name">Filename as referenced in HTML.</param>
58+
/// <param name="value">File content as string.</param>
59+
/// <returns>The builder instance for method chaining.</returns>
4260
public AssetBuilder AddItem(string name, string value) => AddItem(name, new ContentItem(value));
4361

62+
/// <summary>
63+
/// Adds a single asset from byte array (typically for binary files like images or fonts).
64+
/// </summary>
65+
/// <param name="name">Filename as referenced in HTML.</param>
66+
/// <param name="value">File content as bytes.</param>
67+
/// <returns>The builder instance for method chaining.</returns>
4468
public AssetBuilder AddItem(string name, byte[] value) => AddItem(name, new ContentItem(value));
4569

70+
/// <summary>
71+
/// Adds a single asset from a stream.
72+
/// </summary>
73+
/// <param name="name">Filename as referenced in HTML.</param>
74+
/// <param name="value">Stream containing file content.</param>
75+
/// <returns>The builder instance for method chaining.</returns>
4676
public AssetBuilder AddItem(string name, Stream value) => AddItem(name, new ContentItem(value));
4777

4878
#region 'n' assets
4979

5080
#region from dictionaries
5181

82+
/// <summary>
83+
/// Adds multiple assets from a dictionary. Useful for adding several files at once.
84+
/// </summary>
85+
/// <param name="items">Dictionary of filename to content mappings.</param>
86+
/// <returns>The builder instance for method chaining.</returns>
5287
public AssetBuilder AddItems(Dictionary<string, ContentItem>? items)
5388
{
5489
foreach (var item in items.IfNullEmpty())
@@ -59,35 +94,70 @@ public AssetBuilder AddItems(Dictionary<string, ContentItem>? items)
5994
return this;
6095
}
6196

97+
/// <summary>
98+
/// Adds multiple assets from a dictionary with string content.
99+
/// </summary>
100+
/// <param name="assets">Dictionary of filename to string content mappings.</param>
101+
/// <returns>The builder instance for method chaining.</returns>
62102
public AssetBuilder AddItems(Dictionary<string, string>? assets) =>
63103
AddItems(assets?.ToDictionary(a => a.Key, a => new ContentItem(a.Value)));
64104

105+
/// <summary>
106+
/// Adds multiple assets from a dictionary with byte array content.
107+
/// </summary>
108+
/// <param name="assets">Dictionary of filename to byte array mappings.</param>
109+
/// <returns>The builder instance for method chaining.</returns>
65110
public AssetBuilder AddItems(Dictionary<string, byte[]>? assets) =>
66111
AddItems(assets?.ToDictionary(a => a.Key, a => new ContentItem(a.Value)));
67112

113+
/// <summary>
114+
/// Adds multiple assets from a dictionary with stream content.
115+
/// </summary>
116+
/// <param name="assets">Dictionary of filename to stream mappings.</param>
117+
/// <returns>The builder instance for method chaining.</returns>
68118
public AssetBuilder AddItems(Dictionary<string, Stream>? assets) =>
69119
AddItems(assets?.ToDictionary(a => a.Key, a => new ContentItem(a.Value)));
70120

71121
#endregion
72122

73123
#region from KVP enumerables
74124

125+
/// <summary>
126+
/// Adds multiple assets from a key-value pair enumerable.
127+
/// </summary>
128+
/// <param name="assets">Enumerable of filename to content mappings.</param>
129+
/// <returns>The builder instance for method chaining.</returns>
75130
public AssetBuilder AddItems(IEnumerable<KeyValuePair<string, ContentItem>> assets) =>
76131
AddItems(
77132
new Dictionary<string, ContentItem>(
78133
assets?.ToDictionary(a => a.Key, a => a.Value) ?? throw new ArgumentNullException(nameof(assets))));
79134

135+
/// <summary>
136+
/// Adds multiple assets from a key-value pair enumerable with string content.
137+
/// </summary>
138+
/// <param name="assets">Enumerable of filename to string content mappings.</param>
139+
/// <returns>The builder instance for method chaining.</returns>
80140
public AssetBuilder AddItems(IEnumerable<KeyValuePair<string, string>> assets) =>
81141
AddItems(
82142
new Dictionary<string, ContentItem>(
83143
assets?.ToDictionary(a => a.Key, a => new ContentItem(a.Value))
84144
?? throw new ArgumentNullException(nameof(assets))));
85145

146+
/// <summary>
147+
/// Adds multiple assets from a key-value pair enumerable with byte array content.
148+
/// </summary>
149+
/// <param name="assets">Enumerable of filename to byte array mappings.</param>
150+
/// <returns>The builder instance for method chaining.</returns>
86151
public AssetBuilder AddItems(IEnumerable<KeyValuePair<string, byte[]>> assets) =>
87152
AddItems(
88153
assets?.ToDictionary(a => a.Key, a => new ContentItem(a.Value))
89154
?? throw new ArgumentNullException(nameof(assets)));
90155

156+
/// <summary>
157+
/// Adds multiple assets from a key-value pair enumerable with stream content.
158+
/// </summary>
159+
/// <param name="assets">Enumerable of filename to stream mappings.</param>
160+
/// <returns>The builder instance for method chaining.</returns>
91161
public AssetBuilder AddItems(IEnumerable<KeyValuePair<string, Stream>> assets) =>
92162
AddItems(
93163
assets?.ToDictionary(s => s.Key, a => new ContentItem(a.Value))

0 commit comments

Comments
 (0)