Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(docs): index all deeply nested types (#31690)
Max Schmitt950875f0db4a
diff --git a/utils/doclint/api_parser.js b/utils/doclint/api_parser.jsindex 105c56c658..a593872f99 100644--- a/utils/doclint/api_parser.js+++ b/utils/doclint/api_parser.js@@ -92,12 +92,13 @@ class ApiParser {const match = spec.text.match(/(event|method|property|async method|optional method|optional async method): ([^.]+)\.(.*)/);if (!match)throw new Error('Invalid member: ' + spec.text);+ const metainfo = extractMetainfo(spec);const name = match[3];let returnType = null;let optional = false;for (const item of spec.children || []) {if (item.type === 'li' && item.liType === 'default') {- const parsed = this.parseType(item);+ const parsed = this.parseType(item, metainfo.since ?? 'v1.0');returnType = parsed.type;optional = parsed.optional;}@@ -106,7 +107,6 @@ class ApiParser {returnType = new docs.Type('void');const comments = extractComments(spec);- const metainfo = extractMetainfo(spec);let member;if (match[1] === 'event')member = docs.Member.createEvent(metainfo, name, returnType, comments);@@ -188,7 +188,7 @@ class ApiParser {let options = method.argsArray.find(o => o.name === 'options');if (!options) {const type = new docs.Type('Object', []);- options = docs.Member.createProperty({ langs: {}, since: 'v1.0', deprecated: undefined, discouraged: undefined }, 'options', type, undefined, false);+ options = docs.Member.createProperty({ langs: {}, since: method.since, deprecated: undefined, discouraged: undefined }, 'options', type, undefined, false);method.argsArray.push(options);}p.required = false;@@ -209,25 +209,26 @@ class ApiParser {typeStart--;const name = text.substring(0, typeStart).replace(/\`/g, '').trim();const comments = extractComments(spec);- const { type, optional } = this.parseType(/** @type {MarkdownLiNode} */(param));const metainfo = extractMetainfo(spec);if (metainfo.hidden)return null;+ const { type, optional } = this.parseType(/** @type {MarkdownLiNode} */(param), metainfo.since ?? 'v1.0');return docs.Member.createProperty(metainfo, name, type, comments, !optional);}/*** @param {MarkdownLiNode} spec+ * @param {string} since* @return {{ type: docs.Type, optional: boolean }}*/- parseType(spec) {+ parseType(spec, since) {const arg = parseVariable(spec.text);const properties = [];for (const child of /** @type {MarkdownLiNode[]} */ (spec.children) || []) {const { name, text } = parseVariable(/** @type {string} */(child.text));const comments = /** @type {MarkdownNode[]} */ ([{ type: 'text', text }]);- const childType = this.parseType(child);- properties.push(docs.Member.createProperty({ langs: {}, since: 'v1.0', deprecated: undefined, discouraged: undefined }, name, childType.type, comments, !childType.optional));+ const childType = this.parseType(child, since);+ properties.push(docs.Member.createProperty({ langs: {}, since, deprecated: undefined, discouraged: undefined }, name, childType.type, comments, !childType.optional));}const type = docs.Type.parse(arg.type, properties);return { type, optional: arg.optional };diff --git a/utils/doclint/documentation.js b/utils/doclint/documentation.jsindex 54a2153273..8019b5a230 100644--- a/utils/doclint/documentation.js+++ b/utils/doclint/documentation.js@@ -372,15 +372,20 @@ class Member {this.args = new Map();if (this.kind === 'method')this.enclosingMethod = this;+ const indexType = type => {+ type.deepProperties().forEach(p => {+ p.enclosingMethod = this;+ indexType(p.type);+ });+ }for (const arg of this.argsArray) {this.args.set(arg.name, arg);arg.enclosingMethod = this;if (arg.name === 'options') {// @ts-ignorearg.type.properties.sort((p1, p2) => p1.name.localeCompare(p2.name));- // @ts-ignore- arg.type.properties.forEach(p => p.enclosingMethod = this);}+ indexType(arg.type);}}