diff --git a/packages/jsii-calc/lib/documented.ts b/packages/jsii-calc/lib/documented.ts
index c4b6d6b0c8..d88340822c 100644
--- a/packages/jsii-calc/lib/documented.ts
+++ b/packages/jsii-calc/lib/documented.ts
@@ -12,11 +12,11 @@ export class DocumentedClass {
/**
* Greet the indicated person.
*
- * This will print out a friendly greeting intended for
- * the indicated person.
+ * This will print out a friendly greeting intended for the indicated person.
*
* @param greetee The person to be greeted.
- * @returns A number that everyone knows very well
+ * @returns A number that everyone knows very well and represents the answer
+ * to the ultimate question
*/
public greet(greetee: Greetee = {}): number {
process.stdout.write(`Hello, ${greetee.name ?? 'world'}\n`);
@@ -48,7 +48,8 @@ export interface Greetee {
/**
* Old class
*
- * @deprecated Use the new class
+ * @deprecated Use the new class or the old class whatever you want because
+ * whatever you like is always the best
*/
export class Old {
/**
diff --git a/packages/jsii-pacmak/lib/targets/go/documentation.ts b/packages/jsii-pacmak/lib/targets/go/documentation.ts
index 3b411bcbae..f5c4b49697 100644
--- a/packages/jsii-pacmak/lib/targets/go/documentation.ts
+++ b/packages/jsii-pacmak/lib/targets/go/documentation.ts
@@ -19,27 +19,24 @@ export class Documentation {
*/
public emit(docs: Docs): void {
if (docs.toString() !== '') {
- const lines = docs.toString().split('\n');
- for (const line of lines) {
- this.code.line(`// ${line}`);
- }
+ this.emitComment(docs.toString());
}
if (docs.returns !== '') {
- this.code.line(`//`);
- this.code.line(`// Returns: ${docs.returns}`);
+ this.emitComment();
+ this.emitComment(`Returns: ${docs.returns}`);
}
if (docs.example !== '') {
- this.code.line(`//`);
+ this.emitComment();
// TODO: Translate code examples to Go with Rosetta (not implemented there yet)
- this.code.line('// TODO: EXAMPLE');
- this.code.line(`//`);
+ this.emitComment('TODO: EXAMPLE');
+ this.emitComment();
}
if (docs.link !== '') {
- this.code.line(`// See: ${docs.link}`);
- this.code.line(`//`);
+ this.emitComment(`See: ${docs.link}`);
+ this.emitComment();
}
this.emitStability(docs);
@@ -49,13 +46,19 @@ export class Documentation {
const stability = docs.stability;
if (stability && this.shouldMentionStability(docs)) {
if (docs.deprecated) {
- this.code.line(`// Deprecated: ${docs.deprecationReason}`);
+ this.emitComment(`Deprecated: ${docs.deprecationReason}`);
} else {
- this.code.line(`// ${this.code.toPascalCase(stability)}.`);
+ this.emitComment(`${this.code.toPascalCase(stability)}.`);
}
}
}
+ private emitComment(text = '') {
+ for (const line of text.split('\n')) {
+ this.code.line(`// ${line}`);
+ }
+ }
+
private shouldMentionStability(docs: Docs): boolean {
const s = docs.stability;
// Don't render "stable" or "external", those are both stable by implication
diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap
index 319f66a73f..1fc0591dc3 100644
--- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap
+++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap
@@ -4891,10 +4891,10 @@ namespace Amazon.JSII.Tests.CalculatorNamespace
/// Greet the indicated person.
/// The person to be greeted.
- /// A number that everyone knows very well
+ /// A number that everyone knows very well and represents the answer
+ /// to the ultimate question
///
- /// This will print out a friendly greeting intended for
- /// the indicated person.
+ /// This will print out a friendly greeting intended for the indicated person.
///
[JsiiMethod(name: "greet", returnsJson: "{\\"type\\":{\\"primitive\\":\\"number\\"}}", parametersJson: "[{\\"docs\\":{\\"summary\\":\\"The person to be greeted.\\"},\\"name\\":\\"greetee\\",\\"optional\\":true,\\"type\\":{\\"fqn\\":\\"jsii-calc.Greetee\\"}}]")]
public virtual double Greet(Amazon.JSII.Tests.CalculatorNamespace.IGreetee? greetee = null)
@@ -11339,7 +11339,7 @@ namespace Amazon.JSII.Tests.CalculatorNamespace
/// Stability: Deprecated
///
[JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Old), fullyQualifiedName: "jsii-calc.Old")]
- [System.Obsolete("Use the new class")]
+ [System.Obsolete("Use the new class or the old class whatever you want because whatever you like is always the best")]
public class Old : DeputyBase
{
public Old(): base(new DeputyProps(System.Array.Empty