Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Bikeshed pre-processor for WebDriver #1462

Open
andreastt opened this issue Nov 30, 2019 · 9 comments · May be fixed by #1514
Open

Use Bikeshed pre-processor for WebDriver #1462

andreastt opened this issue Nov 30, 2019 · 9 comments · May be fixed by #1514
Assignees
Labels
Milestone

Comments

@andreastt
Copy link
Member

I would like to propose converting the specification to use the Bikeshed spec pre-processor.

Bikeshed produces specification documents that are equivalent to ReSpec that we currently use, but instead of transforming the source document at load-time (through content JavaScript) it pre-processes the source document into a complete, finished HTML document as a build step.

As many of you know I have a distaste for hard-to-explain build steps and a love for the mutable what-you-see-is-what-you-get web, so I am not the natural proponent of this kind of change. But I have come to the realisation that some of the forthcoming changes we need to make for the bi-directional protocol would be easier to tackle if we can run tasks as build steps.

One of the takeaways from TPAC 2019 in Nagoya, Japan was that we need to make WebDriver more discoverable for web authors, client maintainers, and browser developers. There are various things we could do, but I believe the most effective is to make the specification machine-readable.

With the proliferation of APIs that we expect to see with the bi-directional work, we will be moving from a human-managable set of endpoints to a reality where computer automation would be necessary to assist with ingesting changes. Having formalised schema definitions for the different interfaces, methods, and types will enable wider and earlier adoption of new APIs because the specification is offering a useful service to implementors.

Now to the point of this issue and why it means we need a pre-processor:

