Skip to content

Commit a182f0f

Browse files
authored
Tools & meta: add complex categories feature, update tools release, update READMEs (#7156)
1 parent 385c845 commit a182f0f

File tree

17 files changed

+85
-51
lines changed

17 files changed

+85
-51
lines changed

.github/workflows/validate-doc-metadata.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: checkout repo content
1717
uses: actions/checkout@v4
1818
- name: validate metadata
19-
uses: awsdocs/aws-doc-sdk-examples-tools@2024.49.1
19+
uses: awsdocs/aws-doc-sdk-examples-tools@2024.50.2
2020
with:
2121
doc_gen_only: "False"
2222
strict_titles: "True"

.tools/readmes/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"&kms-key;": "KMS key",
2828
"&kms-keys;": "KMS keys",
2929
"&S3long;": "Amazon Simple Storage Service",
30+
"&S3only;": "S3",
3031
"&SLN;": "Amazon States Language",
3132
}
3233
language = {

.tools/readmes/includes/code_examples.jinja2

+7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ functions within the same service.
3333
{{ macs.list_examples(scenarios) }}
3434
{% endif %}
3535
{% for cat, cat_examples in custom_cats.items() %}
36+
{% set cat_info = categories.get(cat) %}
37+
{% if cat_info %}
38+
### {{ cat_info.display }}
39+
{% if cat_info.description %}_{{ cat_info.display }}_ {{ cat_info.description }}{% endif %}
40+
41+
{% else %}
3642
### {{ cat }}
43+
{% endif %}
3744

3845
{{ macs.list_examples(cat_examples) }}
3946
{% endfor %}

.tools/readmes/render.py

+30-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from typing import Dict, List, Tuple
1414

1515
import config
16+
from aws_doc_sdk_examples_tools.categories import Category
1617
from aws_doc_sdk_examples_tools.entities import expand_all_entities
1718
from aws_doc_sdk_examples_tools.metadata import Example
1819
from aws_doc_sdk_examples_tools.sdks import Sdk
@@ -128,6 +129,7 @@ def _transform_examples(
128129
"api": api,
129130
"category": pre.category,
130131
}
132+
self._apply_defaults_and_overrides(action)
131133
post_examples.append(action)
132134
return sorted(post_examples, key=itemgetter(sort_key))
133135

@@ -153,22 +155,44 @@ def _find_files(self, example: Example, api: str, github: bool = False):
153155

154156
return file, run_file
155157

158+
def _make_plain_text(self, s: str, example: Dict[str, str]) -> [str, None]:
159+
"""Work around strings being Go templates and including XML tags by brute forcing them away."""
160+
if s is None:
161+
return s
162+
return s.replace("<code>", "")\
163+
.replace("</code>", "")\
164+
.replace("{{.Action}}", example["api"])\
165+
.replace("{{.ServiceEntity.Short}}", self.scanner.doc_gen.services[self.scanner.svc_name].short)
166+
167+
def _apply_defaults_and_overrides(self, example: Dict[str, str]):
168+
ex_cat = "Actions" if example["category"] == "Api" else example["category"]
169+
cat = self.scanner.doc_gen.categories.get(ex_cat, None)
170+
if cat is not None:
171+
if cat.overrides:
172+
example["title"] = self._make_plain_text(cat.overrides.title, example)
173+
example["title_abbrev"] = self._make_plain_text(cat.overrides.title_abbrev, example)
174+
example["synopsis"] = self._make_plain_text(cat.overrides.synopsis, example)
175+
elif cat.defaults:
176+
if not example.get("title"):
177+
example["title"] = self._make_plain_text(cat.defaults.title, example)
178+
if not example.get("title_abbrev"):
179+
example["title_abbrev"] = self._make_plain_text(cat.defaults.title_abbrev, example)
180+
if not example.get("synopsis"):
181+
example["synopsis"] = self._make_plain_text(cat.defaults.synopsis, example)
182+
156183
def _transform_hellos(self) -> List[Dict[str, str]]:
157184
examples = self._transform_examples(self.scanner.hellos)
158185
return examples
159186

160187
def _transform_actions(self) -> List[Dict[str, str]]:
161188
examples = self._transform_examples(self.scanner.actions, sort_key="api")
162189
for example in examples:
163-
example["title_abbrev"] = example["api"]
164190
del example["api"]
165191
return examples
166192

167193
def _transform_basics(self) -> List[Dict[str, str]]:
168194
examples = self._transform_examples(self.scanner.basics)
169195
for example in examples:
170-
if not example["title_abbrev"]:
171-
example["title_abbrev"] = config.basics_title_abbrev
172196
example["file"] = example["run_file"]
173197
del example["run_file"]
174198
del example["api"]
@@ -196,7 +220,8 @@ def _transform_custom_categories(self) -> Dict[str, List[Dict[str, str]]]:
196220
post_cats[example["category"]].append(example)
197221

198222
sorted_cats = {}
199-
for key in sorted(post_cats.keys()):
223+
for key in sorted(post_cats.keys(),
224+
key=lambda x: self.scanner.doc_gen.categories.get(x, Category(x, x)).display):
200225
if len(post_cats[key]) == 0:
201226
del sorted_cats[key]
202227
else:
@@ -295,6 +320,7 @@ def render(self) -> RenderStatus:
295320
lang_config=self.lang_config,
296321
sdk=sdk,
297322
service=svc,
323+
categories=self.scanner.doc_gen.categories,
298324
hello=hello,
299325
actions=actions,
300326
basics=basics,

dotnetv3/Glacier/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ For prerequisites, see the [README](../README.md#Prerequisites) in the `dotnetv3
3131

3232
### Get started
3333

34-
- [Hello Amazon S3 Glacier](Actions/HelloGlacier.cs#L4) (`ListVaults`)
34+
- [Hello S3 Glacier](Actions/HelloGlacier.cs#L4) (`ListVaults`)
3535

3636

3737
### Single actions
@@ -76,9 +76,9 @@ Alternatively, you can run the example from within your IDE.
7676
<!--custom.instructions.start-->
7777
<!--custom.instructions.end-->
7878

79-
#### Hello Amazon S3 Glacier
79+
#### Hello S3 Glacier
8080

81-
This example shows you how to get started using Amazon S3 Glacier.
81+
This example shows you how to get started using S3 Glacier.
8282

8383

8484

@@ -108,4 +108,4 @@ in the `dotnetv3` folder.
108108

109109
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
110110

111-
SPDX-License-Identifier: Apache-2.0
111+
SPDX-License-Identifier: Apache-2.0

dotnetv3/MediaConvert/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ The project includes the following settings in `settings.json`:
8383

8484
#### Hello MediaConvert
8585

86-
This example shows you how to get started using AWS Elemental MediaConvert.
86+
This example shows you how to get started using MediaConvert.
8787

8888

8989

@@ -113,4 +113,4 @@ in the `dotnetv3` folder.
113113

114114
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
115115

116-
SPDX-License-Identifier: Apache-2.0
116+
SPDX-License-Identifier: Apache-2.0

gov2/bedrock-runtime/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ For prerequisites, see the [README](../README.md#Prerequisites) in the `gov2` fo
3131

3232
### Get started
3333

34-
- [Hello Amazon Bedrock](hello/hello.go#L4) (`InvokeModel`)
34+
- [Hello Amazon Bedrock Runtime](hello/hello.go#L4) (`InvokeModel`)
3535

3636
### Scenarios
3737

@@ -78,9 +78,9 @@ go run ./hello -region=eu-central-1
7878
Be aware that not all regions may support Bedrock and its models yet. Verify service availability for your region [here](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/). For available models per region, refer to the [Bedrock dashboard](https://console.aws.amazon.com/bedrock) in the AWS Management Console.
7979
<!--custom.instructions.end-->
8080

81-
#### Hello Amazon Bedrock
81+
#### Hello Amazon Bedrock Runtime
8282

83-
This example shows you how to get started using Amazon Bedrock.
83+
This example shows you how to get started using Amazon Bedrock Runtime.
8484

8585
```
8686
go run ./hello
@@ -133,4 +133,4 @@ in the `gov2` folder.
133133

134134
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
135135

136-
SPDX-License-Identifier: Apache-2.0
136+
SPDX-License-Identifier: Apache-2.0

gov2/cognito/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ For prerequisites, see the [README](../README.md#Prerequisites) in the `gov2` fo
3131

3232
### Get started
3333

34-
- [Hello Amazon Cognito](hello/hello.go#L4) (`ListUserPools`)
34+
- [Hello Amazon Cognito Identity Provider](hello/hello.go#L4) (`ListUserPools`)
3535

3636

3737
### Single actions
@@ -69,9 +69,9 @@ functions within the same service.
6969
<!--custom.instructions.start-->
7070
<!--custom.instructions.end-->
7171

72-
#### Hello Amazon Cognito
72+
#### Hello Amazon Cognito Identity Provider
7373

74-
This example shows you how to get started using Amazon Cognito.
74+
This example shows you how to get started using Amazon Cognito Identity Provider.
7575

7676
```
7777
go run ./hello
@@ -162,4 +162,4 @@ in the `gov2` folder.
162162

163163
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
164164

165-
SPDX-License-Identifier: Apache-2.0
165+
SPDX-License-Identifier: Apache-2.0

javascriptv3/example_code/bedrock-runtime/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `javas
3636

3737
### Get started
3838

39-
- [Hello Amazon Bedrock](hello.js) (`InvokeModel`)
39+
- [Hello Amazon Bedrock Runtime](hello.js) (`InvokeModel`)
4040

4141
### Scenarios
4242

@@ -118,9 +118,9 @@ for that file.
118118
<!--custom.instructions.start-->
119119
<!--custom.instructions.end-->
120120

121-
#### Hello Amazon Bedrock
121+
#### Hello Amazon Bedrock Runtime
122122

123-
This example shows you how to get started using Amazon Bedrock.
123+
This example shows you how to get started using Amazon Bedrock Runtime.
124124

125125
```bash
126126
node ./hello.js
@@ -165,4 +165,4 @@ in the `javascriptv3` folder.
165165

166166
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
167167

168-
SPDX-License-Identifier: Apache-2.0
168+
SPDX-License-Identifier: Apache-2.0

javascriptv3/example_code/cognito-identity-provider/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `javas
3131

3232
### Get started
3333

34-
- [Hello Amazon Cognito](hello.js#L6) (`ListUserPools`)
34+
- [Hello Amazon Cognito Identity Provider](hello.js#L6) (`ListUserPools`)
3535

3636

3737
### Single actions
@@ -98,9 +98,9 @@ for that file.
9898
<!--custom.instructions.start-->
9999
<!--custom.instructions.end-->
100100

101-
#### Hello Amazon Cognito
101+
#### Hello Amazon Cognito Identity Provider
102102

103-
This example shows you how to get started using Amazon Cognito.
103+
This example shows you how to get started using Amazon Cognito Identity Provider.
104104

105105
```bash
106106
node ./hello.js
@@ -164,4 +164,4 @@ in the `javascriptv3` folder.
164164

165165
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
166166

167-
SPDX-License-Identifier: Apache-2.0
167+
SPDX-License-Identifier: Apache-2.0

javascriptv3/example_code/elastic-load-balancing-v2/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `javas
3131

3232
### Get started
3333

34-
- [Hello Elastic Load Balancing](hello.js) (`DescribeLoadBalancers`)
34+
- [Hello Elastic Load Balancing - Version 2](hello.js) (`DescribeLoadBalancers`)
3535

3636

3737
### Single actions
@@ -91,9 +91,9 @@ for that file.
9191
<!--custom.instructions.start-->
9292
<!--custom.instructions.end-->
9393

94-
#### Hello Elastic Load Balancing
94+
#### Hello Elastic Load Balancing - Version 2
9595

96-
This example shows you how to get started using Elastic Load Balancing.
96+
This example shows you how to get started using Elastic Load Balancing - Version 2.
9797

9898
```bash
9999
node ./hello.js
@@ -144,4 +144,4 @@ in the `javascriptv3` folder.
144144

145145
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
146146

147-
SPDX-License-Identifier: Apache-2.0
147+
SPDX-License-Identifier: Apache-2.0

javav2/example_code/kms/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Code excerpts that show you how to call individual service functions.
7777

7878
#### Hello AWS KMS
7979

80-
This example shows you how to get started using AWS Key Management Service (AWS KMS).
80+
This example shows you how to get started using AWS KMS.
8181

8282

8383
#### Learn the basics
@@ -126,4 +126,4 @@ in the `javav2` folder.
126126

127127
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
128128

129-
SPDX-License-Identifier: Apache-2.0
129+
SPDX-License-Identifier: Apache-2.0

javav2/example_code/s3/src/main/java/com/example/s3/directorybucket/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ For prerequisites, see the [README](../../../../../../../../../README.md#Prerequ
3131

3232
### Get started
3333

34-
- [Hello Amazon S3 directory buckets](HelloS3DirectoryBuckets.java#L4) (`CreateBucket`)
34+
- [Hello S3 Directory Buckets](HelloS3DirectoryBuckets.java#L4) (`CreateBucket`)
3535

3636

3737
### Single actions
@@ -83,9 +83,9 @@ functions within the same service.
8383
<!--custom.instructions.start-->
8484
<!--custom.instructions.end-->
8585

86-
#### Hello Amazon S3 directory buckets
86+
#### Hello S3 Directory Buckets
8787

88-
This example shows you how to get started using Amazon S3 directory buckets.
88+
This example shows you how to get started using S3 Directory Buckets.
8989

9090

9191

@@ -127,4 +127,4 @@ in the `javav2` folder.
127127

128128
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
129129

130-
SPDX-License-Identifier: Apache-2.0
130+
SPDX-License-Identifier: Apache-2.0

php/example_code/kms/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Code excerpts that show you how to call individual service functions.
7777

7878
#### Hello AWS KMS
7979

80-
This example shows you how to get started using AWS Key Management Service (AWS KMS).
80+
This example shows you how to get started using AWS KMS.
8181

8282

8383
#### Learn the basics
@@ -126,4 +126,4 @@ in the `php` folder.
126126

127127
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
128128

129-
SPDX-License-Identifier: Apache-2.0
129+
SPDX-License-Identifier: Apache-2.0

python/example_code/cognito/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ python -m pip install -r requirements.txt
3636

3737
### Get started
3838

39-
- [Hello Amazon Cognito](hello/hello_cognito.py#L4) (`ListUserPools`)
39+
- [Hello Amazon Cognito Identity Provider](hello/hello_cognito.py#L4) (`ListUserPools`)
4040

4141

4242
### Single actions
@@ -75,9 +75,9 @@ functions within the same service.
7575
<!--custom.instructions.start-->
7676
<!--custom.instructions.end-->
7777

78-
#### Hello Amazon Cognito
78+
#### Hello Amazon Cognito Identity Provider
7979

80-
This example shows you how to get started using Amazon Cognito.
80+
This example shows you how to get started using Amazon Cognito Identity Provider.
8181

8282
```
8383
python hello/hello_cognito.py
@@ -140,4 +140,4 @@ in the `python` folder.
140140

141141
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
142142

143-
SPDX-License-Identifier: Apache-2.0
143+
SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)