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

This commit is contained in:
Dmitry Gozman 2021-02-10 07:13:14 -08:00 committed by GitHub
parent 78ab2955f3
commit c12374ea07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 12 deletions

View file

@ -1488,7 +1488,7 @@ User can inspect selectors or perform manual steps while paused. Resume will con
the place it was paused. the place it was paused.
:::note :::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`]. the [`method: BrowserType.launch`].
::: :::

2
types/types.d.ts vendored
View file

@ -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 * User can inspect selectors or perform manual steps while paused. Resume will continue running the original script from
* the place it was paused. * 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). * [browserType.launch([options])](https://playwright.dev/docs/api/class-browsertype#browsertypelaunchoptions).
*/ */
pause(): Promise<void>; pause(): Promise<void>;

View file

@ -637,13 +637,14 @@ function patchLinks(classOrMember, spec, classesMap, membersMap, linkRenderer) {
md.visitAll(spec, node => { md.visitAll(spec, node => {
if (!node.text) if (!node.text)
return; return;
node.text = node.text.replace(/\[`((?:event|method|property): [^\]]+)`\]/g, (match, p1) => { node.text = node.text.replace(/\[`(\w+): ([^\]]+)`\]/g, (match, p1, p2) => {
const member = membersMap.get(p1); if (['event', 'method', 'property'].includes(p1)) {
if (!member) const memberName = p1 + ': ' + p2;
throw new Error('Undefined member references: ' + match); const member = membersMap.get(memberName);
return linkRenderer({ member }) || match; if (!member)
}); throw new Error('Undefined member references: ' + match);
node.text = node.text.replace(/\[`(param|option): ([^\]]+)`\]/g, (match, p1, p2) => { return linkRenderer({ member }) || match;
}
if (p1 === 'param') { if (p1 === 'param') {
let alias = p2; let alias = p2;
if (classOrMember) { if (classOrMember) {
@ -659,6 +660,7 @@ function patchLinks(classOrMember, spec, classesMap, membersMap, linkRenderer) {
} }
if (p1 === 'option') if (p1 === 'option')
return linkRenderer({ option: p2 }) || match; 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) => { node.text = node.text.replace(/\[([\w]+)\]/g, (match, p1) => {
const clazz = classesMap.get(p1); const clazz = classesMap.get(p1);