Skip to content

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

feat(docs): improve link validation (#5394)

Dmitry Gozmanc12374ea0787
diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md
index 8e638e4859..8985a1b8e2 100644
--- a/docs/src/api/class-page.md
+++ b/docs/src/api/class-page.md
@@ -1488,7 +1488,7 @@ User can inspect selectors or perform manual steps while paused. Resume will con
the place it was paused.
:::note
-This method requires Playwright to be started in a headed mode, with a falsy [`options: headless`] value in
+This method requires Playwright to be started in a headed mode, with a falsy [`option: headless`] value in
the [`method: BrowserType.launch`].
:::
diff --git a/types/types.d.ts b/types/types.d.ts
index c0b4096023..8f07e87d60 100644
--- a/types/types.d.ts
+++ b/types/types.d.ts
@@ -2089,7 +2089,7 @@ export interface Page {
* User can inspect selectors or perform manual steps while paused. Resume will continue running the original script from
* the place it was paused.
*
- * > NOTE: This method requires Playwright to be started in a headed mode, with a falsy [`options: headless`] value in the
+ * > NOTE: This method requires Playwright to be started in a headed mode, with a falsy `headless` value in the
* [browserType.launch([options])](https://playwright.dev/docs/api/class-browsertype#browsertypelaunchoptions).
*/
pause(): Promise<void>;
diff --git a/utils/doclint/documentation.js b/utils/doclint/documentation.js
index f665deafd0..2c0b303e98 100644
--- a/utils/doclint/documentation.js
+++ b/utils/doclint/documentation.js
@@ -49,7 +49,7 @@ const md = require('../markdown');
* option?: string
* }): string} Renderer
*/
-
+
class Documentation {
/**
* @param {!Array<!Documentation.Class>} classesArray
@@ -254,7 +254,7 @@ Documentation.Class = class {
}
}
- /**
+ /**
* @param {function(Documentation.Member|Documentation.Class): void} visitor
*/
visit(visitor) {
@@ -383,7 +383,7 @@ Documentation.Member = class {
return new Documentation.Member('event', langs, name, type, [], spec);
}
- /**
+ /**
* @param {function(Documentation.Member|Documentation.Class): void} visitor
*/
visit(visitor) {
@@ -637,13 +637,14 @@ function patchLinks(classOrMember, spec, classesMap, membersMap, linkRenderer) {
md.visitAll(spec, node => {
if (!node.text)
return;
- node.text = node.text.replace(/\[`((?:event|method|property): [^\]]+)`\]/g, (match, p1) => {
- const member = membersMap.get(p1);
- if (!member)
- throw new Error('Undefined member references: ' + match);
- return linkRenderer({ member }) || match;
- });
- node.text = node.text.replace(/\[`(param|option): ([^\]]+)`\]/g, (match, p1, p2) => {
+ node.text = node.text.replace(/\[`(\w+): ([^\]]+)`\]/g, (match, p1, p2) => {
+ if (['event', 'method', 'property'].includes(p1)) {
+ const memberName = p1 + ': ' + p2;
+ const member = membersMap.get(memberName);
+ if (!member)
+ throw new Error('Undefined member references: ' + match);
+ return linkRenderer({ member }) || match;
+ }
if (p1 === 'param') {
let alias = p2;
if (classOrMember) {
@@ -659,6 +660,7 @@ function patchLinks(classOrMember, spec, classesMap, membersMap, linkRenderer) {
}
if (p1 === 'option')
return linkRenderer({ option: p2 }) || match;
+ throw new Error(`Undefined link prefix, expected event|method|property|param|option, got: ` + match);
});
node.text = node.text.replace(/\[([\w]+)\]/g, (match, p1) => {
const clazz = classesMap.get(p1);