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

sideshowbarker/support multiple bcd queries caugner rebased #6358

Closed
wants to merge 15 commits into from
Closed

sideshowbarker/support multiple bcd queries caugner rebased #6358

wants to merge 15 commits into from

Conversation

sideshowbarker
Copy link
Member

Summary

This extends #6004 to add handling for more cases discovered during testing.

Problem description (from #6004)

Previously, pages could only reference a single BCD query.

Solution (from #6004)

  1. Refactored document-extractor.js to use pure functions for BCD and Specifications.
  2. Extracted BCD_BROWSERS and BCD_BROWSER_RELEASES constants.
  3. Combine multiple BCD queries into a common hierarchy (96aa5e2).

Additional changes in this PR branch

  • Update Specifications section population to handle multiple BCD queries
  • Make the flaw checker understand multiple BCD queries
  • Handle browser-compat arrays that contain bad BCD feature IDs
  • Further update BCD table features population to handle multiple BCD queries
  • Prefix parent feature name to subfeatures in multiple-BCD-queries output

@sideshowbarker
Copy link
Member Author

sideshowbarker commented May 28, 2022

https://github.com/mdn/content/tree/sideshowbarker/api-spec-urls-browser-compat-array (mdn/content#16267) has all the existing docs with multiple BCD tables (multiple {{Compat}} macro calls) converted over to browser-compat YAML arrays.

It’s 52 60+ documents in all, and it’s what I’ve been using to test the Yari changes in this Yari PR branch.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 1, 2022

This pull request has merge conflicts that must be resolved before it can be merged.

caugner and others added 14 commits June 2, 2022 11:14
Without this change, when there are multiple BCD features, the
Specifications section won’t get populated as expected.

I tested this change and I believe it’ll work correctly  for all cases.

(And I think we can switch to Object.values rather than Object.entries,
because we only need the values, and don’t really need to do anything
with the keys.)
This adds some checks for “undefined” (which will happen when a
browser-compat array value contains any bad BCD feature ID).
…ueries

Some features — e.g., css.properties.justify-content — have no
compat data themselves but have subfeatures with compat data.
In the case where we’re processing a browser-compat value which is an
array — that is, multiple top-level features in one table (in contrast
to one feature and its subfeatures) — unless we explicitly check for the
__compat-less-feature-with-subfeatures case, and handle it, we can end
up with rows for expected features being entirely missing from the
rendered BCD table.

So this change adds handling for that case.
…CD queries

Some features — e.g., css.properties.justify-content — have no
compat data themselves but have subfeatures with compat data.
In the case where we’re processing a browser-compat value which is an
array — that is, multiple top-level features in one table (in contrast
to one feature and its subfeatures) — unless we explicitly check for the
__compat-less-feature-with-subfeatures case, and handle it, we can end
up with expected specifications being entirely missing from the rendered
Specifications section.

So this change adds handling for that case.
When we’re showing a row for a subfeature in a BCD table, the subfeature
name or description on its own may not provide enough context —
especially in the case where we have a BCD table with multiple top-level
features (that is, from a browser-compat value which is an array) — so
for that case, we show the (parent) feature name — acquired from the
current mdn_url value — as a prefix before the subfeature name/description.
In _getBCDData(queryString), the queryString value) can be, e.g.,
"html.elements.link.rel,html.elements.a.rel,html.elements.area.rel" for
the case where we’re processing multiple BCD queries. So as the key in
the data structure we create there and pass around to other parts of the
code, to ensure the key is unique, we use the full BCD query/feature
name rather than some portion of it.

Otherwise, if we use, e.g., just the part after the last dot, then for
the example above, that ends up being just 'rel' for all three 'query'
values from that full queryString value. And because 'rel' isn’t unique,
if we used it as the key in our internal data structure, then in each
iteration through the 'queryString', we’d end up setting a new value for
the 'rel' key — and clobbering whatever value the previous iteration set.

And then — to make things very clear — we pass around that key/property
to other parts of the code using the variable 'query' to identify it
(rather than 'name').

And then later, for the case when we’re processing multiple BCD 'query'
instances (BCD queries/features) in the part of the code that outputs
the rendered BCD table — where a shortened identifier is needed — we can
end up with duplicate identifiers being displayed unless we further
qualify them.

The query string "html.elements.label.for,html.elements.output.for", for
example, would result in a rendered BCD table that has just 'for' as the
feature name in each row. So in this case, we take the last _two_ parts
of the query/feature name — that is, e.g., 'label.for' and 'output.for'
— and display those in the rendered table.
This change adds an HTML “title” attribute too all BCD table row
headers, so that users can hover to see the full BCD feature name.

Otherwise, without this change, for some multiple-BCD-queries cases,
the displayed names of the features are the same; for example, consider
"css.properties.width.fit-content_function,css.properties.grid-template-columns.fit-content"
For the case of those two features, the displayed feature name for both
is just “fit-content()” — so there’s no way for users to distinguish
which row applies to which feature.

But with this change, users can hover the table row headers to see which
is for which.
@github-actions github-actions bot added flaw-system issues and feature requests related to the flaws system and removed merge conflicts 🚧 Please rebase onto or merge the latest main. labels Jun 2, 2022
@caugner caugner added the browser-compat issues related to the browser compatibility data tables (BCD) label Jun 3, 2022
@caugner
Copy link
Contributor

caugner commented Jun 3, 2022

Closing in favor of #6464.

@caugner caugner closed this Jun 3, 2022
@sideshowbarker sideshowbarker deleted the sideshowbarker/support-multiple-bcd-queries-caugner-rebased branch June 21, 2022 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser-compat issues related to the browser compatibility data tables (BCD) flaw-system issues and feature requests related to the flaws system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants