Skip to content

Commit eec44e1

Browse files
authored
feat(rosetta): extract and compile samples into "tablets" (#925)
Version 2 of the "sampiler" is called "Rosetta". It now provides more control over the compilation of samples found in the source code. It integrates into an existing build by running `jsii-rosetta extract`, which will extract sample code from a jsii assembly, compile it, convert it to all supported languages, and storing the result in a a "tablet file" (effectively, a sample dictionary). Tablet files can then be used by `jsii-pacmak` to look up translations for the code samples it encounters as it is generating language-specific sources. In case the build does not contain a Rosetta step, Pacmak will try to convert samples that are not found in the tablet on the fly. However, the samples will not benefit from compilation, type checking and fixture support. This change also fixes the `jsii-pacmak` all-at-once builder, and will properly copy out binaries for the .NET and Java builds back to the declared output directories, and properly use output directories of packages not included in the megabuild as local package repositories.
1 parent a820217 commit eec44e1

97 files changed

Lines changed: 3174 additions & 1086 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ tsconfig.tsbuildinfo
77
dist/
88
.vscode
99
*.tsbuildinfo
10+
*.tabl.json

packages/jsii-calc-base-of-base/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
"main": "lib/index.js",
2525
"types": "lib/index.d.ts",
2626
"scripts": {
27-
"build": "jsii",
27+
"build": "jsii && jsii-rosetta",
2828
"test": "diff-test test/assembly.jsii .jsii",
2929
"test:update": "npm run build && UPDATE_DIFF=1 npm run test"
3030
},
3131
"devDependencies": {
3232
"jsii": "^0.20.5",
33+
"jsii-rosetta": "^0.20.5",
3334
"jsii-build-tools": "^0.20.5"
3435
},
3536
"jsii": {

packages/jsii-calc-base/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"main": "lib/index.js",
2525
"types": "lib/index.d.ts",
2626
"scripts": {
27-
"build": "jsii",
27+
"build": "jsii && jsii-rosetta",
2828
"test": "diff-test test/assembly.jsii .jsii",
2929
"test:update": "npm run build && UPDATE_DIFF=1 npm run test"
3030
},
@@ -36,6 +36,7 @@
3636
},
3737
"devDependencies": {
3838
"jsii": "^0.20.5",
39+
"jsii-rosetta": "^0.20.5",
3940
"jsii-build-tools": "^0.20.5"
4041
},
4142
"jsii": {
@@ -59,4 +60,4 @@
5960
},
6061
"versionFormat": "short"
6162
}
62-
}
63+
}

packages/jsii-calc-lib/.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66

77
# Include .jsii
88
!.jsii
9+
10+
11+
# Exclude jsii outdir
12+
dist

packages/jsii-calc-lib/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"main": "lib/index.js",
2727
"types": "lib/index.d.ts",
2828
"scripts": {
29-
"build": "jsii",
29+
"build": "jsii && jsii-rosetta",
3030
"test": "diff-test test/assembly.jsii .jsii",
3131
"test:update": "npm run build && UPDATE_DIFF=1 npm run test"
3232
},
@@ -38,6 +38,7 @@
3838
},
3939
"devDependencies": {
4040
"jsii": "^0.20.5",
41+
"jsii-rosetta": "^0.20.5",
4142
"jsii-build-tools": "^0.20.5"
4243
},
4344
"jsii": {
@@ -63,4 +64,4 @@
6364
},
6465
"versionFormat": "short"
6566
}
66-
}
67+
}

packages/jsii-calc/README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22

33
This library is used to demonstrate and test the features of JSII
44

5-
## Sphinx
5+
## How to use running sum API:
66

7-
This file will be incorporated into the sphinx documentation.
7+
First, create a calculator:
88

9-
If this file starts with an "H1" line (in our case `# jsii Calculator`), this
10-
heading will be used as the Sphinx topic name. Otherwise, the name of the module
11-
(`jsii-calc`) will be used instead.
9+
```ts
10+
const calculator = new calc.Calculator();
11+
```
12+
13+
Then call some operations:
14+
15+
16+
```ts fixture=with-calculator
17+
calculator.add(10);
18+
```
1219

1320
## Code Samples
1421

packages/jsii-calc/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"main": "lib/index.js",
2626
"types": "lib/index.d.ts",
2727
"scripts": {
28-
"build": "jsii",
28+
"build": "jsii && jsii-rosetta --compile",
2929
"watch": "jsii -w",
3030
"test": "node test/test.calc.js && diff-test test/assembly.jsii .jsii",
3131
"test:update": "npm run build && UPDATE_DIFF=1 npm run test"
@@ -43,6 +43,7 @@
4343
},
4444
"devDependencies": {
4545
"jsii": "^0.20.5",
46+
"jsii-rosetta": "^0.20.5",
4647
"jsii-build-tools": "^0.20.5"
4748
},
4849
"jsii": {
@@ -100,4 +101,4 @@
100101
]
101102
}
102103
]
103-
}
104+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import calc = require('.');
2+
3+
/// here
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import calc = require('.');
2+
const calculator = new calc.Calculator();
3+
4+
/// here

packages/jsii-calc/test/assembly.jsii

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
},
196196
"name": "jsii-calc",
197197
"readme": {
198-
"markdown": "# jsii Calculator\n\nThis library is used to demonstrate and test the features of JSII\n\n## Sphinx\n\nThis file will be incorporated into the sphinx documentation.\n\nIf this file starts with an \"H1\" line (in our case `# jsii Calculator`), this\nheading will be used as the Sphinx topic name. Otherwise, the name of the module\n(`jsii-calc`) will be used instead.\n\n## Code Samples\n\n```ts\n/* This is totes a magic comment in here, just you wait! */\nconst foo = 'bar';\n```\n"
198+
"markdown": "# jsii Calculator\n\nThis library is used to demonstrate and test the features of JSII\n\n## How to use running sum API:\n\nFirst, create a calculator:\n\n```ts\nconst calculator = new calc.Calculator();\n```\n\nThen call some operations:\n\n\n```ts fixture=with-calculator\ncalculator.add(10);\n```\n\n## Code Samples\n\n```ts\n/* This is totes a magic comment in here, just you wait! */\nconst foo = 'bar';\n```\n"
199199
},
200200
"repository": {
201201
"directory": "packages/jsii-calc",
@@ -11128,5 +11128,5 @@
1112811128
}
1112911129
},
1113011130
"version": "0.20.5",
11131-
"fingerprint": "g9C1lL8c+vgxBjOWVBFMMPlcwkF3Z81xxTAGfc73x9o="
11131+
"fingerprint": "/MRTbTnRC1UWxsPIrca+9Yo1IBKsEueT75P22pQoV1o="
1113211132
}

0 commit comments

Comments
 (0)