From 6ad467501d43c628823f2485e697e62d26dc6044 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Wed, 20 Sep 2023 16:23:28 +0200 Subject: [PATCH 1/2] Add docs on how to use snippets --- src/Snippets/README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Snippets/README.md b/src/Snippets/README.md index b9acd52664..a701867352 100644 --- a/src/Snippets/README.md +++ b/src/Snippets/README.md @@ -5,3 +5,31 @@ Various code-snippets used in the Polly documentation. Run the following command ```powershell dotnet mdsnippets ``` + +Visit 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 snippet as: + +```text +Your documentation text: + + + +``` + +To conclude, run the `dotnet mdsnippets` command from the root directory to refresh snippets throughout all markdown files. From 499b3c86dea9272485a8462566f9d7de2b493b02 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Wed, 20 Sep 2023 19:15:55 +0200 Subject: [PATCH 2/2] fixes --- src/Snippets/README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Snippets/README.md b/src/Snippets/README.md index a701867352..2a9a258650 100644 --- a/src/Snippets/README.md +++ b/src/Snippets/README.md @@ -18,18 +18,13 @@ Next, set up your code snippet. Ideally, use a new method and enclose the sectio public static void MySnippet() { #region my-snippet + // your code here + #endregion } ``` -In your markdown documentation, refer to your snippet as: - -```text -Your documentation text: - - - -``` +In your markdown documentation, refer to your code snippet by adding `` and `` comments to your markdown file. To conclude, run the `dotnet mdsnippets` command from the root directory to refresh snippets throughout all markdown files.