Skip to content

Commit

Permalink
fix(rosetta): 'extract' does not translate samples in submodule READM…
Browse files Browse the repository at this point in the history
…Es (#2744)

Now that the CDK release branch contains the ubergen [fix](aws/aws-cdk@e047bda) that aligns rosseta fixtures, we can try and re-introduce this fix. 

---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
  • Loading branch information
iliapolo authored Mar 30, 2021
1 parent 2310f54 commit 0a3f01f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/jsii-rosetta/lib/jsii/assemblies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ export function allSnippetSources(
});
}

for (const [submoduleFqn, submodule] of Object.entries(
assembly.submodules ?? {},
)) {
if (submodule.readme) {
ret.push({
type: 'markdown',
markdown: submodule.readme.markdown,
where: removeSlashes(`${submoduleFqn}-README`),
});
}
}

if (assembly.types) {
Object.values(assembly.types).forEach((type) => {
emitDocs(type.docs, `${assembly.name}.${type.name}`);
Expand Down
27 changes: 27 additions & 0 deletions packages/jsii-rosetta/test/jsii/assemblies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,33 @@ test('Extract snippet from README', () => {
expect(snippets[0].visibleSource).toEqual('someExample();');
});

test('Extract snippet from submodule READMEs', () => {
const snippets = Array.from(
allTypeScriptSnippets([
{
assembly: fakeAssembly({
submodules: {
'my.submodule': {
readme: {
markdown: [
'Before the example.',
'```ts',
'someExample();',
'```',
'After the example.',
].join('\n'),
},
},
},
}),
directory: path.join(__dirname, 'fixtures'),
},
]),
);

expect(snippets[0].visibleSource).toEqual('someExample();');
});

test('Extract snippet from type docstring', () => {
const snippets = Array.from(
allTypeScriptSnippets([
Expand Down

0 comments on commit 0a3f01f

Please sign in to comment.