Skip to content

Commit aacafd9

Browse files
update docs and debugging info (Azure#33111)
* update docs and debugging info * Update doc/dev/code_snippets.md Co-authored-by: Krista Pratico <[email protected]> --------- Co-authored-by: Krista Pratico <[email protected]>
1 parent 6d0d847 commit aacafd9

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

doc/dev/code_snippets.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ All code snippets in README should be up to date and runnable. And we want to ha
1010

1111
Samples need to store in the samples folder under each service. In each sample file, we use `# [START snippet_name]` & `# [END snippet_name]` to note a code snippet.
1212

13+
**Note:** valid characters for a snippet name are [A-Z a-z0-9_]
14+
1315
A sample code snippet could be like:
1416

1517
```python
@@ -25,18 +27,28 @@ https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/samp
2527

2628
## Refer samples
2729

28-
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.
30+
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.
2931

3032
It is like:
3133

32-
<!-- SNIPPET:test_example_async.asyncio -->
34+
`\<!-- SNIPPET:test_example_async.asyncio -->`
35+
3336
```python
3437
from azure.core.pipeline.transport import AsyncioRequestsTransport
3538

3639
async with AsyncPipeline(AsyncioRequestsTransport(), policies=policies) as pipeline:
3740
response = await pipeline.run(request)
3841
```
39-
<!-- END SNIPPET -->
42+
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.
4052

4153
## Run python_snippet_updater tool
4254

tools/azure-sdk-tools/ci_tools/snippet_update/python_snippet_updater.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
_LOGGER = logging.getLogger(__name__)
99

10+
# Uncomment the following lines to show debug info
11+
# _LOGGER.setLevel(logging.DEBUG)
12+
# console_handler = logging.StreamHandler()
13+
# _LOGGER.addHandler(console_handler)
14+
1015
snippets = {}
1116
not_up_to_date = False
1217

@@ -64,7 +69,7 @@ def get_snippet(file: str) -> None:
6469
if identifier in snippets.keys():
6570
_LOGGER.warning(f'Found duplicated snippet name "{identifier}".')
6671
_LOGGER.warning(file)
67-
_LOGGER.debug(f"Found: {file_obj.name}.{name}")
72+
_LOGGER.debug(f"Found snippet: {file_obj.name}.{name}")
6873
snippets[identifier] = snippet
6974

7075

0 commit comments

Comments
 (0)