Skip to content

[py] Improve docstrings in generated BiDi modules#17392

Open
AutomatedTester wants to merge 4 commits intotrunkfrom
improve-bidi-docstrings
Open

[py] Improve docstrings in generated BiDi modules#17392
AutomatedTester wants to merge 4 commits intotrunkfrom
improve-bidi-docstrings

Conversation

@AutomatedTester
Copy link
Copy Markdown
Member

@AutomatedTester AutomatedTester commented Apr 25, 2026

Adds manifest-driven docstring support to the BiDi code generator so end users get meaningful help() output and IDE hover docs for generated modules.

Changes

py/generate_bidi.py

  • Replace ad-hoc docstring helpers with _docstring_text() + _emit_docstring()
  • _emit_docstring() produces correct PEP 257 layout: opening/closing triple-quotes on their own lines for multi-line strings; inline for single-line
  • module_docstring is now emitted before from __future__ import annotations so it becomes the real module __doc__
  • Three new manifest keys supported: module_docstring, class_docstrings, command_docstrings

py/private/bidi_enhancements_manifest.py

  • Populate docstring content for the four BiDi-adjacent modules (permissions, bluetooth, speculation, userAgentClientHints)
  • Module docstrings, key dataclass descriptions, and command method summaries

Copilot AI review requested due to automatic review settings April 25, 2026 12:22
@selenium-ci selenium-ci added C-py Python Bindings B-build Includes scripting, bazel and CI integrations labels Apr 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Python BiDi codegen pipeline to support richer docstrings (via the enhancements manifest) and to generate additional BiDi-adjacent modules by merging multiple WebRef CDDL specs.

Changes:

  • Add docstring formatting helpers and manifest-driven docstring injection to the BiDi generator.
  • Merge multiple CDDL inputs during Bazel generation and expand the set of generated module outputs.
  • Extend BiDi permissions tests to cover the new embedded_origin keyword-only API behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
py/generate_bidi.py Adds manifest-driven docstring handling and removes the bespoke permissions file generator.
py/private/bidi_enhancements_manifest.py Provides new module/class/command docstrings and a custom Permissions.set_permission(..., *, embedded_origin=None) method.
py/private/generate_bidi.bzl Extends the Bazel rule to merge extra CDDL inputs and declares additional generated module outputs.
py/private/merge_cddl.py New helper tool to concatenate multiple CDDL files into a single generator input.
py/private/BUILD.bazel Exposes merge_cddl.py as a Bazel py_binary for use by the generation rule.
py/BUILD.bazel Wires extra WebRef CDDL specs into the BiDi generation target and configures the merge tool.
py/test/selenium/webdriver/common/bidi_permissions_tests.py Adds regression/behavior tests for embedded_origin being keyword-only and accepted when passed by keyword.

Comment thread py/generate_bidi.py Outdated
Comment thread py/generate_bidi.py Outdated
Comment thread py/BUILD.bazel
@AutomatedTester AutomatedTester force-pushed the improve-bidi-docstrings branch from a942e0f to 3c18960 Compare April 27, 2026 12:57
Copilot AI review requested due to automatic review settings April 29, 2026 10:40
@AutomatedTester AutomatedTester force-pushed the improve-bidi-docstrings branch from 3c18960 to df63f3b Compare April 29, 2026 10:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

Comment thread py/private/bidi_enhancements_manifest.py Outdated
Comment thread py/private/bidi_enhancements_manifest.py Outdated
Comment thread py/generate_bidi.py Outdated
Comment thread py/generate_bidi.py Outdated
Comment thread py/generate_bidi.py Outdated
Comment thread py/private/bidi_enhancements_manifest.py Outdated
Add three new manifest keys to the generator so end users get meaningful
help() output and IDE hover docs for the new BiDi modules:

- module_docstring: file-level triple-quoted string after imports
- class_docstrings: per-class docstring override (dataclasses and enums)
- command_docstrings: per-command method docstring override

Continuation lines are automatically re-indented to match the enclosing
block depth (4 spaces for class body, 8 for method body). Fallback
docstrings (class name only) retain the trailing period they had before.

Populate content for all four new modules:
- permissions: module doc, PermissionState and Permissions class docs
- bluetooth: module doc, 6 key dataclass docs, 13 command method docs
- speculation: module doc, PreloadingStatus and PrefetchStatusUpdatedParameters docs
- userAgentClientHints: module doc, ClientHintsMetadata and BrandVersion docs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AutomatedTester AutomatedTester force-pushed the improve-bidi-docstrings branch from df63f3b to 5cd1644 Compare April 29, 2026 10:53
@AutomatedTester AutomatedTester changed the title [py] Improve bidi docstrings [py] Improve docstrings in generated BiDi modules Apr 29, 2026
Copilot AI review requested due to automatic review settings April 30, 2026 10:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread py/generate_bidi.py Outdated
Comment thread py/generate_bidi.py Outdated
AutomatedTester and others added 2 commits April 30, 2026 14:42
- Remove unused MODULE_HEADER constant (superseded by
  _MODULE_HEADER_COMMENTS + _MODULE_HEADER_IMPORTS)
- Move enhancements normalisation before first .get() call to prevent
  AttributeError when generate_code() is called with enhancements=None

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The _emit_docstring docstring contained escaped backslash sequences
which ruff flags as D301. Adding the r prefix satisfies the rule.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 30, 2026 14:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations C-py Python Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants