-
Notifications
You must be signed in to change notification settings - Fork 17
Support 'generated.status' in build-json #354
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I've left one line comment concerning a finer point of the BCD schema, but it's not a big thing. Thank you, Will!
scripts/build-json/resolve-status.js
Outdated
@@ -0,0 +1,12 @@ | |||
function packageStatus(specifications, bcd) { | |||
const bcdHasStatus = !!bcd.__compat && !!bcd.__compat.status; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!!
is a bit cryptic. I'd prefer something more explicit here (bcd.__compat !== undefined
or whatever we're getting at).
Also, the BCD schema requires __compat
to have a status
object. Seems like we should be able to trust BCD to not break Stumptown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the BCD schema requires __compat to have a status object. Seems like we should be able to trust BCD to not break Stumptown.
Oh, then the docs are wrong: https://github.com/mdn/browser-compat-data/blob/master/schemas/compat-data-schema.md#the-__compat-object and https://github.com/mdn/browser-compat-data/blob/master/schemas/compat-data-schema.md#status-information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ddbeck ! I'm glad BCD mandates status
, and have correspondingly tried to simplify this bit of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course this really wants optional chaining (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) but that's not in Node yet apparently.
Co-Authored-By: Daniel D. Beck <daniel@ddbeck.com>
So we can visually check the rendered banners, I added a fake JS class "TestBanners", which borrows the compat data from I've had to give them the I've also filed mdn/yari#380 for the renderer side, in case you want to see what it looks like. |
@ddbeck , in mdn/yari#380, @peterbe asked for us to represent It also omits I know it seems/is pointless, but I'd appreciate a review if you have time, so we can close this issue. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's fine. I follow why it makes a difference (something about waste? I didn't get it), but I can still follow the semantics of an array on this side, so it works. 👍
This PR addresses the content side of supporting banners/headers, as tracked by #306.
It adds support for a new
status
ingredient. Its value is derived from thespecifications
andbrowser-compatibility
properties, so is made a new sort of ingredient,generated
: which means it appears in recipes but not in front matter: writers explicitly don't have to worry about it.This is from @ddbeck 's suggestion here: #306 (comment).
It's a bit inefficient because it queries the BCD twice for the data. But I think this is pretty quick and it didn't really seem worth caching it, just for this. But maybe it is? But anyway I don't want to cache all the BCD query lookups, as we do for
related_content
, because unlikerelated_content
, BCD JSONs are not typically shared between different pages.It'll add a new JSON object like:
...placed at the start of the
body
: