jsii-rosetta 5.5.4 → 5.5.5-dev.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/languages/index.d.ts +2 -0
- package/lib/languages/index.js +13 -0
- package/lib/languages/index.js.map +1 -1
- package/lib/main.js +17 -8
- package/lib/main.js.map +1 -1
- package/lib/markdown/xml-comment-renderer.d.ts +4 -4
- package/lib/markdown/xml-comment-renderer.js +12 -7
- package/lib/markdown/xml-comment-renderer.js.map +1 -1
- package/package.json +5 -5
package/lib/languages/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { TargetLanguage } from './target-language';
|
2
|
+
import { VisualizeAstVisitor } from './visualize';
|
2
3
|
import { AstHandler } from '../renderer';
|
3
4
|
export { TargetLanguage };
|
4
5
|
export interface VisitorFactory {
|
@@ -8,4 +9,5 @@ export interface VisitorFactory {
|
|
8
9
|
export declare const TARGET_LANGUAGES: {
|
9
10
|
[key in TargetLanguage]: VisitorFactory;
|
10
11
|
};
|
12
|
+
export declare function getVisitorFromLanguage(language: string | undefined): VisualizeAstVisitor | AstHandler<any>;
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/languages/index.js
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.TARGET_LANGUAGES = exports.TargetLanguage = void 0;
|
4
|
+
exports.getVisitorFromLanguage = getVisitorFromLanguage;
|
4
5
|
const csharp_1 = require("./csharp");
|
5
6
|
const go_1 = require("./go");
|
6
7
|
const java_1 = require("./java");
|
7
8
|
const python_1 = require("./python");
|
8
9
|
const target_language_1 = require("./target-language");
|
9
10
|
Object.defineProperty(exports, "TargetLanguage", { enumerable: true, get: function () { return target_language_1.TargetLanguage; } });
|
11
|
+
const visualize_1 = require("./visualize");
|
10
12
|
exports.TARGET_LANGUAGES = {
|
11
13
|
[target_language_1.TargetLanguage.PYTHON]: {
|
12
14
|
version: python_1.PythonVisitor.VERSION,
|
@@ -25,4 +27,15 @@ exports.TARGET_LANGUAGES = {
|
|
25
27
|
createVisitor: () => new go_1.GoVisitor(),
|
26
28
|
},
|
27
29
|
};
|
30
|
+
function getVisitorFromLanguage(language) {
|
31
|
+
if (language !== undefined) {
|
32
|
+
const target = Object.values(target_language_1.TargetLanguage).find((t) => t === language);
|
33
|
+
if (target === undefined) {
|
34
|
+
throw new Error(`Unknown target language: ${language}. Expected one of ${Object.values(target_language_1.TargetLanguage).join(', ')}`);
|
35
|
+
}
|
36
|
+
return exports.TARGET_LANGUAGES[target].createVisitor();
|
37
|
+
}
|
38
|
+
// Default to visualizing AST, including nodes we don't recognize yet
|
39
|
+
return new visualize_1.VisualizeAstVisitor();
|
40
|
+
}
|
28
41
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/languages/index.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/languages/index.ts"],"names":[],"mappings":";;;AAkCA,wDAYC;AA9CD,qCAAyC;AACzC,6BAAiC;AACjC,iCAAqC;AACrC,qCAAyC;AACzC,uDAAmD;AAI1C,+FAJA,gCAAc,OAIA;AAHvB,2CAAkD;AAUrC,QAAA,gBAAgB,GAAgD;IAC3E,CAAC,gCAAc,CAAC,MAAM,CAAC,EAAE;QACvB,OAAO,EAAE,sBAAa,CAAC,OAAO;QAC9B,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,sBAAa,EAAE;KACzC;IACD,CAAC,gCAAc,CAAC,MAAM,CAAC,EAAE;QACvB,OAAO,EAAE,sBAAa,CAAC,OAAO;QAC9B,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,sBAAa,EAAE;KACzC;IACD,CAAC,gCAAc,CAAC,IAAI,CAAC,EAAE;QACrB,OAAO,EAAE,kBAAW,CAAC,OAAO;QAC5B,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,kBAAW,EAAE;KACvC;IACD,CAAC,gCAAc,CAAC,EAAE,CAAC,EAAE;QACnB,OAAO,EAAE,cAAS,CAAC,OAAO;QAC1B,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,cAAS,EAAE;KACrC;CACF,CAAC;AAEF,SAAgB,sBAAsB,CAAC,QAA4B;IACjE,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,gCAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;QACzE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,4BAA4B,QAAQ,qBAAqB,MAAM,CAAC,MAAM,CAAC,gCAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpG,CAAC;QACJ,CAAC;QACD,OAAO,wBAAgB,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAC;IAClD,CAAC;IACD,qEAAqE;IACrE,OAAO,IAAI,+BAAmB,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { CSharpVisitor } from './csharp';\nimport { GoVisitor } from './go';\nimport { JavaVisitor } from './java';\nimport { PythonVisitor } from './python';\nimport { TargetLanguage } from './target-language';\nimport { VisualizeAstVisitor } from './visualize';\nimport { AstHandler } from '../renderer';\n\nexport { TargetLanguage };\n\nexport interface VisitorFactory {\n readonly version: string;\n createVisitor(): AstHandler<any>;\n}\n\nexport const TARGET_LANGUAGES: { [key in TargetLanguage]: VisitorFactory } = {\n [TargetLanguage.PYTHON]: {\n version: PythonVisitor.VERSION,\n createVisitor: () => new PythonVisitor(),\n },\n [TargetLanguage.CSHARP]: {\n version: CSharpVisitor.VERSION,\n createVisitor: () => new CSharpVisitor(),\n },\n [TargetLanguage.JAVA]: {\n version: JavaVisitor.VERSION,\n createVisitor: () => new JavaVisitor(),\n },\n [TargetLanguage.GO]: {\n version: GoVisitor.VERSION,\n createVisitor: () => new GoVisitor(),\n },\n};\n\nexport function getVisitorFromLanguage(language: string | undefined) {\n if (language !== undefined) {\n const target = Object.values(TargetLanguage).find((t) => t === language);\n if (target === undefined) {\n throw new Error(\n `Unknown target language: ${language}. Expected one of ${Object.values(TargetLanguage).join(', ')}`,\n );\n }\n return TARGET_LANGUAGES[target].createVisitor();\n }\n // Default to visualizing AST, including nodes we don't recognize yet\n return new VisualizeAstVisitor();\n}\n"]}
|
package/lib/main.js
CHANGED
@@ -13,8 +13,6 @@ const transliterate_1 = require("./commands/transliterate");
|
|
13
13
|
const trim_cache_1 = require("./commands/trim-cache");
|
14
14
|
const index_1 = require("./index");
|
15
15
|
const languages_1 = require("./languages");
|
16
|
-
const python_1 = require("./languages/python");
|
17
|
-
const visualize_1 = require("./languages/visualize");
|
18
16
|
const logging = require("./logging");
|
19
17
|
const support_1 = require("./support");
|
20
18
|
const util_1 = require("./util");
|
@@ -33,11 +31,17 @@ async function main() {
|
|
33
31
|
.positional('FILE', {
|
34
32
|
type: 'string',
|
35
33
|
describe: 'The file to translate (leave out for stdin)',
|
34
|
+
})
|
35
|
+
.option('language', {
|
36
|
+
type: 'string',
|
37
|
+
describe: 'Language ID to transliterate to',
|
38
|
+
choices: Array.from(new Set(Object.values(languages_1.TargetLanguage))),
|
36
39
|
})
|
37
40
|
.option('python', {
|
38
41
|
alias: 'p',
|
39
42
|
boolean: true,
|
40
|
-
|
43
|
+
deprecated: true,
|
44
|
+
description: 'Translate snippets to Python. Use --language python instead.',
|
41
45
|
}), wrapHandler(async (args) => {
|
42
46
|
const result = (0, index_1.translateTypeScript)(await makeFileSource(args.FILE ?? '-', 'stdin.ts'), makeVisitor(args));
|
43
47
|
handleSingleResult(result);
|
@@ -46,11 +50,17 @@ async function main() {
|
|
46
50
|
.positional('FILE', {
|
47
51
|
type: 'string',
|
48
52
|
describe: 'The file to translate (leave out for stdin)',
|
53
|
+
})
|
54
|
+
.option('language', {
|
55
|
+
type: 'string',
|
56
|
+
describe: 'Language ID to transliterate to',
|
57
|
+
choices: Array.from(new Set(Object.values(languages_1.TargetLanguage))),
|
49
58
|
})
|
50
59
|
.option('python', {
|
51
60
|
alias: 'p',
|
52
61
|
boolean: true,
|
53
|
-
|
62
|
+
deprecated: true,
|
63
|
+
description: 'Translate snippets to Python. Use --language python instead.',
|
54
64
|
}), wrapHandler(async (args) => {
|
55
65
|
const result = (0, convert_1.translateMarkdown)(await makeFileSource(args.FILE ?? '-', 'stdin.md'), makeVisitor(args));
|
56
66
|
handleSingleResult(result);
|
@@ -385,11 +395,10 @@ function wrapHandler(handler) {
|
|
385
395
|
};
|
386
396
|
}
|
387
397
|
function makeVisitor(args) {
|
388
|
-
if (args.python) {
|
389
|
-
|
398
|
+
if (args.python != null && args.language == null) {
|
399
|
+
args.language = 'python';
|
390
400
|
}
|
391
|
-
|
392
|
-
return new visualize_1.VisualizeAstVisitor();
|
401
|
+
return (0, languages_1.getVisitorFromLanguage)(args.language);
|
393
402
|
}
|
394
403
|
async function makeFileSource(fileName, stdinName) {
|
395
404
|
if (fileName === '-') {
|
package/lib/main.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,gCAA8B;AAE9B,qCAAyC;AACzC,kCAAkC;AAClC,+BAA+B;AAE/B,gDAAuD;AACvD,kDAAoD;AACpD,gDAAuF;AACvF,8CAA0E;AAC1E,0CAA6C;AAC7C,4DAAiE;AACjE,sDAAkD;AAClD,mCAAkF;AAClF,2CAA6C;AAC7C,+CAAmD;AACnD,qDAA4D;AAC5D,qCAAqC;AACrC,uCAAyD;AACzD,iCAAsD;AAEtD,KAAK,UAAU,IAAI;IACjB,MAAM,IAAA,sCAA4B,GAAE,CAAC;IAErC,MAAM,IAAI,GAAG,KAAK;SACf,KAAK,CAAC,iBAAiB,CAAC;SACxB,MAAM,CAAC,SAAS,EAAE;QACjB,KAAK,EAAE,GAAG;QACV,I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AAK,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;AACxB,CAAC,CAAC,CAAC","sourcesContent":["import '@jsii/check-node/run';\n\nimport { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport * as yargs from 'yargs';\n\nimport { translateMarkdown } from './commands/convert';\nimport { checkCoverage } from './commands/coverage';\nimport { extractAndInfuse, extractSnippets, ExtractOptions } from './commands/extract';\nimport { infuse, DEFAULT_INFUSION_RESULTS_NAME } from './commands/infuse';\nimport { readTablet } from './commands/read';\nimport { transliterateAssembly } from './commands/transliterate';\nimport { trimCache } from './commands/trim-cache';\nimport { TranslateResult, translateTypeScript, RosettaDiagnostic } from './index';\nimport { TargetLanguage } from './languages';\nimport { PythonVisitor } from './languages/python';\nimport { VisualizeAstVisitor } from './languages/visualize';\nimport * as logging from './logging';\nimport { emitSupportPolicyInformation } from './support';\nimport { File, fmap, printDiagnostics } from './util';\n\nasync function main() {\n await emitSupportPolicyInformation();\n\n const argv = yargs\n .usage('$0 <cmd> [args]')\n .option('verbose', {\n alias: 'v',\n type: 'boolean',\n desc: 'Increase logging verbosity',\n count: true,\n default: 0,\n })\n .command(\n 'snippet FILE',\n 'Translate a single snippet',\n (command) =>\n command\n .positional('FILE', {\n type: 'string',\n describe: 'The file to translate (leave out for stdin)',\n })\n .option('python', {\n alias: 'p',\n boolean: true,\n description: 'Translate snippets to Python',\n }),\n wrapHandler(async (args) => {\n const result = translateTypeScript(await makeFileSource(args.FILE ?? '-', 'stdin.ts'), makeVisitor(args));\n handleSingleResult(result);\n }),\n )\n .command(\n 'markdown FILE',\n 'Translate a MarkDown file',\n (command) =>\n command\n .positional('FILE', {\n type: 'string',\n describe: 'The file to translate (leave out for stdin)',\n })\n .option('python', {\n alias: 'p',\n boolean: true,\n description: 'Translate snippets to Python',\n }),\n wrapHandler(async (args) => {\n const result = translateMarkdown(await makeFileSource(args.FILE ?? '-', 'stdin.md'), makeVisitor(args));\n handleSingleResult(result);\n }),\n )\n .command(\n 'infuse [ASSEMBLY..]',\n '(EXPERIMENTAL) mutates one or more assemblies by adding documentation examples to top-level types',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to mutate',\n })\n .option('log-file', {\n alias: 'l',\n type: 'string',\n describe: 'Output file to store logging results. Ignored if -log is not true',\n default: DEFAULT_INFUSION_RESULTS_NAME,\n })\n .option('cache-from', {\n alias: 'C',\n type: 'string',\n // eslint-disable-next-line prettier/prettier\n describe:\n 'Reuse translations from the given tablet file if the snippet and type definitions did not change',\n requiresArg: true,\n default: undefined,\n })\n .option('cache-to', {\n alias: 'o',\n type: 'string',\n describe: 'Append all translated snippets to the given tablet file',\n requiresArg: true,\n default: undefined,\n })\n .option('cache', {\n alias: 'k',\n type: 'string',\n describe: 'Alias for --cache-from and --cache-to together',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache', 'cache-from')\n .conflicts('cache', 'cache-to'),\n wrapHandler(async (args) => {\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n const absCacheFrom = fmap(args.cache ?? args['cache-from'], path.resolve);\n const absCacheTo = fmap(args.cache ?? args['cache-to'], path.resolve);\n const result = await infuse(absAssemblies, {\n logFile: args['log-file'],\n cacheToFile: absCacheTo,\n cacheFromFile: absCacheFrom,\n });\n\n let totalTypes = 0;\n let insertedExamples = 0;\n for (const [directory, map] of Object.entries(result.coverageResults)) {\n const commonName = directory.split('/').pop()!;\n const newCoverage = roundPercentage(map.typesWithInsertedExamples / map.types);\n process.stdout.write(\n `${commonName}: Added ${map.typesWithInsertedExamples} examples to ${map.types} types.\\n`,\n );\n process.stdout.write(`${commonName}: New coverage: ${newCoverage}%.\\n`);\n\n insertedExamples += map.typesWithInsertedExamples;\n totalTypes += map.types;\n }\n const newCoverage = roundPercentage(insertedExamples / totalTypes);\n process.stdout.write(`\\n\\nFinal Stats:\\nNew coverage: ${newCoverage}%.\\n`);\n }),\n )\n .command(\n ['extract [ASSEMBLY..]', '$0 [ASSEMBLY..]'],\n 'Extract code snippets from one or more assemblies into language tablets',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to extract from',\n })\n .option('output', {\n type: 'string',\n describe: 'Additional output file where to store translated samples (deprecated, alias for --cache-to)',\n requiresArg: true,\n default: undefined,\n })\n .option('compile', {\n alias: 'c',\n type: 'boolean',\n describe: 'Try compiling (on by default, use --no-compile to switch off)',\n default: true,\n })\n .option('directory', {\n alias: 'd',\n type: 'string',\n describe: 'Working directory (for require() etc)',\n })\n .option('include', {\n alias: 'i',\n type: 'string',\n array: true,\n describe: 'Extract only snippets with given ids',\n default: [],\n })\n .option('infuse', {\n type: 'boolean',\n describe: 'bundle this command with the infuse command',\n default: false,\n })\n .option('fail', {\n alias: 'f',\n type: 'boolean',\n describe: 'Fail if there are compilation errors',\n default: false,\n })\n .option('validate-assemblies', {\n type: 'boolean',\n describe: 'Whether to validate loaded assemblies or not (this can be slow)',\n default: false,\n })\n .option('cache-from', {\n alias: 'C',\n type: 'string',\n // eslint-disable-next-line prettier/prettier\n describe:\n 'Reuse translations from the given tablet file if the snippet and type definitions did not change',\n requiresArg: true,\n default: undefined,\n })\n .option('cache-to', {\n alias: 'o',\n type: 'string',\n describe: 'Append all translated snippets to the given tablet file',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache-to', 'output')\n .option('cache', {\n alias: 'k',\n type: 'string',\n describe: 'Alias for --cache-from and --cache-to together',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache', 'cache-from')\n .conflicts('cache', 'cache-to')\n .option('trim-cache', {\n alias: 'T',\n type: 'boolean',\n describe: 'Remove translations that are not referenced by any of the assemblies anymore from the cache',\n })\n .option('strict', {\n alias: 'S',\n type: 'boolean',\n describe:\n 'Require all code samples compile, and fail if one does not. Strict mode always enables --compile and --fail',\n default: false,\n })\n .options('loose', {\n alias: 'l',\n describe: 'Ignore missing fixtures and literate markdown files instead of failing',\n type: 'boolean',\n })\n .options('compress-tablet', {\n alias: 'z',\n type: 'boolean',\n describe: 'Compress the implicit tablet file',\n default: false,\n })\n .options('compress-cache', {\n type: 'boolean',\n describe: 'Compress the cache-to file',\n default: false,\n })\n .options('cleanup', {\n type: 'boolean',\n describe: 'Clean up temporary directories',\n default: true,\n })\n .conflicts('loose', 'strict')\n .conflicts('loose', 'fail'),\n wrapHandler(async (args) => {\n // `--strict` is short for `--compile --fail`, and we'll override those even if they're set to `false`, such as\n // using `--no-(compile|fail)`, because yargs does not quite give us a better option that does not hurt CX.\n if (args.strict) {\n args.compile = args.c = true;\n args.fail = args.f = true;\n }\n\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n\n const absCacheFrom = fmap(args.cache ?? args['cache-from'], path.resolve);\n const absCacheTo = fmap(args.cache ?? args['cache-to'] ?? args.output, path.resolve);\n\n const extractOptions: ExtractOptions = {\n compilationDirectory: args.directory,\n includeCompilerDiagnostics: !!args.compile,\n validateAssemblies: args['validate-assemblies'],\n only: args.include,\n cacheFromFile: absCacheFrom,\n cacheToFile: absCacheTo,\n trimCache: args['trim-cache'],\n loose: args.loose,\n compressTablet: args['compress-tablet'],\n compressCacheToFile: args['compress-cache'],\n cleanup: args.cleanup,\n };\n\n const result = args.infuse\n ? await extractAndInfuse(absAssemblies, extractOptions)\n : await extractSnippets(absAssemblies, extractOptions);\n\n handleDiagnostics(result.diagnostics, args.fail, result.tablet.count);\n }),\n )\n .command(\n 'transliterate [ASSEMBLY..]',\n '(EXPERIMENTAL) Transliterates the designated assemblies',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n required: true,\n describe: 'Assembly to transliterate',\n })\n .option('language', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Language ID to transliterate to',\n })\n .options('strict', {\n alias: 's',\n conflicts: 'loose',\n describe:\n 'Fail if an example that needs live transliteration fails to compile (which could cause incorrect transpilation results)',\n type: 'boolean',\n })\n .options('loose', {\n alias: 'l',\n conflicts: 'strict',\n describe: 'Ignore missing fixtures and literate markdown files instead of failing',\n type: 'boolean',\n })\n .option('tablet', {\n alias: 't',\n type: 'string',\n describe:\n 'Language tablet containing pre-translated code examples to use (these are generated by the `extract` command)',\n }),\n wrapHandler((args) => {\n const assemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((dir) =>\n path.resolve(process.cwd(), dir),\n );\n const languages =\n args.language.length > 0\n ? args.language\n .map((lang) => lang.toUpperCase())\n .map((lang) => {\n const target = Object.entries(TargetLanguage).find(([k]) => k === lang)?.[1];\n if (target == null) {\n throw new Error(\n `Unknown target language: ${lang}. Expected one of ${Object.keys(TargetLanguage).join(', ')}`,\n );\n }\n return target;\n })\n : Object.values(TargetLanguage);\n return transliterateAssembly(assemblies, languages, args);\n }),\n )\n .command(\n 'trim-cache <TABLET> [ASSEMBLY..]',\n 'Retain only those snippets in the cache which occur in one of the given assemblies',\n (command) =>\n command\n .positional('TABLET', {\n type: 'string',\n required: true,\n describe: 'Language tablet to trim',\n })\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to search',\n })\n .demandOption('TABLET'),\n wrapHandler(async (args) => {\n await trimCache({\n cacheFile: args.TABLET,\n assemblyLocations: args.ASSEMBLY,\n });\n }),\n )\n .command(\n 'coverage [ASSEMBLY..]',\n 'Check the translation coverage of implicit tablets for the given assemblies',\n (command) =>\n command.positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: ['.'],\n describe: 'Assembly or directory to search',\n }),\n wrapHandler(async (args) => {\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n await checkCoverage(absAssemblies);\n }),\n )\n .command(\n 'read <TABLET> [KEY] [LANGUAGE]',\n 'Display snippets in a language tablet file',\n (command) =>\n command\n .positional('TABLET', {\n type: 'string',\n required: true,\n describe: 'Language tablet to read',\n })\n .positional('KEY', {\n type: 'string',\n describe: 'Snippet key to read',\n })\n .positional('LANGUAGE', {\n type: 'string',\n describe: 'Language ID to read',\n })\n .demandOption('TABLET'),\n wrapHandler(async (args) => {\n await readTablet(args.TABLET, args.KEY, args.LANGUAGE);\n }),\n )\n .command(\n 'configure-strict [PACKAGE]',\n \"Enables strict mode for a package's assembly\",\n (command) =>\n command.positional('PACKAGE', {\n type: 'string',\n describe: 'The path to the package to configure',\n required: false,\n default: '.',\n normalize: true,\n }),\n wrapHandler(async (args) => {\n const packageJsonPath = (await fs.stat(args.PACKAGE)).isDirectory()\n ? path.join(args.PACKAGE, 'package.json')\n : args.PACKAGE;\n const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));\n if (packageJson.jsii == null) {\n console.error(\n `The package in ${args.PACKAGE} does not have a jsii configuration! You can set it up using jsii-config.`,\n );\n process.exitCode = 1;\n return Promise.resolve();\n }\n if (packageJson.jsii.metadata?.jsii?.rosetta?.strict) {\n // Nothing to do - it's already configured, so we assert idempotent success!\n return Promise.resolve();\n }\n const md = (packageJson.jsii.metadata = packageJson.jsii.metadata ?? {});\n const mdJsii = (md.jsii = md.jsii ?? {});\n const mdRosetta = (mdJsii.rosetta = mdJsii.rosetta ?? {});\n mdRosetta.strict = true;\n\n return fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));\n }),\n )\n .demandCommand()\n .help()\n .strict() // Error on wrong command\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n .version(require('../package.json').version)\n .showHelpOnFail(false).argv;\n\n // Evaluating .argv triggers the parsing but the command gets implicitly executed,\n // so we don't need the output.\n Array.isArray(argv);\n}\n\n/**\n * Wrap a command's handler with standard pre- and post-work\n */\nfunction wrapHandler<A extends { verbose?: number }, R>(handler: (x: A) => Promise<R>) {\n return (argv: A) => {\n logging.configure({ level: argv.verbose !== undefined ? argv.verbose : 0 });\n handler(argv).catch((e) => {\n logging.error(e.message);\n logging.error(e.stack);\n process.exitCode = 1;\n });\n };\n}\n\nfunction makeVisitor(args: { python?: boolean }) {\n if (args.python) {\n return new PythonVisitor();\n }\n // Default to visualizing AST, including nodes we don't recognize yet\n return new VisualizeAstVisitor();\n}\n\nasync function makeFileSource(fileName: string, stdinName: string): Promise<File> {\n if (fileName === '-') {\n return {\n contents: await readStdin(),\n fileName: stdinName,\n };\n }\n return {\n contents: await fs.readFile(fileName, { encoding: 'utf-8' }),\n fileName: fileName,\n };\n}\n\nasync function readStdin(): Promise<string> {\n process.stdin.setEncoding('utf8');\n\n const parts: Buffer[] = [];\n\n return new Promise((resolve, reject) => {\n process.stdin.on('readable', () => {\n const chunk = process.stdin.read();\n if (chunk !== null) {\n parts.push(Buffer.from(chunk));\n }\n });\n\n process.stdin.on('error', reject);\n process.stdin.on('end', () => resolve(Buffer.concat(parts).toString('utf-8')));\n });\n}\n\nfunction handleSingleResult(result: TranslateResult) {\n process.stdout.write(`${result.translation}\\n`);\n\n // For a single result, we always request implicit failure.\n handleDiagnostics(result.diagnostics, 'implicit');\n}\n\n/**\n * Print diagnostics and set exit code\n *\n * 'fail' is whether or not the user passed '--fail' for commands that accept\n * it, or 'implicit' for commands that should always fail. 'implicit' will be\n * treated as 'fail=true, but will not print to the user that the '--fail' is\n * set (because for this particular command that switch does not exist and so it\n * would be confusing).\n */\nfunction handleDiagnostics(diagnostics: readonly RosettaDiagnostic[], fail: boolean | 'implicit', snippetCount = 1) {\n if (fail !== false) {\n // Fail on any diagnostic\n if (diagnostics.length > 0) {\n printDiagnostics(diagnostics, process.stderr, process.stderr.isTTY);\n logging.error(\n [\n `${diagnostics.length} diagnostics encountered in ${snippetCount} snippets`,\n ...(fail === true ? [\"(running with '--fail')\"] : []),\n ].join(' '),\n );\n process.exitCode = 1;\n }\n\n return;\n }\n\n // Otherwise fail only on strict diagnostics. If we have strict diagnostics, print only those\n // (so it's very clear what is failing the build), otherwise print everything.\n const strictDiagnostics = diagnostics.filter((diag) => diag.isFromStrictAssembly);\n if (strictDiagnostics.length > 0) {\n printDiagnostics(strictDiagnostics, process.stderr, process.stderr.isTTY);\n const remaining = diagnostics.length - strictDiagnostics.length;\n logging.warn(\n [\n `${strictDiagnostics.length} diagnostics from assemblies with 'strict' mode on`,\n ...(remaining > 0 ? [`(and ${remaining} more non-strict diagnostics)`] : []),\n ].join(' '),\n );\n process.exitCode = 1;\n return;\n }\n\n if (diagnostics.length > 0) {\n printDiagnostics(diagnostics, process.stderr, process.stderr.isTTY);\n logging.warn(`${diagnostics.length} diagnostics encountered in ${snippetCount} snippets`);\n }\n}\n\n/**\n * Rounds a decimal number to two decimal points.\n * The function is useful for fractions that need to be outputted as percentages.\n */\nfunction roundPercentage(num: number): number {\n return Math.round(10000 * num) / 100;\n}\n\nmain().catch((cause) => {\n console.error(cause);\n process.exitCode = -1;\n});\n"]}
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,gCAA8B;AAE9B,qCAAyC;AACzC,kCAAkC;AAClC,+BAA+B;AAE/B,gDAAuD;AACvD,kDAAoD;AACpD,gDAAuF;AACvF,8CAA0E;AAC1E,0CAA6C;AAC7C,4DAAiE;AACjE,sDAAkD;AAClD,mCAAkF;AAClF,2CAAqE;AACrE,qCAAqC;AACrC,uCAAyD;AACzD,iCAAsD;AAEtD,KAAK,UAAU,IAAI;IACjB,MAAM,IAAA,sCAA4B,GAAE,CAAC;IAErC,MAAM,IAAI,GAAG,KAAK;SACf,KAAK,CAAC,iBAAiB,CAAC;SACxB,MAAM,CAAC,SAAS,EAAE;QACjB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,4BAA4B;QAClC,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC;KACX,CAAC;SACD,OAAO,CACN,cAAc,EACd,4BAA4B,EAC5B,CAAC,OAAO,EAAE,EAAE,CACV,OAAO;SAC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CAAC,CAAC;QACpE,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,MAAM,+BAA+B,YAAY,WAAW,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACvC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;AACxB,CAAC,CAAC,CAAC","sourcesContent":["import '@jsii/check-node/run';\n\nimport { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport * as yargs from 'yargs';\n\nimport { translateMarkdown } from './commands/convert';\nimport { checkCoverage } from './commands/coverage';\nimport { extractAndInfuse, extractSnippets, ExtractOptions } from './commands/extract';\nimport { infuse, DEFAULT_INFUSION_RESULTS_NAME } from './commands/infuse';\nimport { readTablet } from './commands/read';\nimport { transliterateAssembly } from './commands/transliterate';\nimport { trimCache } from './commands/trim-cache';\nimport { TranslateResult, translateTypeScript, RosettaDiagnostic } from './index';\nimport { getVisitorFromLanguage, TargetLanguage } from './languages';\nimport * as logging from './logging';\nimport { emitSupportPolicyInformation } from './support';\nimport { File, fmap, printDiagnostics } from './util';\n\nasync function main() {\n await emitSupportPolicyInformation();\n\n const argv = yargs\n .usage('$0 <cmd> [args]')\n .option('verbose', {\n alias: 'v',\n type: 'boolean',\n desc: 'Increase logging verbosity',\n count: true,\n default: 0,\n })\n .command(\n 'snippet FILE',\n 'Translate a single snippet',\n (command) =>\n command\n .positional('FILE', {\n type: 'string',\n describe: 'The file to translate (leave out for stdin)',\n })\n .option('language', {\n type: 'string',\n describe: 'Language ID to transliterate to',\n choices: Array.from(new Set(Object.values(TargetLanguage))),\n })\n .option('python', {\n alias: 'p',\n boolean: true,\n deprecated: true,\n description: 'Translate snippets to Python. Use --language python instead.',\n }),\n wrapHandler(async (args) => {\n const result = translateTypeScript(await makeFileSource(args.FILE ?? '-', 'stdin.ts'), makeVisitor(args));\n handleSingleResult(result);\n }),\n )\n .command(\n 'markdown FILE',\n 'Translate a MarkDown file',\n (command) =>\n command\n .positional('FILE', {\n type: 'string',\n describe: 'The file to translate (leave out for stdin)',\n })\n .option('language', {\n type: 'string',\n describe: 'Language ID to transliterate to',\n choices: Array.from(new Set(Object.values(TargetLanguage))),\n })\n .option('python', {\n alias: 'p',\n boolean: true,\n deprecated: true,\n description: 'Translate snippets to Python. Use --language python instead.',\n }),\n wrapHandler(async (args) => {\n const result = translateMarkdown(await makeFileSource(args.FILE ?? '-', 'stdin.md'), makeVisitor(args));\n handleSingleResult(result);\n }),\n )\n .command(\n 'infuse [ASSEMBLY..]',\n '(EXPERIMENTAL) mutates one or more assemblies by adding documentation examples to top-level types',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to mutate',\n })\n .option('log-file', {\n alias: 'l',\n type: 'string',\n describe: 'Output file to store logging results. Ignored if -log is not true',\n default: DEFAULT_INFUSION_RESULTS_NAME,\n })\n .option('cache-from', {\n alias: 'C',\n type: 'string',\n // eslint-disable-next-line prettier/prettier\n describe:\n 'Reuse translations from the given tablet file if the snippet and type definitions did not change',\n requiresArg: true,\n default: undefined,\n })\n .option('cache-to', {\n alias: 'o',\n type: 'string',\n describe: 'Append all translated snippets to the given tablet file',\n requiresArg: true,\n default: undefined,\n })\n .option('cache', {\n alias: 'k',\n type: 'string',\n describe: 'Alias for --cache-from and --cache-to together',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache', 'cache-from')\n .conflicts('cache', 'cache-to'),\n wrapHandler(async (args) => {\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n const absCacheFrom = fmap(args.cache ?? args['cache-from'], path.resolve);\n const absCacheTo = fmap(args.cache ?? args['cache-to'], path.resolve);\n const result = await infuse(absAssemblies, {\n logFile: args['log-file'],\n cacheToFile: absCacheTo,\n cacheFromFile: absCacheFrom,\n });\n\n let totalTypes = 0;\n let insertedExamples = 0;\n for (const [directory, map] of Object.entries(result.coverageResults)) {\n const commonName = directory.split('/').pop()!;\n const newCoverage = roundPercentage(map.typesWithInsertedExamples / map.types);\n process.stdout.write(\n `${commonName}: Added ${map.typesWithInsertedExamples} examples to ${map.types} types.\\n`,\n );\n process.stdout.write(`${commonName}: New coverage: ${newCoverage}%.\\n`);\n\n insertedExamples += map.typesWithInsertedExamples;\n totalTypes += map.types;\n }\n const newCoverage = roundPercentage(insertedExamples / totalTypes);\n process.stdout.write(`\\n\\nFinal Stats:\\nNew coverage: ${newCoverage}%.\\n`);\n }),\n )\n .command(\n ['extract [ASSEMBLY..]', '$0 [ASSEMBLY..]'],\n 'Extract code snippets from one or more assemblies into language tablets',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to extract from',\n })\n .option('output', {\n type: 'string',\n describe: 'Additional output file where to store translated samples (deprecated, alias for --cache-to)',\n requiresArg: true,\n default: undefined,\n })\n .option('compile', {\n alias: 'c',\n type: 'boolean',\n describe: 'Try compiling (on by default, use --no-compile to switch off)',\n default: true,\n })\n .option('directory', {\n alias: 'd',\n type: 'string',\n describe: 'Working directory (for require() etc)',\n })\n .option('include', {\n alias: 'i',\n type: 'string',\n array: true,\n describe: 'Extract only snippets with given ids',\n default: [],\n })\n .option('infuse', {\n type: 'boolean',\n describe: 'bundle this command with the infuse command',\n default: false,\n })\n .option('fail', {\n alias: 'f',\n type: 'boolean',\n describe: 'Fail if there are compilation errors',\n default: false,\n })\n .option('validate-assemblies', {\n type: 'boolean',\n describe: 'Whether to validate loaded assemblies or not (this can be slow)',\n default: false,\n })\n .option('cache-from', {\n alias: 'C',\n type: 'string',\n // eslint-disable-next-line prettier/prettier\n describe:\n 'Reuse translations from the given tablet file if the snippet and type definitions did not change',\n requiresArg: true,\n default: undefined,\n })\n .option('cache-to', {\n alias: 'o',\n type: 'string',\n describe: 'Append all translated snippets to the given tablet file',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache-to', 'output')\n .option('cache', {\n alias: 'k',\n type: 'string',\n describe: 'Alias for --cache-from and --cache-to together',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache', 'cache-from')\n .conflicts('cache', 'cache-to')\n .option('trim-cache', {\n alias: 'T',\n type: 'boolean',\n describe: 'Remove translations that are not referenced by any of the assemblies anymore from the cache',\n })\n .option('strict', {\n alias: 'S',\n type: 'boolean',\n describe:\n 'Require all code samples compile, and fail if one does not. Strict mode always enables --compile and --fail',\n default: false,\n })\n .options('loose', {\n alias: 'l',\n describe: 'Ignore missing fixtures and literate markdown files instead of failing',\n type: 'boolean',\n })\n .options('compress-tablet', {\n alias: 'z',\n type: 'boolean',\n describe: 'Compress the implicit tablet file',\n default: false,\n })\n .options('compress-cache', {\n type: 'boolean',\n describe: 'Compress the cache-to file',\n default: false,\n })\n .options('cleanup', {\n type: 'boolean',\n describe: 'Clean up temporary directories',\n default: true,\n })\n .conflicts('loose', 'strict')\n .conflicts('loose', 'fail'),\n wrapHandler(async (args) => {\n // `--strict` is short for `--compile --fail`, and we'll override those even if they're set to `false`, such as\n // using `--no-(compile|fail)`, because yargs does not quite give us a better option that does not hurt CX.\n if (args.strict) {\n args.compile = args.c = true;\n args.fail = args.f = true;\n }\n\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n\n const absCacheFrom = fmap(args.cache ?? args['cache-from'], path.resolve);\n const absCacheTo = fmap(args.cache ?? args['cache-to'] ?? args.output, path.resolve);\n\n const extractOptions: ExtractOptions = {\n compilationDirectory: args.directory,\n includeCompilerDiagnostics: !!args.compile,\n validateAssemblies: args['validate-assemblies'],\n only: args.include,\n cacheFromFile: absCacheFrom,\n cacheToFile: absCacheTo,\n trimCache: args['trim-cache'],\n loose: args.loose,\n compressTablet: args['compress-tablet'],\n compressCacheToFile: args['compress-cache'],\n cleanup: args.cleanup,\n };\n\n const result = args.infuse\n ? await extractAndInfuse(absAssemblies, extractOptions)\n : await extractSnippets(absAssemblies, extractOptions);\n\n handleDiagnostics(result.diagnostics, args.fail, result.tablet.count);\n }),\n )\n .command(\n 'transliterate [ASSEMBLY..]',\n '(EXPERIMENTAL) Transliterates the designated assemblies',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n required: true,\n describe: 'Assembly to transliterate',\n })\n .option('language', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Language ID to transliterate to',\n })\n .options('strict', {\n alias: 's',\n conflicts: 'loose',\n describe:\n 'Fail if an example that needs live transliteration fails to compile (which could cause incorrect transpilation results)',\n type: 'boolean',\n })\n .options('loose', {\n alias: 'l',\n conflicts: 'strict',\n describe: 'Ignore missing fixtures and literate markdown files instead of failing',\n type: 'boolean',\n })\n .option('tablet', {\n alias: 't',\n type: 'string',\n describe:\n 'Language tablet containing pre-translated code examples to use (these are generated by the `extract` command)',\n }),\n wrapHandler((args) => {\n const assemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((dir) =>\n path.resolve(process.cwd(), dir),\n );\n const languages =\n args.language.length > 0\n ? args.language\n .map((lang) => lang.toUpperCase())\n .map((lang) => {\n const target = Object.entries(TargetLanguage).find(([k]) => k === lang)?.[1];\n if (target == null) {\n throw new Error(\n `Unknown target language: ${lang}. Expected one of ${Object.keys(TargetLanguage).join(', ')}`,\n );\n }\n return target;\n })\n : Object.values(TargetLanguage);\n return transliterateAssembly(assemblies, languages, args);\n }),\n )\n .command(\n 'trim-cache <TABLET> [ASSEMBLY..]',\n 'Retain only those snippets in the cache which occur in one of the given assemblies',\n (command) =>\n command\n .positional('TABLET', {\n type: 'string',\n required: true,\n describe: 'Language tablet to trim',\n })\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to search',\n })\n .demandOption('TABLET'),\n wrapHandler(async (args) => {\n await trimCache({\n cacheFile: args.TABLET,\n assemblyLocations: args.ASSEMBLY,\n });\n }),\n )\n .command(\n 'coverage [ASSEMBLY..]',\n 'Check the translation coverage of implicit tablets for the given assemblies',\n (command) =>\n command.positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: ['.'],\n describe: 'Assembly or directory to search',\n }),\n wrapHandler(async (args) => {\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n await checkCoverage(absAssemblies);\n }),\n )\n .command(\n 'read <TABLET> [KEY] [LANGUAGE]',\n 'Display snippets in a language tablet file',\n (command) =>\n command\n .positional('TABLET', {\n type: 'string',\n required: true,\n describe: 'Language tablet to read',\n })\n .positional('KEY', {\n type: 'string',\n describe: 'Snippet key to read',\n })\n .positional('LANGUAGE', {\n type: 'string',\n describe: 'Language ID to read',\n })\n .demandOption('TABLET'),\n wrapHandler(async (args) => {\n await readTablet(args.TABLET, args.KEY, args.LANGUAGE);\n }),\n )\n .command(\n 'configure-strict [PACKAGE]',\n \"Enables strict mode for a package's assembly\",\n (command) =>\n command.positional('PACKAGE', {\n type: 'string',\n describe: 'The path to the package to configure',\n required: false,\n default: '.',\n normalize: true,\n }),\n wrapHandler(async (args) => {\n const packageJsonPath = (await fs.stat(args.PACKAGE)).isDirectory()\n ? path.join(args.PACKAGE, 'package.json')\n : args.PACKAGE;\n const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));\n if (packageJson.jsii == null) {\n console.error(\n `The package in ${args.PACKAGE} does not have a jsii configuration! You can set it up using jsii-config.`,\n );\n process.exitCode = 1;\n return Promise.resolve();\n }\n if (packageJson.jsii.metadata?.jsii?.rosetta?.strict) {\n // Nothing to do - it's already configured, so we assert idempotent success!\n return Promise.resolve();\n }\n const md = (packageJson.jsii.metadata = packageJson.jsii.metadata ?? {});\n const mdJsii = (md.jsii = md.jsii ?? {});\n const mdRosetta = (mdJsii.rosetta = mdJsii.rosetta ?? {});\n mdRosetta.strict = true;\n\n return fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));\n }),\n )\n .demandCommand()\n .help()\n .strict() // Error on wrong command\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n .version(require('../package.json').version)\n .showHelpOnFail(false).argv;\n\n // Evaluating .argv triggers the parsing but the command gets implicitly executed,\n // so we don't need the output.\n Array.isArray(argv);\n}\n\n/**\n * Wrap a command's handler with standard pre- and post-work\n */\nfunction wrapHandler<A extends { verbose?: number }, R>(handler: (x: A) => Promise<R>) {\n return (argv: A) => {\n logging.configure({ level: argv.verbose !== undefined ? argv.verbose : 0 });\n handler(argv).catch((e) => {\n logging.error(e.message);\n logging.error(e.stack);\n process.exitCode = 1;\n });\n };\n}\n\nfunction makeVisitor(args: { python?: boolean; language?: string }) {\n if (args.python != null && args.language == null) {\n args.language = 'python';\n }\n return getVisitorFromLanguage(args.language);\n}\n\nasync function makeFileSource(fileName: string, stdinName: string): Promise<File> {\n if (fileName === '-') {\n return {\n contents: await readStdin(),\n fileName: stdinName,\n };\n }\n return {\n contents: await fs.readFile(fileName, { encoding: 'utf-8' }),\n fileName: fileName,\n };\n}\n\nasync function readStdin(): Promise<string> {\n process.stdin.setEncoding('utf8');\n\n const parts: Buffer[] = [];\n\n return new Promise((resolve, reject) => {\n process.stdin.on('readable', () => {\n const chunk = process.stdin.read();\n if (chunk !== null) {\n parts.push(Buffer.from(chunk));\n }\n });\n\n process.stdin.on('error', reject);\n process.stdin.on('end', () => resolve(Buffer.concat(parts).toString('utf-8')));\n });\n}\n\nfunction handleSingleResult(result: TranslateResult) {\n process.stdout.write(`${result.translation}\\n`);\n\n // For a single result, we always request implicit failure.\n handleDiagnostics(result.diagnostics, 'implicit');\n}\n\n/**\n * Print diagnostics and set exit code\n *\n * 'fail' is whether or not the user passed '--fail' for commands that accept\n * it, or 'implicit' for commands that should always fail. 'implicit' will be\n * treated as 'fail=true, but will not print to the user that the '--fail' is\n * set (because for this particular command that switch does not exist and so it\n * would be confusing).\n */\nfunction handleDiagnostics(diagnostics: readonly RosettaDiagnostic[], fail: boolean | 'implicit', snippetCount = 1) {\n if (fail !== false) {\n // Fail on any diagnostic\n if (diagnostics.length > 0) {\n printDiagnostics(diagnostics, process.stderr, process.stderr.isTTY);\n logging.error(\n [\n `${diagnostics.length} diagnostics encountered in ${snippetCount} snippets`,\n ...(fail === true ? [\"(running with '--fail')\"] : []),\n ].join(' '),\n );\n process.exitCode = 1;\n }\n\n return;\n }\n\n // Otherwise fail only on strict diagnostics. If we have strict diagnostics, print only those\n // (so it's very clear what is failing the build), otherwise print everything.\n const strictDiagnostics = diagnostics.filter((diag) => diag.isFromStrictAssembly);\n if (strictDiagnostics.length > 0) {\n printDiagnostics(strictDiagnostics, process.stderr, process.stderr.isTTY);\n const remaining = diagnostics.length - strictDiagnostics.length;\n logging.warn(\n [\n `${strictDiagnostics.length} diagnostics from assemblies with 'strict' mode on`,\n ...(remaining > 0 ? [`(and ${remaining} more non-strict diagnostics)`] : []),\n ].join(' '),\n );\n process.exitCode = 1;\n return;\n }\n\n if (diagnostics.length > 0) {\n printDiagnostics(diagnostics, process.stderr, process.stderr.isTTY);\n logging.warn(`${diagnostics.length} diagnostics encountered in ${snippetCount} snippets`);\n }\n}\n\n/**\n * Rounds a decimal number to two decimal points.\n * The function is useful for fractions that need to be outputted as percentages.\n */\nfunction roundPercentage(num: number): number {\n return Math.round(10000 * num) / 100;\n}\n\nmain().catch((cause) => {\n console.error(cause);\n process.exitCode = -1;\n});\n"]}
|
@@ -23,16 +23,16 @@ export declare class CSharpXmlCommentRenderer extends MarkdownRenderer {
|
|
23
23
|
/**
|
24
24
|
* HTML needs to be converted to XML
|
25
25
|
*
|
26
|
-
* If we don't do this, the parser will reject the whole XML block once it
|
26
|
+
* If we don't do this, the parser will reject the whole XML block once it sees an unclosed
|
27
27
|
* <img> tag.
|
28
28
|
*/
|
29
|
-
html_inline(node: cm.Node, _context: RendererContext):
|
29
|
+
html_inline(node: cm.Node, _context: RendererContext): string;
|
30
30
|
/**
|
31
31
|
* HTML needs to be converted to XML
|
32
32
|
*
|
33
|
-
* If we don't do this, the parser will reject the whole XML block once it
|
33
|
+
* If we don't do this, the parser will reject the whole XML block once it sees an unclosed
|
34
34
|
* <img> tag.
|
35
35
|
*/
|
36
|
-
html_block(node: cm.Node, context: RendererContext):
|
36
|
+
html_block(node: cm.Node, context: RendererContext): string;
|
37
37
|
}
|
38
38
|
//# sourceMappingURL=xml-comment-renderer.d.ts.map
|
@@ -1,13 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.CSharpXmlCommentRenderer = void 0;
|
4
|
+
const xmldom_1 = require("@xmldom/xmldom");
|
4
5
|
const escapes_1 = require("./escapes");
|
5
6
|
const markdown_1 = require("./markdown");
|
6
7
|
const markdown_renderer_1 = require("./markdown-renderer");
|
7
8
|
const ESCAPE = (0, escapes_1.makeXmlEscaper)();
|
8
|
-
// The types for 'xmldom' are not complete.
|
9
|
-
/* eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports */
|
10
|
-
const { DOMParser, XMLSerializer } = require('@xmldom/xmldom');
|
11
9
|
/**
|
12
10
|
* A renderer that will render a CommonMark tree to .NET XML comments
|
13
11
|
*
|
@@ -55,14 +53,21 @@ class CSharpXmlCommentRenderer extends markdown_renderer_1.MarkdownRenderer {
|
|
55
53
|
/**
|
56
54
|
* HTML needs to be converted to XML
|
57
55
|
*
|
58
|
-
* If we don't do this, the parser will reject the whole XML block once it
|
56
|
+
* If we don't do this, the parser will reject the whole XML block once it sees an unclosed
|
59
57
|
* <img> tag.
|
60
58
|
*/
|
61
59
|
html_inline(node, _context) {
|
62
60
|
const html = node.literal ?? '';
|
63
61
|
try {
|
64
|
-
|
65
|
-
|
62
|
+
// An html string fails to parse unless it is wrapped into a document root element
|
63
|
+
// We fake this, by wrapping the inline html into an artificial root element,
|
64
|
+
// and for rendering only selecting its children.
|
65
|
+
const dom = new xmldom_1.DOMParser().parseFromString(`<jsii-root>${html}</jsii-root>`, xmldom_1.MIME_TYPE.HTML);
|
66
|
+
const fragment = dom.createDocumentFragment();
|
67
|
+
for (const child of Array.from(dom.firstChild?.childNodes ?? [])) {
|
68
|
+
fragment.appendChild(child);
|
69
|
+
}
|
70
|
+
return new xmldom_1.XMLSerializer().serializeToString(fragment);
|
66
71
|
}
|
67
72
|
catch {
|
68
73
|
// Could not parse - we'll escape unsafe XML entities here...
|
@@ -83,7 +88,7 @@ class CSharpXmlCommentRenderer extends markdown_renderer_1.MarkdownRenderer {
|
|
83
88
|
/**
|
84
89
|
* HTML needs to be converted to XML
|
85
90
|
*
|
86
|
-
* If we don't do this, the parser will reject the whole XML block once it
|
91
|
+
* If we don't do this, the parser will reject the whole XML block once it sees an unclosed
|
87
92
|
* <img> tag.
|
88
93
|
*/
|
89
94
|
html_block(node, context) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"xml-comment-renderer.js","sourceRoot":"","sources":["../../src/markdown/xml-comment-renderer.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"xml-comment-renderer.js","sourceRoot":"","sources":["../../src/markdown/xml-comment-renderer.ts"],"names":[],"mappings":";;;AAAA,2CAAqE;AAGrE,uCAA2C;AAC3C,yCAA0D;AAC1D,2DAAwE;AAExE,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;AAEhC;;;;;GAKG;AACH,MAAa,wBAAyB,SAAQ,oCAAgB;IAC5C,WAAW,CAAC,KAAc,EAAE,OAAwB;QAClE,OAAO,IAAA,wBAAI,EAAC,IAAA,sBAAW,EAAC,MAAM,EAAE,IAAA,6BAAS,EAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC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AM,CAAC;oBAChB,KAAK,GAAG;wBACN,OAAO,MAAM,CAAC;oBAChB;wBACE,OAAO,IAAI,CAAC;gBAChB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACa,UAAU,CAAC,IAAa,EAAE,OAAwB;QAChE,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;CACF;AA/FD,4DA+FC","sourcesContent":["import { DOMParser, MIME_TYPE, XMLSerializer } from '@xmldom/xmldom';\nimport * as cm from 'commonmark';\n\nimport { makeXmlEscaper } from './escapes';\nimport { prefixLines, RendererContext } from './markdown';\nimport { MarkdownRenderer, para, stripPara } from './markdown-renderer';\n\nconst ESCAPE = makeXmlEscaper();\n\n/**\n * A renderer that will render a CommonMark tree to .NET XML comments\n *\n * Mostly concerns itself with code annotations and escaping; tags that the\n * XML formatter doesn't have equivalents for will be rendered back to MarkDown.\n */\nexport class CSharpXmlCommentRenderer extends MarkdownRenderer {\n public override block_quote(_node: cm.Node, context: RendererContext) {\n return para(prefixLines(' ', stripPara(context.content())));\n }\n\n public override code(node: cm.Node, _context: RendererContext) {\n return `<c>${ESCAPE.text(node.literal)}</c>`;\n }\n\n public override code_block(node: cm.Node, _context: RendererContext) {\n return para(`<code><![CDATA[\\n${node.literal}]]></code>`);\n }\n\n public override text(node: cm.Node, _context: RendererContext) {\n return ESCAPE.text(node.literal) ?? '';\n }\n\n public override link(node: cm.Node, context: RendererContext) {\n return `<a href=\"${ESCAPE.attribute(node.destination) ?? ''}\">${context.content()}</a>`;\n }\n\n public override image(node: cm.Node, context: RendererContext) {\n return `<img alt=\"${ESCAPE.text2attr(context.content())}\" src=\"${ESCAPE.attribute(node.destination) ?? ''}\" />`;\n }\n\n public override emph(_node: cm.Node, context: RendererContext) {\n return `<em>${context.content()}</em>`;\n }\n\n public override strong(_node: cm.Node, context: RendererContext) {\n return `<strong>${context.content()}</strong>`;\n }\n\n public override heading(node: cm.Node, context: RendererContext) {\n return para(`<h${node.level}>${context.content()}</h${node.level}>`);\n }\n\n public override list(node: cm.Node, context: RendererContext) {\n const listType = node.listType === 'bullet' ? 'bullet' : 'number';\n\n return para(`<list type=\"${listType}\">\\n${context.content()}</list>`);\n }\n\n public override item(_node: cm.Node, context: RendererContext) {\n return `<description>${stripPara(context.content())}</description>\\n`;\n }\n\n public override thematic_break(_node: cm.Node, _context: RendererContext) {\n return para('<hr />');\n }\n\n /**\n * HTML needs to be converted to XML\n *\n * If we don't do this, the parser will reject the whole XML block once it sees an unclosed\n * <img> tag.\n */\n public override html_inline(node: cm.Node, _context: RendererContext) {\n const html = node.literal ?? '';\n try {\n // An html string fails to parse unless it is wrapped into a document root element\n // We fake this, by wrapping the inline html into an artificial root element,\n // and for rendering only selecting its children.\n const dom = new DOMParser().parseFromString(`<jsii-root>${html}</jsii-root>`, MIME_TYPE.HTML);\n const fragment = dom.createDocumentFragment();\n for (const child of Array.from(dom.firstChild?.childNodes ?? [])) {\n fragment.appendChild(child);\n }\n return new XMLSerializer().serializeToString(fragment);\n } catch {\n // Could not parse - we'll escape unsafe XML entities here...\n return html.replace(/[<>&]/g, (char: string) => {\n switch (char) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n default:\n return char;\n }\n });\n }\n }\n\n /**\n * HTML needs to be converted to XML\n *\n * If we don't do this, the parser will reject the whole XML block once it sees an unclosed\n * <img> tag.\n */\n public override html_block(node: cm.Node, context: RendererContext) {\n return this.html_inline(node, context);\n }\n}\n"]}
|
package/package.json
CHANGED
@@ -59,15 +59,15 @@
|
|
59
59
|
"memfs": "^4.11.1",
|
60
60
|
"mock-fs": "^5.2.0",
|
61
61
|
"prettier": "^2.8.8",
|
62
|
-
"projen": "^0.86.
|
62
|
+
"projen": "^0.86.6",
|
63
63
|
"tar": "^6.2.1",
|
64
64
|
"ts-jest": "^29.2.5",
|
65
65
|
"ts-node": "^10.9.2"
|
66
66
|
},
|
67
67
|
"dependencies": {
|
68
|
-
"@jsii/check-node": "1.103.
|
69
|
-
"@jsii/spec": "^1.103.
|
70
|
-
"@xmldom/xmldom": "^0.
|
68
|
+
"@jsii/check-node": "1.103.1",
|
69
|
+
"@jsii/spec": "^1.103.1",
|
70
|
+
"@xmldom/xmldom": "^0.9.0",
|
71
71
|
"chalk": "^4",
|
72
72
|
"commonmark": "^0.31.1",
|
73
73
|
"fast-glob": "^3.3.2",
|
@@ -88,7 +88,7 @@
|
|
88
88
|
"publishConfig": {
|
89
89
|
"access": "public"
|
90
90
|
},
|
91
|
-
"version": "5.5.
|
91
|
+
"version": "5.5.5-dev.0",
|
92
92
|
"types": "lib/index.d.ts",
|
93
93
|
"exports": {
|
94
94
|
".": "./lib/index.js",
|