Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs on how to use snippets #1604

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Snippets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,26 @@ Various code-snippets used in the Polly documentation. Run the following command
```powershell
dotnet mdsnippets
```

Visit <https://github.com/SimonCropp/MarkdownSnippets> for more details.

## How to use snippets in Polly documentation

First, locate the relevant `.cs` file where the snippet resides. For instance, `retry.md` refers to snippets found in the `Retry.cs` file.

Next, set up your code snippet. Ideally, use a new method and enclose the section you want to reference between `#region my-snippet` and `#endregion` tags.

```csharp
public static void MySnippet()
{
#region my-snippet

// your code here

#endregion
}
```

In your markdown documentation, refer to your code snippet by adding `<!-- snippet: my-snippet -->` and `<!-- endSnippet -->` comments to your markdown file.

To conclude, run the `dotnet mdsnippets` command from the root directory to refresh snippets throughout all markdown files.