Generate synthetic examples for CDK libraries
npm install cdk-generate-synthetic-examplesThis tool will find all classes in the JSII assembly that don't yet have
any example code associated with them, and will generate a synthetic
example that shows how to instantiate the type. This is a method of last
resort: we'd obviously prefer hand-written examples, but this will make sure
all classes get something usable (which otherwise would not have any
examples at all). It is designed to run during the build of a CDK Construct
Library.
This tool is published as an npm module, install locally:
``bash`
npm install cdk-generate-synthetic-examples
Suppose you are in the base directory of your CDK construct, aws-construct..jsii
After a successful build, you have a file.cdk-generate-synthetic-examples will generate examples for types without
doc examples and directly modify the assembly.
As part of the command, a _generated.ts-fixture file will be added to yourrosetta
project's directory. This fixture contains the necessary importsrosetta:extract
that will ensure compilation when is run.
`bash`
npx cdk-generate-synthetic-examples .jsii
A common workflow is to run cdk-generate-synthetic-examples sandwichedrosetta:extract
between calls to .rosetta:extract
The first will extract any possible hand-written examplesrosetta:extract
into your assembly. The second will then compile and
translate the new synthetic examples.
The --extract flag is simply a helper that does the second rosetta:extract
call for you.
`bash`
npx cdk-generate-synthetic-examples .jsii --extract
You can send common rosetta:extract options throughcdk-generate-synthetic-examples as well.
`bash``
npx cdk-generate-synthetic-examples \
path/to/cdk/directory/.jsii \
--extract \
--extract-cache='rosetta-cache.tabl.json' \
--extract-directory='path/to/cdk/directory'
See CONTRIBUTING for more
information.
This project is licensed under the Apache-2.0 License.