Skip to content

Commit

Permalink
docs(csharp): events convention based naming fix for csharp (#5238)
Browse files Browse the repository at this point in the history
* docs(gen): Updating events names to camelCase.
* docs(gen): updating generator to match new assumption for event names
* docs(gen): renaming references to events
  • Loading branch information
avodovnik committed Feb 4, 2021
1 parent cf96b15 commit ff06399
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions docs/src/api/class-chromiumbrowsercontext.md
Expand Up @@ -16,7 +16,7 @@ background_page = await context.wait_for_event("backgroundpage")
background_page = context.wait_for_event("backgroundpage")
```

## event: ChromiumBrowserContext.backgroundpage
## event: ChromiumBrowserContext.backgroundPage
- type: <[Page]>

Emitted when new background page is created in the context.
Expand All @@ -25,7 +25,7 @@ Emitted when new background page is created in the context.
Only works with persistent context.
:::

## event: ChromiumBrowserContext.serviceworker
## event: ChromiumBrowserContext.serviceWorker
- type: <[Worker]>

Emitted when new service worker is created in the context.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/api/class-filechooser.md
@@ -1,6 +1,6 @@
# class: FileChooser

[FileChooser] objects are dispatched by the page in the [`event: Page.filechooser`] event.
[FileChooser] objects are dispatched by the page in the [`event: Page.fileChooser`] event.

```js
const [fileChooser] = await Promise.all([
Expand Down
6 changes: 3 additions & 3 deletions docs/src/api/class-frame.md
Expand Up @@ -4,10 +4,10 @@ At every point of time, page exposes its current frame tree via the [`method: Pa
[`method: Frame.childFrames`] methods.

[Frame] object's lifecycle is controlled by three events, dispatched on the page object:
* [`event: Page.frameattached`] - fired when the frame gets attached to the page. A Frame can be attached to the page
* [`event: Page.frameAttached`] - fired when the frame gets attached to the page. A Frame can be attached to the page
only once.
* [`event: Page.framenavigated`] - fired when the frame commits navigation to a different URL.
* [`event: Page.framedetached`] - fired when the frame gets detached from the page. A Frame can be detached from the
* [`event: Page.frameNavigated`] - fired when the frame commits navigation to a different URL.
* [`event: Page.frameDetached`] - fired when the frame gets detached from the page. A Frame can be detached from the
page only once.

An example of dumping frame tree:
Expand Down
20 changes: 10 additions & 10 deletions docs/src/api/class-page.md
Expand Up @@ -177,7 +177,7 @@ Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` o
When no [`event: Page.dialog`] listeners are present, all dialogs are automatically dismissed.
:::

## event: Page.domcontentloaded
## event: Page.DOMContentLoaded
- type: <[Page]>

Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded)
Expand All @@ -195,7 +195,7 @@ downloaded content. If [`option: acceptDownloads`] is not set, download events a
not performed and user has no access to the downloaded files.
:::

## event: Page.filechooser
## event: Page.fileChooser
- type: <[FileChooser]>

Emitted when a file chooser is supposed to appear, such as after clicking the `<input type=file>`. Playwright can
Expand All @@ -211,17 +211,17 @@ page.on('filechooser', async (fileChooser) => {
page.on("filechooser", lambda file_chooser: file_chooser.set_files("/tmp/myfile.pdf"))
```

## event: Page.frameattached
## event: Page.frameAttached
- type: <[Frame]>

Emitted when a frame is attached.

## event: Page.framedetached
## event: Page.frameDetached
- type: <[Frame]>

Emitted when a frame is detached.

## event: Page.framenavigated
## event: Page.frameNavigated
- type: <[Frame]>

Emitted when a frame is navigated to a new url.
Expand All @@ -231,7 +231,7 @@ Emitted when a frame is navigated to a new url.

Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched.

## event: Page.pageerror
## event: Page.pageError
- type: <[Error]>

Emitted when an uncaught exception happens within the page.
Expand Down Expand Up @@ -279,17 +279,17 @@ cases).
Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see
[`method: Page.route`] or [`method: BrowserContext.route`].

## event: Page.requestfailed
## event: Page.requestFailed
- type: <[Request]>

Emitted when a request fails, for example by timing out.

:::note
HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete
with [`event: Page.requestfinished`] event and not with [`event: Page.requestfailed`].
with [`event: Page.requestFinished`] event and not with [`event: Page.requestFailed`].
:::

## event: Page.requestfinished
## event: Page.requestFinished
- type: <[Request]>

Emitted when a request finishes successfully after downloading the response body. For a successful response, the
Expand All @@ -301,7 +301,7 @@ sequence of events is `request`, `response` and `requestfinished`.
Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events
is `request`, `response` and `requestfinished`.

## event: Page.websocket
## event: Page.webSocket
- type: <[WebSocket]>

Emitted when <[WebSocket]> request is sent.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/api/class-request.md
Expand Up @@ -3,10 +3,10 @@
Whenever the page sends a request for a network resource the following sequence of events are emitted by [Page]:
* [`event: Page.request`] emitted when the request is issued by the page.
* [`event: Page.response`] emitted when/if the response status and headers are received for the request.
* [`event: Page.requestfinished`] emitted when the response body is downloaded and the request is complete.
* [`event: Page.requestFinished`] emitted when the response body is downloaded and the request is complete.

If request fails at some point, then instead of `'requestfinished'` event (and possibly instead of 'response' event),
the [`event: Page.requestfailed`] event is emitted.
the [`event: Page.requestFailed`] event is emitted.

:::note
HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete
Expand Down
6 changes: 3 additions & 3 deletions docs/src/api/class-websocket.md
Expand Up @@ -7,19 +7,19 @@ The [WebSocket] class represents websocket connections in the page.

Fired when the websocket closes.

## event: WebSocket.framereceived
## event: WebSocket.frameReceived
- type: <[Object]>
- `payload` <[string]|[Buffer]> frame payload

Fired when the websocket recieves a frame.

## event: WebSocket.framesent
## event: WebSocket.frameSent
- type: <[Object]>
- `payload` <[string]|[Buffer]> frame payload

Fired when the websocket sends a frame.

## event: WebSocket.socketerror
## event: WebSocket.socketError
- type: <[String]>

Fired when the websocket has an error.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/input.md
Expand Up @@ -487,7 +487,7 @@ page.set_input_files(
)
```

If you don't have input element in hand (it is created dynamically), you can handle the [`event: Page.filechooser`] event
If you don't have input element in hand (it is created dynamically), you can handle the [`event: Page.fileChooser`] event
or use a corresponding waiting method upon your action:

```js
Expand Down
2 changes: 1 addition & 1 deletion docs/src/navigations.md
Expand Up @@ -21,7 +21,7 @@ navigation succeeds, page starts **loading** the document.
events:
- [`method: Page.url`] is set to the new url
- document content is loaded over network and parsed
- [`event: Page.domcontentloaded`] event is fired
- [`event: Page.DOMContentLoaded`] event is fired
- page executes some scripts and loads resources like stylesheets and images
- [`event: Page.load`] event is fired
- page executes dynamically loaded scripts
Expand Down
4 changes: 2 additions & 2 deletions docs/src/verification.md
Expand Up @@ -108,7 +108,7 @@ page.goto("data:text/html,<script>throw new Error('test')</script>")

### API reference
- [Page]
- [`event: Page.pageerror`]
- [`event: Page.pageError`]

<br/>

Expand Down Expand Up @@ -161,6 +161,6 @@ popup = popup_info.value

### API reference
- [Page]
- [`event: Page.requestfailed`]
- [`event: Page.requestFailed`]
- [`event: Page.dialog`]
- [`event: Page.popup`]
5 changes: 3 additions & 2 deletions utils/generate_types/index.js
Expand Up @@ -54,7 +54,7 @@ let hadChanges = false;
if (member.kind === 'method')
return createMemberLink(member.clazz, `${member.clazz.varName}.${member.alias}(${renderJSSignature(member.argsArray)})`);
if (member.kind === 'event')
return createMemberLink(member.clazz, `${member.clazz.varName}.on('${member.alias}')`);
return createMemberLink(member.clazz, `${member.clazz.varName}.on('${member.alias.toLowerCase()}')`);
if (member.kind === 'property')
return createMemberLink(member.clazz, `${member.clazz.varName}.${member.alias}`);
throw new Error('Unknown member kind ' + member.kind);
Expand Down Expand Up @@ -184,7 +184,8 @@ function createEventDescriptions(classDesc) {
if (!hasUniqueEvents(classDesc))
return [];
const descriptions = [];
for (const [eventName, value] of classDesc.events) {
for (let [eventName, value] of classDesc.events) {
eventName = eventName.toLowerCase();
const type = stringifyComplexType(value && value.type, '', classDesc.name, eventName, 'payload');
const argName = argNameForType(type);
const params = argName ? `${argName}: ${type}` : '';
Expand Down

0 comments on commit ff06399

Please sign in to comment.