Skip to content

Commit a81f177

Browse files
Add some docs related to Update-Snippets.ps1 (Azure#13310)
* Add some docs related to Update-Snippets.ps1 * example suggestion Co-authored-by: Mariana Rios Flores <mariari@microsoft.com> * add example links * pr comments Co-authored-by: Mariana Rios Flores <mariari@microsoft.com>
1 parent 74e70eb commit a81f177

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

CONTRIBUTING.md

+49
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,55 @@ Running the script for a project in `sdk\tables` would look like this:
151151
eng\scripts\Export-API.ps1 tables
152152
```
153153

154+
## Updating Sample Snippets
155+
If the specific client library has sample snippets in markdown format, they were most likely created with help of the `eng\scripts\Update-Snippets.ps1` script.
156+
Any changes made to the snippet markdown should be done via updating the corresponding C# snippet code and subsequently running the script.
157+
158+
Running the script for a project, for example in `sdk\keyvault`, would look like this:
159+
```
160+
eng\scripts\Update-Snippets.ps1 keyvault
161+
```
162+
163+
When run, the code regions in the format below (where `<snippetName>` is the name of the snippet):
164+
```c#
165+
#region Snippet:<snippetName>
166+
//some sample code
167+
string snippet = "some snippet code";
168+
169+
// Lines prefixed with the below comment format will be ignored by the snippet updater.
170+
/*@@*/ string ignored = "this code will not appear in the snippet markdown";
171+
172+
// Lines prefixed with the below comment format will appear in the snippet markdown, but will remain comments in the C#` code.
173+
// Note: these comments should only be used for non-critical code as it will not be compiled or refactored as the code changes.
174+
//@@ snippet = "value that would never pass a test but looks good in a sample!";
175+
176+
#endregion
177+
```
178+
will be mapped to any markdown file with a corresponding code region in the format below where the snippet names match:
179+
180+
**\`\`\`C# Snippet:\<snippetName>**
181+
182+
**\`\`\`**
183+
184+
See the following example of a [snippet C# file](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/search/Azure.Search.Documents/tests/Samples/HelloWorld.cs) and a [snippet markdown file](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/search/Azure.Search.Documents/samples/Sample01a_HelloWorld.md).
185+
Note that snippet names need to be globally unique under a given service directory.
186+
187+
Snippets also can be integrated into XML doc comments. For example:
188+
```c#
189+
/// <summary>
190+
/// Some Property.
191+
/// </summary>
192+
/// <example>
193+
/// This is an example of using a snippet in XML docs.
194+
/// <code snippet="Snippet:<snippetName>">
195+
/// // some sample code.
196+
/// string snippet = "some snippet code";
197+
/// </code>
198+
public string SomeProperty { get; set; }
199+
```
200+
201+
For general information about samples, see the [Samples Guidelines](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-samples)
202+
154203
## API Compatibility Verification
155204

156205
.NET is using the [ApiCompat tool](https://github.com/dotnet/arcade/tree/master/src/Microsoft.DotNet.ApiCompat) to enforce API compatibility between versions. Builds of GA'ed libraries will fail locally and in CI if there are breaking changes.

0 commit comments

Comments
 (0)