Skip to content

Commit

Permalink
fix(go): malformed multiline docstrings in constructors (#2639)
Browse files Browse the repository at this point in the history
Use `documenter.emit()`, which takes care of multi-line docstrings instead of just emitting the text.

This uncovered missing maturity information on ctors as well.

Fixes #2638
  • Loading branch information
Elad Ben-Israel authored Mar 3, 2021
1 parent cd8957e commit 72f25af
Show file tree
Hide file tree
Showing 10 changed files with 338 additions and 7 deletions.
19 changes: 19 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2925,3 +2925,22 @@ export class TestStructWithEnum {
};
}
}

/**
* Docstrings with period
* @see https://github.com/aws/jsii/issues/2638
*/
export class Issue2638 {
/**
* First sentence. Second sentence. Third sentence.
*/
public constructor() {
return;
}
}

export class Issue2638B {
public constructor() {
return; // no docs
}
}
50 changes: 49 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -7219,6 +7219,54 @@
],
"name": "Isomorphism"
},
"jsii-calc.Issue2638": {
"assembly": "jsii-calc",
"docs": {
"see": "https://github.com/aws/jsii/issues/2638",
"stability": "stable",
"summary": "Docstrings with period."
},
"fqn": "jsii-calc.Issue2638",
"initializer": {
"docs": {
"remarks": "Second sentence. Third sentence.",
"stability": "stable",
"summary": "First sentence."
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2937
}
},
"kind": "class",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2933
},
"name": "Issue2638"
},
"jsii-calc.Issue2638B": {
"assembly": "jsii-calc",
"docs": {
"stability": "stable"
},
"fqn": "jsii-calc.Issue2638B",
"initializer": {
"docs": {
"stability": "stable"
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2943
}
},
"kind": "class",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2942
},
"name": "Issue2638B"
},
"jsii-calc.JSII417Derived": {
"assembly": "jsii-calc",
"base": "jsii-calc.JSII417PublicBaseOfBase",
Expand Down Expand Up @@ -14756,5 +14804,5 @@
}
},
"version": "3.20.120",
"fingerprint": "GfueSeyZdyEIZp4V4lbddw+TnoCel74KSDMPxp2phmw="
"fingerprint": "WnxyYDpN1opFu5dYMKwKeo5wN3IkNe9gnovO0ro7i2U="
}
7 changes: 1 addition & 6 deletions packages/jsii-pacmak/lib/targets/go/types/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,7 @@ export class GoClassConstructor {
? ''
: this.parameters.map((p) => p.toString()).join(', ');

let docstring = '';
if (this.type.docs.summary) {
docstring = this.type.docs.toString();
code.line(`// ${docstring}`);
}

context.documenter.emit(this.type.docs);
code.openBlock(`func ${constr}(${paramString}) ${this.parent.name}`);

this.constructorRuntimeCall.emit(code);
Expand Down

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

0 comments on commit 72f25af

Please sign in to comment.