@@ -22,7 +22,7 @@ let us know if it's not up-to-date (even better, submit a PR with your correcti
22
22
- [ Step 5: Merge] ( #step-5-merge )
23
23
- [ Breaking Changes] ( #breaking-changes )
24
24
- [ Documentation] ( #documentation )
25
- - [ rosetta ] ( #rosetta )
25
+ - [ Rosetta ] ( #rosetta )
26
26
- [ Tools] ( #tools )
27
27
- [ Linters] ( #linters )
28
28
- [ cfn2ts] ( #cfn2ts )
@@ -217,6 +217,8 @@ Work your magic. Here are some guidelines:
217
217
Watch out for their error messages and adjust your code accordingly.
218
218
* Every change requires a unit test
219
219
* If you change APIs, make sure to update the module's README file
220
+ * When you add new examples to the module's README file, you must also ensure they compile - the PR build will fail
221
+ if they do not. To learn more about how to ensure that they compile, see [ Documentation] ( #documentation ) .
220
222
* Try to maintain a single feature/bugfix per pull request. It's okay to introduce a little bit of housekeeping
221
223
changes along the way, but try to avoid conflating multiple features. Eventually, all these are going to go into a
222
224
single commit, so you can use that to frame your scope.
@@ -508,7 +510,7 @@ the README for the `aws-ec2` module - https://docs.aws.amazon.com/cdk/api/latest
508
510
509
511
### Rosetta
510
512
511
- The README file contains code snippets written as typescript code. Code snippets typed in fenced code blocks
513
+ The README file contains code snippets written as typescript code. Code snippets typed in fenced code blocks
512
514
(such as `` ```ts `` ) will be automatically extracted, compiled and translated to other languages when the
513
515
during the [ pack] ( #pack ) step. We call this feature 'rosetta'.
514
516
@@ -541,11 +543,12 @@ When no fixture is specified, the fixture with the name
541
543
` rosetta/default.ts-fixture ` will be used if present. ` nofixture ` can be used to
542
544
opt out of that behavior.
543
545
544
- In an ` @example ` block, which is unfenced, the first line of the example can
545
- contain three slashes to achieve the same effect :
546
+ In an ` @example ` block, which is unfenced, additional information pertaining to
547
+ the example can be provided via the ` @exampleMetadata ` tag :
546
548
547
549
```
548
550
/**
551
+ * @exampleMetadata fixture=with-bucket
549
552
* @example
550
553
* /// fixture=with-bucket
551
554
* bucket.addLifecycleTransition({ ...props });
@@ -582,21 +585,21 @@ cases where some of those do not apply - good judgement is to be applied):
582
585
// ...rest of the example...
583
586
```
584
587
585
- - Within ` .ts-fixture ` files, make use of ` declare ` statements instead of
586
- writing a compatible value (this will make your fixtures more durable) :
588
+ - Make use of ` declare ` statements directly in examples for values that are
589
+ necessary for compilation but unimportant to the example :
587
590
588
591
``` ts
589
- // An hypothetical 'rosetta/default.ts-fixture' file in `@aws-cdk/core`
590
- import * as kms from ' @aws-cdk/aws-kms' ;
591
- import * as s3 from ' @aws-cdk/aws-s3' ;
592
- import { StackProps } from ' @aws-cdk/core' ;
593
-
594
- declare const kmsKey: kms .IKey ;
595
- declare const bucket: s3 .Bucket ;
596
-
597
- declare const props: StackProps ;
592
+ // An example about adding a stage to a pipeline in the @aws-cdk/pipelines library
593
+ declare const pipeline: pipelines .CodePipeline ;
594
+ declare const myStage: Stage ;
595
+ pipeline .addStage (myStage );
598
596
```
599
597
598
+ - Utilize the ` default.ts-fixture ` that already exists rather than writing new
599
+ ` .ts-fixture ` files. This is because values stored in ` .ts-fixture ` files do
600
+ not surface to the examples visible in the docs, so while they help successful
601
+ compilation, they do not help users understand the example.
602
+
600
603
## Tools (Advanced)
601
604
602
605
### scripts/foreach.sh
0 commit comments