I picture that the schemas should be defined in separate files/artifacts, rather than be inlined in the source spec document. This would allow generation of API documentation (using Swagger or something equivalent) to serve as client maintainer documentation, MDN browser compat data and API documentation, and—most importantly!—generation of source files ready for use in browser implementations (for example into C++ or Rust) for schema validation, or local-end clients (Go/C#/Java).

With schema definitions as separate artifacts, ingesting them into the document would require a build step. We could hack together the inlining of interfaces for ReSpec with m4(1) or sed(1), but if there’s already a necessity to add a build step it would seem more obvious to adopt a spec authoring tool that already supports inclusion of files.

Here are some arbitrary examples of Bikeshed-backed specs from W3C, WHATWG, and non-affiliated:

Pros:

  • Syntax is not too different from ReSpec
  • Allows interface definitions to live separately from the spec, enabling their use for other purposes:
    • MDN browser compat data
    • MDN API listings
    • API documentation generation (Swagger or similar)
    • Source code generation for browsers (C++/Rust) and clients (Go/C#/Java)
  • Correctness checks can be done when PRs are created because pre-processor validates source document for parsing
  • Loading https://w3c.github.io/webdriver/ should be a lot quicker
  • Spec can be viewed locally without internet connection
    • With ReSpec we rely on a bunch of remote resources from www.w3.org
  • We won’t be hit by upstream ReSpec bugs
    • We rely on ReSpec from a remote server, meaning upstream bugs hit us immediately and retroactively affects already published documents

Cons:

  • Requires build step to try out changes locally (view in browser)
    • Installation of Bikeshed dependency shouldn’t be necessary with internet access because we can have remote HTML generation
  • Cannot make real-time changes (e.g. with DevTools) and see the transformed result immediately
  • The conversion itself is a bit of busy-work, as we could hack the inlining of interfaces with ReSpec

Overall I don’t think the change should impact our workflow too much.

@foolip
Copy link
Member

foolip commented May 26, 2020

Does doing this have support among the editors and others impacted? I've done some conversions to Bikeshed before, am pretty good at vetting for unintended differences, and might volunteer if it's likely to be accepted.

@AutomatedTester
Copy link
Contributor

Both @shs96c and I don't mind what tool is used. I am happy for it to be moved over, I just haven't prioritised this work

@foolip
Copy link
Member

foolip commented May 26, 2020

I'd be happy to take a stab at this. There are 11 open pull requests in https://github.com/w3c/webdriver/pulls right now, and rebasing them will be an entirely manual affair. Are there any that can be merged or closed to reduce the amount of work needed?

@christian-bromann
Copy link
Member

christian-bromann commented May 27, 2020

@foolip it would be great if this protocol could be machine readable as it would simplify the creation of rudimental bindings that can be used to build a framework with higher level abstractions as well as for documentation. For example: the Chrome DevTools protocol is maintained as a pure json file and is used to build its documentation page as well as CDP modules like chrome-remote-interface. This can safe a lot of time and duplication for adopters building packages around the protocol.

Another example is from the WebdriverIO project where I've defined a custom JSON format of the WebDriver spec that is used to autogenerate a minimal functional binding. While I think a spec text is not necessarily suited as user documentation - being able to have the ability for type checks especially in the JS ecosystem would be very beneficial.

A while ago I tried to convert the current WebDriver protocol into an OpenAPI spec and was able to generate a page like this: https://webdriver.github.io/webdriver/. I can imagine that it should be not that difficult to build a bikeshed pre processor that reads an OpenAPI spec and coverts it into a spec document.

I would be happy to help contribute and drive the effort for a machine readable spec if you all think it is worthwhile.

@bwalderman
Copy link
Contributor

I played around with OpenRPC when writing the explainer. There's an example here. I ran into some minor issues. The spec supports only one-way calls (no concept of bidi) so I ended up using tags to mark things as either "events" or "commands". The tooling support also seems pretty limited. There's a code gen tool but this supports only TypeScript and Rust at the moment.

AsyncAPI looks promising instead. It's more generic and can express both HTTP and WebSocket transports in the same file. It also has proper support for bidi communication through "channels".

@foolip
Copy link
Member

foolip commented May 28, 2020

In the initial conversion for this I'd try to have as few visual and markup changes possible, as looking for differences is the best way to catch mistakes. I wouldn't want to make any deliberate change at all, even typo fixes, in that initial change.

@christian-bromann @bwalderman I suspect you're mostly interested in machine readable for bidi, right? Can you file an issue for that? If you'd like the main webdriver spec to also be more machine readable, an issue for that would be great too.

@foolip
Copy link
Member

foolip commented May 29, 2020

I've filed #1510 and w3c/webdriver-bidi#21 for machine readable definitions for the REST and BiDi protocols, respectively.

foolip added a commit that referenced this issue May 29, 2020
Per discussion in speced/bikeshed#1682.

This is mainly to minimize changes in #1462.
AutomatedTester pushed a commit that referenced this issue May 29, 2020
Per discussion in speced/bikeshed#1682.

This is mainly to minimize changes in #1462.
@foolip foolip linked a pull request May 29, 2020 that will close this issue
foolip added a commit to foolip/webdriver that referenced this issue Jun 2, 2020
Discovered as part of w3c#1462.

It doesn't matter in ReSpec because the <section> nesting level is used,
but Bikeshed does not use the HTML outline algorithm:
https://tabatkins.github.io/bikeshed/#table-of-contents
foolip added a commit to foolip/webdriver that referenced this issue Jun 2, 2020
Discovered as part of w3c#1462.

It doesn't matter in ReSpec because the <section> nesting level is used,
but Bikeshed does not use the HTML outline algorithm:
https://tabatkins.github.io/bikeshed/#table-of-contents
AutomatedTester pushed a commit that referenced this issue Jun 2, 2020
Discovered as part of #1462.

It doesn't matter in ReSpec because the <section> nesting level is used,
but Bikeshed does not use the HTML outline algorithm:
https://tabatkins.github.io/bikeshed/#table-of-contents
@foolip
Copy link
Member

foolip commented Jun 2, 2020

I'd like to ask the input of regular WebDriver spec contributors about ID stability. Given a definition like <dfn>a thing</dfn>, ReSpec will generate id=dfn-a-thing while Bikeshed will generate id=a-thing, i.e., ReSpec prepends dfn-. IDs can be provided manually in both cases, of course.

Preserving all IDs is possible, but would make the source fairly verbose. I'd therefore like to suggest allowing a lot of IDs to change, while making an effort to not break links. One thing we can do is create a mapping of IDs to be checked client-side in JS. HTML does some stuff like this.

The most important thing is to not break links from other specs. Using reffy-reports and Bikeshed's tests there are the specs that link to WebDriver that I can find:

My questions:

  • Are there other places with incoming links that should be checked?
  • If we're confident enough that the important incoming links have been accounted for, is it OK to drop a lot of IDs?
  • Would taking care of the remainder with JS be OK, or will it get in the way of publishing to /TR/ later?

foolip added a commit to web-platform-tests/wpt that referenced this issue Jun 2, 2020
Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
foolip added a commit to web-platform-tests/wpt that referenced this issue Jun 2, 2020
Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jun 8, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911
xeonchen pushed a commit to xeonchen/gecko that referenced this issue Jun 8, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jun 9, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

Differential Revision: https://phabricator.services.mozilla.com/D78794
xeonchen pushed a commit to xeonchen/gecko that referenced this issue Jun 9, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

Differential Revision: https://phabricator.services.mozilla.com/D78794
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jun 10, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

Differential Revision: https://phabricator.services.mozilla.com/D78794
xeonchen pushed a commit to xeonchen/gecko that referenced this issue Jun 10, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

Differential Revision: https://phabricator.services.mozilla.com/D78794
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Jun 11, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

UltraBlame original commit: 4ea9d35d56d9cba2e0711df3986b340168bed03c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Jun 11, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

Differential Revision: https://phabricator.services.mozilla.com/D78794

UltraBlame original commit: ed8cbf0c075c028dded58fa3192cd8965f9f37a0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Jun 11, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

Differential Revision: https://phabricator.services.mozilla.com/D78794

UltraBlame original commit: 6572082b695a7a149a6a715b1cb26f9982ec394b
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Jun 12, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

UltraBlame original commit: 4ea9d35d56d9cba2e0711df3986b340168bed03c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Jun 12, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

Differential Revision: https://phabricator.services.mozilla.com/D78794

UltraBlame original commit: ed8cbf0c075c028dded58fa3192cd8965f9f37a0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Jun 12, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

Differential Revision: https://phabricator.services.mozilla.com/D78794

UltraBlame original commit: 6572082b695a7a149a6a715b1cb26f9982ec394b
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Jun 12, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

UltraBlame original commit: 4ea9d35d56d9cba2e0711df3986b340168bed03c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Jun 12, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

Differential Revision: https://phabricator.services.mozilla.com/D78794

UltraBlame original commit: ed8cbf0c075c028dded58fa3192cd8965f9f37a0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Jun 12, 2020
…he WebDriver spec, a=testonly

Automatic update from web-platform-tests
[webdriver] normalize and fix links to the WebDriver spec (#23911)

Spotted while looking for incoming links to the spec:
w3c/webdriver#1462 (comment)

(#dfn-set-window-rect changed to #set-window-rect for consistency, not
to enable the ID to be changed.)
--

wpt-commits: 5d0dcf0142d07916584db9c76c2fdec02833e959
wpt-pr: 23911

Differential Revision: https://phabricator.services.mozilla.com/D78794

UltraBlame original commit: 6572082b695a7a149a6a715b1cb26f9982ec394b
@marcoscaceres
Copy link
Member

So, obviously I'm super biased (as I maintain ReSpec), but I don't see any advantage to using BS over ReSpec. ReSpec supports the same cross referencing features are BikeShed, and it's really a group's choice if they enable GitHub pages or not for a spec (you don't need to use a browser to transform the output - or let anyone in a browser view ReSpec document... you can generate a static snapshot in exactly the same manner as BikeShed does).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants