Skip to content

chore(codegen): generate the public API from the upstream docs - #3240

Merged
Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:codegen-from-docs
Oct 12, 2026
Merged

Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:codegen-from-docs

Conversation

@pavelfeldman

Copy link
Copy Markdown
Member

Summary

  • Generates async_api/_generated.py and sync_api/_generated.py from the upstream docs (docs/src/api) with the upstream doc parser, instead of introspecting playwright/_impl. Generator: scripts/codegen/generate_api.js; Python-only facts: scripts/codegen/python_rules.js.
  • scripts/codegen/legacy_order.json and the code marked TEMPORARY keep the old order and formatting, so the _generated.py diff shows only real changes (mostly docstring fixes). The next PRs in the stack remove them.
  • No change to playwright/_impl or tests. Stack: 1/3.

- scripts/codegen/generate_api.js builds async_api/_generated.py and
  sync_api/_generated.py from docs/src/api with the upstream doc parser,
  instead of introspecting playwright/_impl.
- scripts/codegen/python_rules.js records the Python facts that the docs
  do not contain.
- scripts/codegen/legacy_order.json and the code marked TEMPORARY keep the
  old order and formatting, so that the generated diff shows only real
  changes. Follow-up changes remove them.
- Removes the old generator scripts.
return mapping.from_impl(
self._impl_obj.locator(
selectorOrLocator=selector_or_locator,
selectorOrLocator=mapping.to_impl(selector_or_locator),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behavior change!


// Arguments whose Python name differs from the docs.
argNames: {
// The docs header says `name`, the type line says `description`; Python shipped `name`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch!!!

'predicate',
],

// Struct (TypedDict) names. The docs name a struct with `* alias:`; these

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This differs from what we do for java/.net and we should align them all I guess.

// No docs alias.
'*.*.recordVideoSize': 'ViewportSize',
// No docs alias.
'Page.setViewportSize.viewportSize': 'ViewportSize',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't believe this one does not have an alias. We should add it :) Probably true for many others.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan is to update aliases once this lands, to burn this delta down

return mapping.from_impl(
self._impl_obj.locator(
selectorOrLocator=selector_or_locator,
selectorOrLocator=mapping.to_impl(selector_or_locator),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more behavior change!

return mapping.from_impl(
self._impl_obj.locator(
selectorOrLocator=selector_or_locator,
selectorOrLocator=mapping.to_impl(selector_or_locator),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And again.

timeout=to_milliseconds(timeout),
storageState=storage_state,
clientCertificates=client_certificates,
clientCertificates=mapping.to_impl(client_certificates),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And some more!

@pavelfeldman
Pavel Feldman (pavelfeldman) merged commit b93d8b9 into microsoft:main Oct 12, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants