Skip to content

Commit 2b974f2

Browse files
authored
docs(clock): update time types in Python/.NET (#31511)
1 parent bfbd5f6 commit 2b974f2

File tree

5 files changed

+94
-30
lines changed

5 files changed

+94
-30
lines changed

docs/src/api/class-clock.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,26 @@ Install fake implementations for the following time-related functions:
6464
Fake timers are used to manually control the flow of time in tests. They allow you to advance time, fire timers, and control the behavior of time-dependent functions. See [`method: Clock.runFor`] and [`method: Clock.fastForward`] for more information.
6565

6666
### option: Clock.install.time
67+
* langs: js, java
6768
* since: v1.45
6869
- `time` <[long]|[string]|[Date]>
6970

7071
Time to initialize with, current system time by default.
7172

73+
### option: Clock.install.time
74+
* langs: python
75+
* since: v1.45
76+
- `time` <[float]|[string]|[Date]>
77+
78+
Time to initialize with, current system time by default.
79+
80+
### option: Clock.install.time
81+
* langs: csharp
82+
* since: v1.45
83+
- `time` <[string]|[Date]>
84+
85+
Time to initialize with, current system time by default.
86+
7287
## async method: Clock.runFor
7388
* since: v1.45
7489

@@ -147,9 +162,25 @@ await page.Clock.PauseAtAsync("2020-02-02");
147162
```
148163

149164
### param: Clock.pauseAt.time
165+
* langs: js, java
150166
* since: v1.45
151167
- `time` <[long]|[string]|[Date]>
152168

169+
Time to pause at.
170+
171+
### param: Clock.pauseAt.time
172+
* langs: python
173+
* since: v1.45
174+
- `time` <[float]|[string]|[Date]>
175+
176+
Time to pause at.
177+
178+
### param: Clock.pauseAt.time
179+
* langs: csharp
180+
* since: v1.45
181+
- `time` <[Date]|[string]>
182+
183+
Time to pause at.
153184

154185
## async method: Clock.resume
155186
* since: v1.45
@@ -195,9 +226,24 @@ await page.Clock.SetFixedTimeAsync("2020-02-02");
195226
```
196227

197228
### param: Clock.setFixedTime.time
229+
* langs: js, java
198230
* since: v1.45
199231
- `time` <[long]|[string]|[Date]>
200232

233+
Time to be set in milliseconds.
234+
235+
### param: Clock.setFixedTime.time
236+
* langs: python
237+
* since: v1.45
238+
- `time` <[float]|[string]|[Date]>
239+
240+
Time to be set.
241+
242+
### param: Clock.setFixedTime.time
243+
* langs: csharp
244+
* since: v1.45
245+
- `time` <[string]|[Date]>
246+
201247
Time to be set.
202248

203249
## async method: Clock.setSystemTime
@@ -238,5 +284,22 @@ await page.Clock.SetSystemTimeAsync("2020-02-02");
238284
```
239285

240286
### param: Clock.setSystemTime.time
287+
* langs: js, java
241288
* since: v1.45
242289
- `time` <[long]|[string]|[Date]>
290+
291+
Time to be set in milliseconds.
292+
293+
### param: Clock.setSystemTime.time
294+
* langs: python
295+
* since: v1.45
296+
- `time` <[float]|[string]|[Date]>
297+
298+
Time to be set.
299+
300+
### param: Clock.setSystemTime.time
301+
* langs: csharp
302+
* since: v1.45
303+
- `time` <[string]|[Date]>
304+
305+
Time to be set.

packages/playwright-core/types/types.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17287,7 +17287,7 @@ export interface Clock {
1728717287
* await page.clock.pauseAt('2020-02-02');
1728817288
* ```
1728917289
*
17290-
* @param time
17290+
* @param time Time to pause at.
1729117291
*/
1729217292
pauseAt(time: number|string|Date): Promise<void>;
1729317293

@@ -17322,7 +17322,7 @@ export interface Clock {
1732217322
* await page.clock.setFixedTime('2020-02-02');
1732317323
* ```
1732417324
*
17325-
* @param time Time to be set.
17325+
* @param time Time to be set in milliseconds.
1732617326
*/
1732717327
setFixedTime(time: number|string|Date): Promise<void>;
1732817328

@@ -17337,7 +17337,7 @@ export interface Clock {
1733717337
* await page.clock.setSystemTime('2020-02-02');
1733817338
* ```
1733917339
*
17340-
* @param time
17340+
* @param time Time to be set in milliseconds.
1734117341
*/
1734217342
setSystemTime(time: number|string|Date): Promise<void>;
1734317343
}

utils/doclint/documentation.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class Documentation {
167167
renderLinksInNodes(nodes, classOrMember) {
168168
if (classOrMember instanceof Member) {
169169
classOrMember.discouraged = classOrMember.discouraged ? this.renderLinksInText(classOrMember.discouraged, classOrMember) : undefined;
170-
classOrMember.deprecated = classOrMember.deprecated ? this.renderLinksInText(classOrMember.deprecated, classOrMember) : undefined
170+
classOrMember.deprecated = classOrMember.deprecated ? this.renderLinksInText(classOrMember.deprecated, classOrMember) : undefined;
171171
}
172172
md.visitAll(nodes, node => {
173173
if (!node.text)
@@ -208,7 +208,7 @@ class Documentation {
208208
}
209209
}
210210

211-
class Class {
211+
class Class {
212212
/**
213213
* @param {Metainfo} metainfo
214214
* @param {string} name
@@ -322,7 +322,7 @@ class Documentation {
322322
for (const e of this.eventsArray)
323323
e.visit(visitor);
324324
}
325-
};
325+
}
326326

327327
class Member {
328328
/**
@@ -345,7 +345,7 @@ class Member {
345345
this.spec = spec;
346346
this.argsArray = argsArray;
347347
this.required = required;
348-
this.comment = '';
348+
this.comment = '';
349349
/** @type {!Map<string, !Member>} */
350350
this.args = new Map();
351351
this.index();
@@ -473,8 +473,10 @@ class Member {
473473
this.type.visit(visitor);
474474
for (const arg of this.argsArray)
475475
arg.visit(visitor);
476+
for (const lang in this.langs.overrides || {})
477+
this.langs.overrides?.[lang].visit(visitor);
476478
}
477-
};
479+
}
478480

479481
class Type {
480482
/**
@@ -509,9 +511,9 @@ class Type {
509511
* @return {Type}
510512
*/
511513
static fromParsedType(parsedType, inUnion = false) {
512-
if (!inUnion && !parsedType.unionName && isStringUnion(parsedType) ) {
514+
if (!inUnion && !parsedType.unionName && isStringUnion(parsedType))
513515
throw new Error('Enum must have a name:\n' + JSON.stringify(parsedType, null, 2));
514-
}
516+
515517

516518
if (!inUnion && (parsedType.union || parsedType.unionName)) {
517519
const type = new Type(parsedType.unionName || '');
@@ -556,15 +558,15 @@ class Type {
556558
/** @type {Member[] | undefined} */
557559
this.properties = this.name === 'Object' ? properties : undefined;
558560
/** @type {Type[] | undefined} */
559-
this.union;
561+
this.union = undefined;
560562
/** @type {Type[] | undefined} */
561-
this.args;
563+
this.args = undefined;
562564
/** @type {Type | undefined} */
563-
this.returnType;
565+
this.returnType = undefined;
564566
/** @type {Type[] | undefined} */
565-
this.templates;
567+
this.templates = undefined;
566568
/** @type {string | undefined} */
567-
this.expression;
569+
this.expression = undefined;
568570
}
569571

570572
visit(visitor) {
@@ -645,7 +647,7 @@ class Type {
645647
if (this.returnType)
646648
this.returnType._collectAllTypes(result);
647649
}
648-
};
650+
}
649651

650652
/**
651653
* @param {ParsedType | null} type
@@ -931,7 +933,7 @@ function processCodeGroups(spec, language, transformer) {
931933
* @param {string} codeLang
932934
* @return {{ highlighter: string, language: string|undefined, codeGroup: string|undefined}}
933935
*/
934-
function parseCodeLang(codeLang) {
936+
function parseCodeLang(codeLang) {
935937
if (codeLang === 'python async')
936938
return { highlighter: 'py', codeGroup: 'python-async', language: 'python' };
937939
if (codeLang === 'python sync')

utils/doclint/generateApiJson.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
// @ts-check
1818

1919
const path = require('path');
20-
const fs = require('fs');
2120
const Documentation = require('./documentation');
2221
const { parseApi } = require('./api_parser');
2322
const PROJECT_DIR = path.join(__dirname, '..', '..');
@@ -73,15 +72,15 @@ function serializeMember(member) {
7372
sanitize(result);
7473
result.args = member.argsArray.map(serializeProperty);
7574
if (member.type)
76-
result.type = serializeType(member.type)
75+
result.type = serializeType(member.type);
7776
return result;
7877
}
7978

8079
function serializeProperty(arg) {
8180
const result = { ...arg };
8281
sanitize(result);
8382
if (arg.type)
84-
result.type = serializeType(arg.type, arg.name === 'options')
83+
result.type = serializeType(arg.type, arg.name === 'options');
8584
return result;
8685
}
8786

utils/markdown.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function buildTree(lines) {
124124
const headerStack = [root];
125125

126126
/** @type {{ indent: string, node: MarkdownNode }[]} */
127-
let sectionStack = [];
127+
const sectionStack = [];
128128

129129
/**
130130
* @param {string} indent
@@ -133,7 +133,7 @@ function buildTree(lines) {
133133
const appendNode = (indent, node) => {
134134
while (sectionStack.length && sectionStack[0].indent.length >= indent.length)
135135
sectionStack.shift();
136-
const parentNode = sectionStack.length ? sectionStack[0].node :headerStack[0];
136+
const parentNode = sectionStack.length ? sectionStack[0].node : headerStack[0];
137137
if (!parentNode.children)
138138
parentNode.children = [];
139139
parentNode.children.push(node);
@@ -176,7 +176,7 @@ function buildTree(lines) {
176176
line = lines[++i];
177177
while (!line.trim().startsWith('```')) {
178178
if (line && !line.startsWith(indent)) {
179-
const from = Math.max(0, i - 5)
179+
const from = Math.max(0, i - 5);
180180
const to = Math.min(lines.length, from + 10);
181181
const snippet = lines.slice(from, to);
182182
throw new Error(`Bad code block: ${snippet.join('\n')}`);
@@ -200,7 +200,7 @@ function buildTree(lines) {
200200
const tokens = [];
201201
while (!line.trim().startsWith(':::')) {
202202
if (!line.startsWith(indent)) {
203-
const from = Math.max(0, i - 5)
203+
const from = Math.max(0, i - 5);
204204
const to = Math.min(lines.length, from + 10);
205205
const snippet = lines.slice(from, to);
206206
throw new Error(`Bad comment block: ${snippet.join('\n')}`);
@@ -254,7 +254,7 @@ function buildTree(lines) {
254254
}
255255

256256
/**
257-
* @param {String} firstLine
257+
* @param {String} firstLine
258258
* @returns {[string, string|undefined]}
259259
*/
260260
function parseCodeBlockMetadata(firstLine) {
@@ -279,7 +279,7 @@ function parse(content) {
279279
function render(nodes, options) {
280280
const result = [];
281281
let lastNode;
282-
for (let node of nodes) {
282+
for (const node of nodes) {
283283
if (node.type === 'null')
284284
continue;
285285
innerRenderMdNode('', node, /** @type {MarkdownNode} */ (lastNode), result, options);
@@ -322,7 +322,7 @@ function innerRenderMdNode(indent, node, lastNode, result, options) {
322322
const bothLinks = node.text.match(/\[[^\]]+\]:/) && lastNode && lastNode.type === 'text' && lastNode.text.match(/\[[^\]]+\]:/);
323323
if (!bothTables && !bothGen && !bothComments && !bothLinks && lastNode && lastNode.text)
324324
newLine();
325-
result.push(wrapText(node.text, options, indent));
325+
result.push(wrapText(node.text, options, indent));
326326
return;
327327
}
328328

@@ -391,15 +391,15 @@ function tokenizeNoBreakLinks(text) {
391391
* @param {string} prefix
392392
* @returns {string}
393393
*/
394-
function wrapText(text, options, prefix) {
394+
function wrapText(text, options, prefix) {
395395
if (options?.flattenText)
396396
text = text.replace(//g, ' ');
397397
const lines = text.split(/[\n]/);
398398
const result = /** @type {string[]} */([]);
399399
const indent = ' '.repeat(prefix.length);
400-
for (const line of lines) {
400+
for (const line of lines)
401401
result.push(wrapLine(line, options?.maxColumns, result.length ? indent : prefix));
402-
}
402+
403403
return result.join('\n');
404404
}
405405

0 commit comments

Comments
 (0)