Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: declare Python handler types in the docs (#43403)

Pavel Feldman12ade829b4ed
diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md
index 2c0acaa7b2..9dcd8f7524 100644
--- a/docs/src/api/class-browsercontext.md
+++ b/docs/src/api/class-browsercontext.md
@@ -1226,11 +1226,18 @@ A glob pattern, regex pattern, or predicate that receives a [URL] to match durin
### param: BrowserContext.route.handler
* since: v1.8
-* langs: js, python
+* langs: js
- `handler` <[function]\([Route], [Request]\): [Promise<any>|any]>
handler function to route the request.
+### param: BrowserContext.route.handler
+* since: v1.8
+* langs: python
+- `handler` <[function]\([Route]\)|[function]\([Route], [Request]\)>
+
+handler function to route the request.
+
### param: BrowserContext.route.handler
* since: v1.8
* langs: csharp, java
@@ -1656,11 +1663,18 @@ A glob pattern, regex pattern, or predicate receiving [URL] used to register a r
### param: BrowserContext.unroute.handler
* since: v1.8
-* langs: js, python
+* langs: js
- `handler` ?<[function]\([Route], [Request]\): [Promise<any>|any]>
Optional handler function used to register a routing with [`method: BrowserContext.route`].
+### param: BrowserContext.unroute.handler
+* since: v1.8
+* langs: python
+- `handler` ?<[function]\([Route]\)|[function]\([Route], [Request]\)>
+
+Optional handler function used to register a routing with [`method: BrowserContext.route`].
+
### param: BrowserContext.unroute.handler
* since: v1.8
* langs: csharp, java
diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md
index 05d44e7c12..f6761866db 100644
--- a/docs/src/api/class-page.md
+++ b/docs/src/api/class-page.md
@@ -3637,12 +3637,19 @@ await page.AddLocatorHandlerAsync(page.GetByText("Sign up to the newsletter"), a
Locator that triggers the handler.
### param: Page.addLocatorHandler.handler
-* langs: js, python
+* langs: js
* since: v1.42
- `handler` <[function]\([Locator]\): [Promise<any>]>
Function that should be run once [`param: locator`] appears. This function should get rid of the element that blocks actions like click.
+### param: Page.addLocatorHandler.handler
+* langs: python
+* since: v1.42
+- `handler` <[function]\([Locator]\)|[function]\(\): [Promise<any>]>
+
+Function that should be run once [`param: locator`] appears. This function should get rid of the element that blocks actions like click.
+
### param: Page.addLocatorHandler.handler
* langs: csharp
* since: v1.42
@@ -3905,11 +3912,18 @@ A glob pattern, regex pattern, or predicate that receives a [URL] to match durin
### param: Page.route.handler
* since: v1.8
-* langs: js, python
+* langs: js
- `handler` <[function]\([Route], [Request]\): [Promise<any>|any]>
handler function to route the request.
+### param: Page.route.handler
+* since: v1.8
+* langs: python
+- `handler` <[function]\([Route]\)|[function]\([Route], [Request]\)>
+
+handler function to route the request.
+
### param: Page.route.handler
* since: v1.8
* langs: csharp, java
@@ -4695,11 +4709,18 @@ A glob pattern, regex pattern, or predicate receiving [URL] to match while routi
### param: Page.unroute.handler
* since: v1.8
-* langs: js, python
+* langs: js
- `handler` ?<[function]\([Route], [Request]\): [Promise<any>|any]>
Optional handler function to route the request.
+### param: Page.unroute.handler
+* since: v1.8
+* langs: python
+- `handler` ?<[function]\([Route]\)|[function]\([Route], [Request]\)>
+
+Optional handler function to route the request.
+
### param: Page.unroute.handler
* since: v1.8
* langs: csharp, java
diff --git a/utils/doclint/documentation.js b/utils/doclint/documentation.js
index e4ab2e8a67..e49ef4f821 100644
--- a/utils/doclint/documentation.js
+++ b/utils/doclint/documentation.js
@@ -704,9 +704,13 @@ function parseTypeExpression(type) {
}
}
let union = null;
- if (type[firstTypeLength] === '|')
+ if (type[firstTypeLength] === '|') {
union = parseTypeExpression(type.substring(firstTypeLength + 1));
- else if (type[firstTypeLength] === ',')
+ // In `[A]|[B], [C]`, the union ends at the comma: `[C]` is the next item
+ // of the list, not a part of the union.
+ next = union.next;
+ union.next = null;
+ } else if (type[firstTypeLength] === ',')
next = parseTypeExpression(type.substring(firstTypeLength + 1));
if (template && !template.unionName && isStringUnion(template)) {