Skip to content

Commit

Permalink
Add docs on how to use snippets (#1604)
Browse files Browse the repository at this point in the history
  • Loading branch information
martintmk committed Sep 21, 2023
1 parent 2c3f74b commit 5af6eb0
Showing 1 changed file with 23 additions and 0 deletions.
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.

0 comments on commit 5af6eb0

Please sign in to comment.