Skip to content

Conversation

@dr-3lo
Copy link
Collaborator

@dr-3lo dr-3lo commented Oct 22, 2025

Motivation

Code Snippets requested for portal examples, they should show a basic code required to send an email. But in case of update .NET client main interfaces (will take place after merge PR #158) snippets should be updated.
So to easier maintenance of such snippets they are added to .NET client documentation.

Changes

  • Created Code Snippets section on docs

How to test

  • Build docs and navigates to /codesnippets/index.html

Summary by CodeRabbit

  • Documentation
    • Added comprehensive code snippets documenting common email-sending scenarios, including simple send, template-based send, bulk send, and sandbox testing operations with full examples and error handling.
    • Introduced a new documentation index for easy access to all available code examples.
    • Updated main documentation navigation to include the new code snippets section.

@dr-3lo dr-3lo requested a review from zhaparoff as a code owner October 22, 2025 16:28
@dr-3lo dr-3lo requested a review from yanchuk October 22, 2025 16:29
@coderabbitai
Copy link

coderabbitai bot commented Oct 22, 2025

Walkthrough

Five code snippet documentation examples are added demonstrating various email-sending workflows with the Mailtrap .NET SDK: simple send, template-based send, bulk send, and sandbox send. Supporting index and table of contents files establish navigation within the new documentation section, integrated into the root documentation hierarchy.

Changes

Cohort / File(s) Summary
Code Snippet Examples
docs/codesnippets/SimpleSend.md, docs/codesnippets/SimpleSendFromTemplate.md, docs/codesnippets/BulkSend.md, docs/codesnippets/BulkSendFromTemplate.md, docs/codesnippets/SandboxSendFromTemplate.md
Introduces five code snippet documentation files demonstrating email-sending workflows using MailtrapClientFactory, including client initialization, SendEmailRequest construction via fluent interface, sending operations (Email().Send, Bulk().Send, Test().Send), and exception handling with API token cautions
Code Snippets Section Navigation
docs/codesnippets/index.md, docs/codesnippets/toc.yml
Adds index page describing available snippets with cross-reference links and table of contents file with five new snippet UIDs for navigation
Root Documentation Integration
docs/index.md, docs/toc.yml
Adds "Code Snippets" entry to main documentation TOC and creates new CodeSnippets section in root TOC file with codesnippets/ href and five linked snippet UIDs

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

The changes consist of homogeneous, repetitive documentation additions following consistent structure and patterns across multiple code snippet files. Review primarily requires verification of example correctness, code accuracy, internal link validity between index/snippet pages, and proper hierarchy integration into existing documentation.

Suggested reviewers

  • zhaparoff
  • kovpack
  • yanchuk

Poem

🐰 Five snippets hopping through the docs so bright,
From simple sends to templates, all is right,
The Mailtrap SDK now shines with care,
Examples guide the way everywhere! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Add code snippets to documentation" directly and clearly summarizes the main changeset, which consists entirely of adding six new documentation files for code snippets (BulkSend.md, BulkSendFromTemplate.md, SandboxSendFromTemplate.md, SimpleSend.md, SimpleSendFromTemplate.md) and updating navigation/indexing files to expose these snippets. The title is concise, free of noise, and immediately communicates the primary purpose to someone scanning the repository history.
Description Check ✅ Passed The pull request description follows the required template structure and includes all critical sections: a Motivation section explaining the context (portal examples and maintenance simplification), a Changes section identifying the Code Snippets section addition, and a How to test section with specific instructions and a checkbox. While the Changes section is somewhat concise (listing only a summary rather than individual files), it adequately communicates what was added, and the overall description is mostly complete. The Images and GIFs section is not included but is not critical for a documentation-only change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/codesnippets

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dr-3lo dr-3lo requested a review from kovpack October 22, 2025 16:29
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
docs/index.md (1)

24-25: Minor refinement: Improve description clarity.

Line 25's description "Code snippets for base send mail operations" is slightly informal. Consider: "Practical code examples for common email sending scenarios" for better consistency with other documentation entries.

docs/codesnippets/SimpleSendFromTemplate.md (1)

23-23: Standardize template variables comment spacing.

Line 23 has a double space in the comment: // Optional template parameters. This differs from the single space used in BulkSendFromTemplate.md (line 23). Standardize across all template-related snippets.

Apply this diff to standardize comment formatting:

-        .TemplateVariables(new Dictionary<string, object> // Optional template  parameters
+        .TemplateVariables(new Dictionary<string, object> // Optional template variables

Alternatively, update BulkSendFromTemplate.md and SandboxSendFromTemplate.md to match if a different convention is preferred.

docs/codesnippets/SimpleSend.md (1)

8-33: Clarify the async context for code integration.

The code example uses await (line 25) but doesn't show an explicit async method wrapper. While this is common in documentation examples, developers might need clearer guidance on integrating this into an async method context.

Consider adding a comment or a brief note in the description (e.g., "Add this code to an async method") to help developers understand the expected context for using this snippet.

One way to address this is to add a clarifying comment above the try block:

+// Add this code to an async method (e.g., an async Task Main or async controller action)
try

Alternatively, you could add a note in the description section (after line 6) such as:

 # Send an email
 Short example of sending a simple email.
+> Note: This example should be placed within an async method context.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ddfab62 and 413c9ba.

📒 Files selected for processing (9)
  • docs/codesnippets/BulkSend.md (1 hunks)
  • docs/codesnippets/BulkSendFromTemplate.md (1 hunks)
  • docs/codesnippets/SandboxSendFromTemplate.md (1 hunks)
  • docs/codesnippets/SimpleSend.md (1 hunks)
  • docs/codesnippets/SimpleSendFromTemplate.md (1 hunks)
  • docs/codesnippets/index.md (1 hunks)
  • docs/codesnippets/toc.yml (1 hunks)
  • docs/index.md (1 hunks)
  • docs/toc.yml (1 hunks)
🔇 Additional comments (9)
docs/codesnippets/toc.yml (1)

1-5: LGTM! The table of contents entries are properly structured with consistent UID naming conventions. All five snippet identifiers align with the corresponding documentation pages and cross-references in parent TOC files.

docs/toc.yml (1)

13-20: LGTM! The new CodeSnippets section is properly integrated into the root table of contents. The structure follows the established pattern (name, href, items list), and all five snippet UIDs match those defined in docs/codesnippets/toc.yml.

docs/codesnippets/BulkSendFromTemplate.md (1)

1-41: LGTM! The code snippet correctly demonstrates bulk-sending emails from templates. The fluent API pattern is consistent with other snippets, error handling is appropriate for documentation, and the API token caution is properly included.

docs/codesnippets/SandboxSendFromTemplate.md (1)

1-42: LGTM! The sandbox snippet correctly demonstrates the .Test(sandboxId) method for testing environments. Template variables and error handling are consistent with other snippets. The inline API token caution reinforces security best practices.

docs/codesnippets/BulkSend.md (1)

1-35: LGTM! The bulk-send example correctly demonstrates non-template email sending via the .Bulk() method. The fluent API (From, To, Subject, Category, Text) is idiomatic and well-structured. Error handling and API token caution are appropriately included.

docs/codesnippets/index.md (1)

13-13: No issues found. SimpleSend.md exists at docs/codesnippets/SimpleSend.md with uid snippets.simple-send-email correctly matching the xref reference on line 13. The file contains appropriate documentation with a code example and proper structure.

docs/codesnippets/SimpleSend.md (3)

9-11: LGTM!

The using statements and imports are appropriate and follow the expected pattern for Mailtrap .NET SDK usage. Resource management with the using statement for mailtrapClientFactory (line 16) ensures proper disposal.


18-27: LGTM!

The fluent builder pattern for SendEmailRequest is clean and idiomatic for the SDK. The async/await pattern and the response handling are correctly implemented.


15-15: Include file verified—no issues found.

The referenced file ../includes/api-token-caution.md exists at docs/includes/api-token-caution.md and is correctly located relative to SimpleSend.md. The path reference on line 35 resolves correctly.

Copy link
Contributor

@yanchuk yanchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, it's fine. Let's not forget to update it with breaking changes PR #158 as we'll use that revision for the UI

@dr-3lo
Copy link
Collaborator Author

dr-3lo commented Oct 23, 2025

Verified that snippets will be exactly the same after changes from #158 , so we already can use them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants