Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.

Reveal BCD ID in rendered HTML#1247

Merged
escattone merged 3 commits intomdn:masterfrom
peterbe:1238-reveal-bcd-id-in-rendered-html
Sep 25, 2019
Merged

Reveal BCD ID in rendered HTML#1247
escattone merged 3 commits intomdn:masterfrom
peterbe:1238-reveal-bcd-id-in-rendered-html

Conversation

@peterbe
Copy link
Copy Markdown
Contributor

@peterbe peterbe commented Sep 24, 2019

Fixes #1238

I just made the change without knowing how to test this in kuma. Also, I don't know if identifier is the right string :)
But the goal is to be able to do something like this:

from pyquery import PyQuery as pq
doc = pq("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video")
for wrapper in doc('div.bcd-data').items():
    print(wrapper.data('bcd-id'))
    break
else:
    print("Has no BCD data table!")

and that should print the identifier that is equivalent to what we put in the front-matter of https://github.com/mdn/stumptown-content/blob/master/content/html/reference/elements/video/docs.md

PS. I don't know how to write and run unit tests for KS.

@peterbe peterbe requested a review from Elchi3 September 24, 2019 15:59
@peterbe
Copy link
Copy Markdown
Contributor Author

peterbe commented Sep 24, 2019

The context for this is to be able to use the Document JSON API and get that identifier out. The Document JSON API has a key which is the rendered body HTML which we can parse and pick apart.
The other objective is the scrape-mdn.js project in stumptown-content which needs this identifier to be able to create the right front-matter from an MDN URL.

Comment thread macros/Compat.ejs Outdated
Comment thread macros/Compat.ejs Outdated
@peterbe
Copy link
Copy Markdown
Contributor Author

peterbe commented Sep 25, 2019

I tested this manually now. In Kuma and sure enough it's there:

<div class="bc-data" id="bcd:html.elements.details">

@escattone escattone merged commit 6bde85f into mdn:master Sep 25, 2019
@peterbe peterbe deleted the 1238-reveal-bcd-id-in-rendered-html branch September 25, 2019 16:19
@peterbe
Copy link
Copy Markdown
Contributor Author

peterbe commented Sep 25, 2019

FYI @escattone perhaps we should set up that thing we have in kuma so that we always use the "Squash and rebase" thing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reveal BCD ID in rendered HTML

3 participants