Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jsii-pacmak): comment lines should not contain comment ending #4193

Merged
merged 7 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/jsii-calc/bin/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const runCommand = async () => {

if (args.includes('delay')) {
for (let i = 1; i <= 5; i++) {
console.log('sleeping 1s', i);
console.log(`sleeping 1s ${i}`);
// eslint-disable-next-line no-await-in-loop
await delay(1000);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/jsii-calc/lib/documented.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export class DocumentedClass {
public hola(): void {
process.stdout.write('bonjour');
}

/**
* Some comments have an escaped star backslash in them, ending the comment if left unescaped.
For example: 'projects/*\/global/networks/network-1'.
*/
public moin(): void {
process.stdout.write('servus');
}
}

/**
Expand Down
30 changes: 21 additions & 9 deletions packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -5074,6 +5074,18 @@
"line": 38
},
"name": "hola"
},
{
"docs": {
"remarks": "For example: 'projects/*\\/global/networks/network-1'.",
"stability": "stable",
"summary": "Some comments have an escaped star backslash in them, ending the comment if left unescaped."
},
"locationInModule": {
"filename": "lib/documented.ts",
"line": 46
},
"name": "moin"
}
],
"name": "DocumentedClass",
Expand Down Expand Up @@ -5143,7 +5155,7 @@
"kind": "interface",
"locationInModule": {
"filename": "lib/documented.ts",
"line": 74
"line": 82
},
"name": "DontUseMe",
"properties": [
Expand All @@ -5157,7 +5169,7 @@
"immutable": true,
"locationInModule": {
"filename": "lib/documented.ts",
"line": 80
"line": 88
},
"name": "dontSetMe",
"optional": true,
Expand Down Expand Up @@ -6217,7 +6229,7 @@
"kind": "interface",
"locationInModule": {
"filename": "lib/documented.ts",
"line": 46
"line": 54
},
"name": "Greetee",
"properties": [
Expand All @@ -6231,7 +6243,7 @@
"immutable": true,
"locationInModule": {
"filename": "lib/documented.ts",
"line": 52
"line": 60
},
"name": "name",
"optional": true,
Expand Down Expand Up @@ -11140,7 +11152,7 @@
"kind": "class",
"locationInModule": {
"filename": "lib/documented.ts",
"line": 61
"line": 69
},
"methods": [
{
Expand All @@ -11150,7 +11162,7 @@
},
"locationInModule": {
"filename": "lib/documented.ts",
"line": 65
"line": 73
},
"name": "doAThing"
}
Expand Down Expand Up @@ -16062,7 +16074,7 @@
"kind": "class",
"locationInModule": {
"filename": "lib/documented.ts",
"line": 88
"line": 96
},
"name": "WeirdDocs",
"properties": [
Expand All @@ -16074,7 +16086,7 @@
},
"locationInModule": {
"filename": "lib/documented.ts",
"line": 94
"line": 102
},
"name": "dontReadMe",
"optional": true,
Expand Down Expand Up @@ -18984,5 +18996,5 @@
}
},
"version": "3.20.120",
"fingerprint": "P8PbBkSVSEXGN8+6wTvu1VFR499+MbQMrLXt+jdZgBo="
"fingerprint": "qoT4xo5rhn5qx9EIbP7DMeSFV9/lr8qwScm8SvGRZE4="
}
7 changes: 6 additions & 1 deletion packages/jsii-pacmak/lib/targets/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2808,7 +2808,7 @@ class JavaGenerator extends Generator {

this.code.line('/**');
for (const line of lines) {
this.code.line(` * ${line}`);
this.code.line(` * ${escapeEndingComment(line)}`);
}
this.code.line(' */');
}
Expand Down Expand Up @@ -3677,3 +3677,8 @@ function myMarkDownToJavaDoc(source: string) {
function stripNewLines(x: string) {
return x.replace(/\n/g, '');
}

// Replace */ with *\/ to avoid closing the comment block
function escapeEndingComment(x: string) {
return x.replace(/\*\//g, '*\\/');
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading