[rb] link generated BiDi elements to their spec definitions - #17781
Conversation
|
Thank you, @titusfortner for this code suggestion. The support packages contain example code that many users find helpful, but they do not necessarily represent After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. |
PR Summary by QodoAdd specHref links to BiDi schema and emit Ruby @see docs for spec definitions
AI Description
Diagram
High-Level Assessment
Files changed (23)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
22 rules 1.
|
|
Code review by qodo was updated up to the latest commit 1021bc0 |
There was a problem hiding this comment.
Pull request overview
This PR adds optional specHref metadata to the shared WebDriver BiDi schema so generated clients (Ruby in this PR) can link schema elements (domains/modules, commands/events, and types) to their definitions in the living specifications. It also introduces build-time extraction of prose anchors from a pinned rendered BiDi spec HTML, and pins the needed webref dfns indexes + spec HTML via Bazel.
Changes:
- Extend the schema projector to attach optional
specHreflinks to types/commands/events and add a per-domaindomainsmap. - Add a build step to extract prose anchors from pinned BiDi spec HTML and merge them with webref CDDL/dfns links.
- Update the Ruby BiDi generator/templates to render these links as
@seeYARD comments, and update pinning automation (update_cddl.py) + Bazel repos.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/update_cddl.py | Updates the pin-refresh script to also repin dfns indexes and the rendered BiDi spec HTML alongside CDDL. |
| rb/lib/selenium/webdriver/bidi/support/templates/module.rb.erb | Emits @see YARD links for domains, types/unions, enums, and commands when specHref is present. |
| rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb | Threads specHref through the Ruby BiDi IR structs and reads per-domain links from the schema domains map. |
| rb/lib/selenium/webdriver/bidi/protocol/web_extension.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/user_agent_client_hints.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/storage.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/speculation.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/session.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/script.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/network.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/log.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/input.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/emulation.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/browsing_context.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/browser.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| rb/lib/selenium/webdriver/bidi/protocol/bluetooth.rb | Regenerated Ruby BiDi protocol file with added @see links. |
| MODULE.bazel | Adds use_repo entries for the new dfns and rendered-spec http_file repos. |
| javascript/selenium-webdriver/project_bidi_schema.mjs | Adds spec-link mapping/join logic and extends projected schema output with specHref + domains. |
| javascript/selenium-webdriver/project_bidi_schema_test.mjs | Adds unit tests covering dfns mapping, prose anchor extraction, and schema link attachment. |
| javascript/selenium-webdriver/private/generate_bidi.bzl | Extends Bazel generation to stage dfns/spec HTML, extract anchors, and pass them into the schema projector. |
| javascript/selenium-webdriver/extract_bidi_anchors.mjs | New helper to extract prose anchor IDs from pinned BiDi spec HTML into an index for schema linking. |
| javascript/selenium-webdriver/BUILD.bazel | Adds the new anchors extractor binary and wires dfns/spec HTML inputs into BiDi generation. |
| common/webref_cddl.bzl | Adds pinned webref dfns repos and a separately pinned rendered BiDi spec HTML repo to the module extension. |
💥 What does this PR do?
Adds a
specHrefto the shared BiDi schema so generated clients can link eachelement to its definition in the live WebDriver BiDi spec. Types, commands, and
events each carry one, and a new
domainsmap holds the per-domain module link.Where the spec has a readable prose section (
#type-/#command-/#event-/#module-)the link points there; otherwise it falls back to the webref CDDL production
(
#cddl-type-). The Ruby generator renders these as@seedoc comments on domainclasses, command methods, and type/union/enum classes.
🔧 Implementation Notes
specHrefispresent-only-when-known, so existing schema consumers are unaffected and the generated
Ruby changes are comment-only. Other bindings can adopt
specHrefin follow-ups.and no rule predicts which types get one. So the rendered
index.htmlis pinned fromw3c/webdriver-bidi's gh-pages branch (
http_file, commit + sha256, like the CDDL/dfns)and its anchors are extracted at build — nothing fetched live, nothing generated
committed.
//scripts:update_cddlrepins the HTML and refreshes the dfns hashes inlockstep with the CDDL.
…) keep the CDDL fallback on their own origin.
pinned source it was generated against.
🤖 AI assistance
Ruby generator + regenerated protocol files,
update_cddlchanges, tests💡 Additional Considerations
http_filerepos toMODULE.bazel. Additive but coordinated.specHrefthe same way.🔄 Types of changes