You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/dev/code_snippets.md
+24-21
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
3
3
All code snippets in README should be up to date and runnable. And we want to have single source of truth hence we only need to maintain one copy. To achieve it, we want to have:
4
4
5
-
-[Store samples in samples folder and setup the pipeline to run them to make sure no sample is broken](#create-samples)
6
-
-[In README, refer the code snippet from the samples](#refer-samples)
5
+
-[Define snippet definitions in the samples folder](#create-samples)
6
+
-[In README, refer to the code snippets from the samples](#refer-samples)
7
7
-[Run `python_snippet_updater.py` to keep them in sync](#python_snippet_updater-tool)
Instead of copying the code snippet into README which is hard to maintain and validate, we add reference to the sample snippet in README. We use the annotation `\<!-- SNIPPET:file_name.snippet_name-->` to refer the code snippet in README file.
31
31
32
-
It is like:
33
-
34
-
`\<!-- SNIPPET:test_example_async.asyncio -->`
32
+
If you have a file in `samples\text_example_async.py` with a snippet named `asyncio`, you can reference it in your README like:
35
33
34
+
````markdown
35
+
<!-- SNIPPET:test_example_async.asyncio -->
36
36
```python
37
-
from azure.core.pipeline.transport import AsyncioRequestsTransport
38
-
39
-
asyncwith AsyncPipeline(AsyncioRequestsTransport(), policies=policies) as pipeline:
40
-
response =await pipeline.run(request)
41
37
```
38
+
<!-- END SNIPPET -->
39
+
````
42
40
43
-
`\<!-- END SNIPPET -->`
44
-
45
-
**Note:** you need to make sure there is
46
-
47
-
\```python
48
-
49
-
\```
50
-
51
-
within `\<!-- SNIPPET:` & `\<!-- END SNIPPET -->` in README.MD to make the annotation valid.
41
+
> Make sure you include a Python code fence within the snippet reference!
For management (control plane) packages, start with this page: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/mgmt/mgmt_release.md
11
7
8
+
For client (data plane) packages, ensure that:
9
+
- The version at `sdk/path-to-your-package/_version.py` has been updated following [these guidelines](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/package_version/package_version_rule.md).
10
+
- The changelog has been updated following [these guidelines](https://azure.github.io/azure-sdk/policies_releases.html#change-logs).
11
+
- Package README has been updated following [these guidelines](https://azure.github.io/azure-sdk/python_documentation.html).
12
+
- Samples have been updated following [these guidelines](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/sample_guide.md).
Copy file name to clipboardExpand all lines: doc/dev/sample_guide.md
+2
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,8 @@ Note that the metadata under `products` must match an existing product slug foun
42
42
43
43
## Capturing code snippets in reference documentation
44
44
Code snippets from samples can be captured as [examples][qa_example] in our reference documentation.
45
+
See [code snippets documentation](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/code_snippets.md) for more details on how to define and reference code snippets in Markdown files.
46
+
45
47
To do this, place `# [START <keyword>]` and `# [END <keyword>]` comments which span the lines you want to show up in the reference documentation example.
46
48
Note that the <keyword> used should be unique across all sync/async samples added to a client library.
0 commit comments