Skip to content

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

docs: introduce struct names for ports (#39931)

Dmitry Gozman9faf55174318
diff --git a/docs/src/api/class-apiresponse.md b/docs/src/api/class-apiresponse.md
index 468a5a830d..d439df9992 100644
--- a/docs/src/api/class-apiresponse.md
+++ b/docs/src/api/class-apiresponse.md
@@ -57,7 +57,7 @@ An object with all the response HTTP headers associated with this response.
## method: APIResponse.headersArray
* since: v1.16
-- returns: <[Array]<[Object]>>
+- returns: <[Array]<[Object=Header]>>
- `name` <[string]> Name of the header.
- `value` <[string]> Value of the header.
diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md
index 8e9b75ac05..c1e034ec39 100644
--- a/docs/src/api/class-browsercontext.md
+++ b/docs/src/api/class-browsercontext.md
@@ -569,7 +569,7 @@ The default browser context cannot be closed.
## async method: BrowserContext.cookies
* since: v1.8
-- returns: <[Array]<[Object]>>
+- returns: <[Array]<[Object=BrowserContextCookiesResult]>>
- `name` <[string]>
- `value` <[string]>
- `domain` <[string]>
diff --git a/docs/src/api/class-debugger.md b/docs/src/api/class-debugger.md
index 6334a4ab67..322b14b272 100644
--- a/docs/src/api/class-debugger.md
+++ b/docs/src/api/class-debugger.md
@@ -11,7 +11,7 @@ Emitted when the debugger pauses or resumes.
## method: Debugger.pausedDetails
* since: v1.59
-- returns: <[null]|[Object]>
+- returns: <[null]|[Object=DebuggerPausedDetails]>
- `location` <[Object]>
- `file` <[string]>
- `line` ?<[int]>
diff --git a/docs/src/api/class-elementhandle.md b/docs/src/api/class-elementhandle.md
index 730269950f..9e048baadc 100644
--- a/docs/src/api/class-elementhandle.md
+++ b/docs/src/api/class-elementhandle.md
@@ -108,7 +108,7 @@ await locator.ClickAsync();
## async method: ElementHandle.boundingBox
* since: v1.8
-- returns: <[null]|[Object]>
+- returns: <[null]|[Object=ElementHandleBoundingBoxResult]>
- `x` <[float]> the x coordinate of the element in pixels.
- `y` <[float]> the y coordinate of the element in pixels.
- `width` <[float]> the width of the element in pixels.
diff --git a/docs/src/api/class-formdata.md b/docs/src/api/class-formdata.md
index c5f4bcb51d..2c42456ace 100644
--- a/docs/src/api/class-formdata.md
+++ b/docs/src/api/class-formdata.md
@@ -68,7 +68,7 @@ Field name.
### param: FormData.append.value
* since: v1.44
-- `value` <[string]|[boolean]|[int]|[Path]|[Object]>
+- `value` <[string]|[boolean]|[int]|[Path]|[Object=FilePayload]>
- `name` <[string]> File name
- `mimeType` <[string]> File type
- `buffer` <[Buffer]> File content
@@ -78,7 +78,7 @@ Field value.
### param: FormData.append.value
* since: v1.44
* langs: csharp
-- `value` <[string]|[boolean]|[int]|[Object]>
+- `value` <[string]|[boolean]|[int]|[Object=FilePayload]>
- `name` <[string]> File name
- `mimeType` <[string]> File type
- `buffer` <[Buffer]> File content
@@ -135,7 +135,7 @@ Field name.
### param: FormData.set.value
* since: v1.18
-- `value` <[string]|[boolean]|[int]|[Path]|[Object]>
+- `value` <[string]|[boolean]|[int]|[Path]|[Object=FilePayload]>
- `name` <[string]> File name
- `mimeType` <[string]> File type
- `buffer` <[Buffer]> File content
@@ -145,7 +145,7 @@ Field value.
### param: FormData.set.value
* since: v1.18
* langs: csharp
-- `value` <[string]|[boolean]|[int]|[Object]>
+- `value` <[string]|[boolean]|[int]|[Object=FilePayload]>
- `name` <[string]> File name
- `mimeType` <[string]> File type
- `buffer` <[Buffer]> File content
diff --git a/docs/src/api/class-locator.md b/docs/src/api/class-locator.md
index ae53d6f49e..25f0251216 100644
--- a/docs/src/api/class-locator.md
+++ b/docs/src/api/class-locator.md
@@ -242,7 +242,7 @@ Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur)
## async method: Locator.boundingBox
* since: v1.14
-- returns: <[null]|[Object]>
+- returns: <[null]|[Object=LocatorBoundingBoxResult]>
- `x` <[float]> the x coordinate of the element in pixels.
- `y` <[float]> the y coordinate of the element in pixels.
- `width` <[float]> the width of the element in pixels.
diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md
index 020c748c56..7affcf3bf3 100644
--- a/docs/src/api/class-page.md
+++ b/docs/src/api/class-page.md
@@ -4461,7 +4461,7 @@ Video object associated with this page. Can be used to access the video file whe
## method: Page.viewportSize
* since: v1.8
-- returns: <[null]|[Object]>
+- returns: <[null]|[Object=PageViewportSizeResult]>
- `width` <[int]> page width in pixels.
- `height` <[int]> page height in pixels.
diff --git a/docs/src/api/class-request.md b/docs/src/api/class-request.md
index 3d0ef0f58c..1ee132d794 100644
--- a/docs/src/api/class-request.md
+++ b/docs/src/api/class-request.md
@@ -113,7 +113,7 @@ You can use [`method: Request.allHeaders`] for complete list of headers that inc
## async method: Request.headersArray
* since: v1.15
-- returns: <[Array]<[Object]>>
+- returns: <[Array]<[Object=Header]>>
- `name` <[string]> Name of the header.
- `value` <[string]> Value of the header.
@@ -310,7 +310,7 @@ Requests originated in a Service Worker do not have a [`method: Request.frame`]
## async method: Request.sizes
* since: v1.15
-- returns: <[Object]>
+- returns: <[Object=RequestSizesResult]>
- `requestBodySize` <[int]> Size of the request body (POST data payload) in bytes. Set to 0 if there was no body.
- `requestHeadersSize` <[int]> Total number of bytes from the start of the HTTP request message until (and including) the double CRLF before the body.
- `responseBodySize` <[int]> Size of the received response body (encoded) in bytes.
@@ -320,7 +320,7 @@ Returns resource size information for given request.
## method: Request.timing
* since: v1.8
-- returns: <[Object]>
+- returns: <[Object=RequestTimingResult]>
- `startTime` <[float]> Request start time in milliseconds elapsed since January 1, 1970 00:00:00 UTC
- `domainLookupStart` <[float]> Time immediately before the browser starts the domain name lookup for the
resource. The value is given in milliseconds relative to `startTime`, -1 if not available.
diff --git a/docs/src/api/class-response.md b/docs/src/api/class-response.md
index 8fcef0883d..9433109a0a 100644
--- a/docs/src/api/class-response.md
+++ b/docs/src/api/class-response.md
@@ -48,7 +48,7 @@ You can use [`method: Response.allHeaders`] for complete list of headers that in
## async method: Response.headersArray
* since: v1.15
-- returns: <[Array]<[Object]>>
+- returns: <[Array]<[Object=Header]>>
- `name` <[string]> Name of the header.
- `value` <[string]> Value of the header.
@@ -118,7 +118,7 @@ Returns the matching [Request] object.
## async method: Response.securityDetails
* since: v1.13
-- returns: <[null]|[Object]>
+- returns: <[null]|[Object=ResponseSecurityDetailsResult]>
- `issuer` ?<[string]> Common Name component of the Issuer field.
from the certificate. This should only be used for informational purposes. Optional.
- `protocol` ?<[string]> The specific TLS protocol used. (e.g. `TLS 1.3`). Optional.
@@ -133,7 +133,7 @@ Returns SSL and other security information.
## async method: Response.serverAddr
* since: v1.13
-- returns: <[null]|[Object]>
+- returns: <[null]|[Object=ResponseServerAddrResult]>
- `ipAddress` <[string]> IPv4 or IPV6 address of the server.
- `port` <[int]>
diff --git a/docs/src/api/class-screencast.md b/docs/src/api/class-screencast.md
index 8ba066e6a8..f90ceb79b9 100644
--- a/docs/src/api/class-screencast.md
+++ b/docs/src/api/class-screencast.md
@@ -32,7 +32,7 @@ Callback that receives JPEG-encoded frame data.
### option: Screencast.start.preferredSize
* since: v1.59
* langs: js
-- `preferredSize` ?<[Object]>
+- `preferredSize` ?<[Object=ScreencastSize]>
- `width` <[int]> Max frame width in pixels.
- `height` <[int]> Max frame height in pixels.
@@ -62,7 +62,7 @@ Path where the video should be saved when the recording is stopped.
### option: Screencast.startRecording.size
* since: v1.59
-- `size` ?<[Object]>
+- `size` ?<[Object=ScreencastSize]>
- `width` <[int]> Video frame width.
- `height` <[int]> Video frame height.
@@ -70,7 +70,7 @@ Optional dimensions of the recorded video. If not specified the size will be equ
### option: Screencast.startRecording.annotate
* since: v1.59
-- `annotate` ?<[Object]>
+- `annotate` ?<[Object=ScreencastAnnotation]>
- `duration` ?<[float]> How long each annotation is displayed in milliseconds. Defaults to `500`.
- `position` ?<[AnnotatePosition]<"top-left"|"top"|"top-right"|"bottom-left"|"bottom"|"bottom-right">> Position of the action title overlay. Defaults to `"top-right"`.
- `fontSize` ?<[int]> Font size of the action title in pixels. Defaults to `24`.
diff --git a/docs/src/api/params.md b/docs/src/api/params.md
index 862a296f2b..e2d6de0682 100644
--- a/docs/src/api/params.md
+++ b/docs/src/api/params.md
@@ -126,7 +126,7 @@ and Linux and to "Meta" on macOS.
Defaults to `left`.
## input-files
-- `files` <[path]|[Array]<[path]>|[Object]|[Array]<[Object]>>
+- `files` <[path]|[Array]<[path]>|[Object=FilePayload]|[Array]<[Object=FilePayload]>>
- `name` <[string]> File name
- `mimeType` <[string]> File type
- `buffer` <[Buffer]> File content
@@ -805,12 +805,12 @@ When set to `minimal`, only record information necessary for routing from HAR. T
* langs: js
- `recordVideo` <[Object]>
- `dir` ?<[path]> Path to the directory to put videos into. If not specified, the videos will be stored in `artifactsDir` (see [`method: BrowserType.launch`] options).
- - `size` ?<[Object]> Optional dimensions of the recorded videos. If not specified the size will be equal to `viewport`
+ - `size` ?<[Object=RecordVideoSize]> Optional dimensions of the recorded videos. If not specified the size will be equal to `viewport`
scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450.
Actual picture of each page will be scaled down if necessary to fit the specified size.
- `width` <[int]> Video frame width.
- `height` <[int]> Video frame height.
- - `annotate` ?<[Object]> If specified, enables visual annotations on interacted elements during video recording.
+ - `annotate` ?<[Object=VideoAnnotation]> If specified, enables visual annotations on interacted elements during video recording.
- `duration` ?<[float]> How long each annotation is displayed in milliseconds. Defaults to `500`.
- `position` ?<[AnnotatePosition]<"top-left"|"top"|"top-right"|"bottom-left"|"bottom"|"bottom-right">> Position of the action title overlay. Defaults to `"top-right"`.
- `fontSize` ?<[int]> Font size of the action title in pixels. Defaults to `24`.
diff --git a/utils/doclint/documentation.js b/utils/doclint/documentation.js
index 4246c72ed6..27d860ac2d 100644
--- a/utils/doclint/documentation.js
+++ b/utils/doclint/documentation.js
@@ -544,6 +544,14 @@ class Type {
type.templates.push(Type.fromParsedType(t));
return type;
}
+
+ const stripped = parsedType.name.replace(/^\[/, '').replace(/\]$/, '');
+ const eqIndex = stripped.indexOf('=');
+ if (eqIndex !== -1) {
+ const type = new Type(stripped.substring(0, eqIndex));
+ type.structName = stripped.substring(eqIndex + 1);
+ return type;
+ }
return new Type(parsedType.name);
}
@@ -565,6 +573,8 @@ class Type {
this.templates = undefined;
/** @type {string | undefined} */
this.expression = undefined;
+ /** @type {string | undefined} */
+ this.structName = undefined;
}
visit(visitor) {
@@ -587,6 +597,7 @@ class Type {
if (this.templates)
type.templates = this.templates.map(type => type.clone());
type.expression = this.expression;
+ type.structName = this.structName;
return type;
}
diff --git a/utils/doclint/generateDotnetApi.js b/utils/doclint/generateDotnetApi.js
index 5f4182ea4f..532e0a6b35 100644
--- a/utils/doclint/generateDotnetApi.js
+++ b/utils/doclint/generateDotnetApi.js
@@ -388,6 +388,11 @@ function getPropertyOverloads(type, member, name, parent) {
* @param {*} parent
*/
function generateNameDefault(member, name, t, parent) {
+ if (t.structName) {
+ registerModelType(t.structName, t);
+ return t.structName;
+ }
+
if (!t.properties
&& !t.templates
&& !t.union
@@ -425,27 +430,6 @@ function generateNameDefault(member, name, t, parent) {
&& !['properties', 'httpcredentials'].includes(attemptedName.toLowerCase()))
attemptedName = attemptedName.substring(0, attemptedName.length - 1);
- // For some of these we don't want to generate generic types.
- // For some others we simply did not have the code that was deduping the names.
- if (attemptedName === 'BoundingBox')
- attemptedName = `${parent.name}BoundingBoxResult`;
- if (attemptedName === 'BrowserContextCookie')
- attemptedName = 'BrowserContextCookiesResult';
- if (attemptedName === 'File' || (parent.name === 'FormData' && ['SetValue', 'AppendValue'].includes(attemptedName)))
- attemptedName = `FilePayload`;
- if (attemptedName === 'Size')
- attemptedName = 'RequestSizesResult';
- if (attemptedName === 'ViewportSize' && parent.name === 'Page')
- attemptedName = 'PageViewportSizeResult';
- if (attemptedName === 'SecurityDetail')
- attemptedName = 'ResponseSecurityDetailsResult';
- if (attemptedName === 'ServerAddr')
- attemptedName = 'ResponseServerAddrResult';
- if (attemptedName === 'Timing')
- attemptedName = 'RequestTimingResult';
- if (attemptedName === 'HeadersArray')
- attemptedName = 'Header';
-
const probableType = modelTypes.get(attemptedName);
if ((probableType && typesDiffer(t, probableType))
|| (['Value'].includes(attemptedName))) {
@@ -845,6 +829,7 @@ function translateType(type, parent, generateNameCallback = t => t.name, optiona
function registerModelType(typeName, type) {
if (['object', 'string', 'int', 'long'].includes(typeName))
return;
+
if (typeName.endsWith('Option'))
return;