in src/docgen/view/documentation.ts [288:324]
private async createAssembly(
language: TargetLanguage | undefined,
options: Required<TransliterationOptions>,
): Promise<reflect.Assembly> {
const cacheKey = `lang:${language ?? 'ts'}.loose:${options.loose}.validate:${options.validate}`;
const cached = this.assembliesCache.get(cacheKey);
if (cached) {
return cached;
}
const created = await withTempDir(async (workdir: string) => {
// always better not to pollute an externally provided directory
await fs.copy(this.assembliesDir, workdir);
const ts = new reflect.TypeSystem();
for (let dotJsii of await glob.promise(`${workdir}/**/.jsii`)) {
// we only transliterate the top level assembly and not the entire type-system.
// note that the only reason to translate dependant assemblies is to show code examples
// for expanded python arguments - which we don't to right now anyway.
// we don't want to make any assumption of the directory structure, so this is the most
// robuse way to detect the root assembly.
const spec = JSON.parse(await fs.readFile(dotJsii, 'utf-8'));
if (language && spec.name === this.assemblyName) {
const packageDir = path.dirname(dotJsii);
await transliterateAssembly([packageDir], [language], { loose: options.loose });
dotJsii = path.join(packageDir, `.jsii.${language}`);
}
await ts.load(dotJsii, { validate: options.validate });
}
return ts.findAssembly(this.assemblyName);
});
this.assembliesCache.set(cacheKey, created);
return created;
}