Skip to content

Commit

Permalink
feat(docs): add variadic params to jsii docgen (#4007)
Browse files Browse the repository at this point in the history
closes [#3781](#3781)
<img width="951" alt="image" src="https://github.com/winglang/wing/assets/39455181/bfecb78b-812e-4483-aac6-cc5f83103f3e">

## Checklist

- [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [x] Description explains motivation and solution
- [ ] Tests added (always)
- [x] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
tsuf239 authored Sep 6, 2023
1 parent f1446e7 commit 52b44ca
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 22 deletions.
5 changes: 5 additions & 0 deletions apps/jsii-docgen/src/docgen/transpile/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ export interface TranspiledParameter {
* supports that.
*/
readonly declaration: string;

/**
* Is the parameter variadic
*/
readonly variadic?: boolean;
}

/**
Expand Down
10 changes: 9 additions & 1 deletion apps/jsii-docgen/src/docgen/transpile/wing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export class WingTranspile extends transpile.TranspileBase {
parentType: this.type(parameter.parentType),
typeReference: typeRef,
optional: parameter.optional,
variadic: parameter.spec.variadic,
declaration: this.formatProperty(name, typeRef),
};
}
Expand Down Expand Up @@ -280,7 +281,14 @@ export class WingTranspile extends transpile.TranspileBase {
if (tf === "Inflight") {
tf = "~Inflight";
}
return `${transpiled.name}${transpiled.optional ? "?" : ""}: ${tf}`;
if (transpiled.variadic) {
tf = `Array<${tf}>`;
}
const name = transpiled.variadic
? `...${transpiled.name}`
: transpiled.name;

return `${name}${transpiled.optional ? "?" : ""}: ${tf}`;
}

private formatProperty(
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.

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

2 changes: 1 addition & 1 deletion docs/docs/04-standard-library/01-cloud/queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Purge all of the messages in the queue.
##### `push` <a name="push" id="@winglang/sdk.cloud.IQueueClient.push"></a>

```wing
inflight push(messages: str): void
inflight push(...messages: Array<str>): void
```

Push one or more messages to the queue.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/04-standard-library/02-std/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,7 @@ metadata describing how one construct is related to another construct.
##### `addDependency` <a name="addDependency" id="@winglang/sdk.std.Node.addDependency"></a>

```wing
addDependency(deps: IDependable): void
addDependency(...deps: Array<IDependable>): void
```

Add an ordering dependency on another construct.
Expand Down
2 changes: 1 addition & 1 deletion libs/wingsdk/.projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const UNDOCUMENTED_CLOUD_FILES = ["index", "test-runner"];
const cloudFiles = readdirSync("./src/cloud");

const cloudResources: Set<string> = new Set(
cloudFiles.map((filename) => filename.split(".").slice(0, -1).join("."))
cloudFiles.map((filename) => filename.split(".")[0])
);

UNDOCUMENTED_CLOUD_FILES.forEach((file) => cloudResources.delete(file));
Expand Down

0 comments on commit 52b44ca

Please sign in to comment.