I’m interested in discussing with others here the utility (and feasibility) of having the MDN API provide data for all specs that are linked to in Specifications tables in MDN articles.
I filed an enhancement request/issue here:
Quoting that issue’s description:
A concrete use case for this data is, I want to add annotations in the HTML spec for all defined terms in the spec which have a corresponding MDN article that contains a Specifications table with a link to that term’s URL (with fragment).
Currently, lacking a way to use the MDN API to get that, I need to crawl the MDN site and parse/scrape articles in order to the data and put it into a form I can use in the build process that generates the published HTML spec.
If the MDN API provided the data, I wouldn’t need to do that crawling/scraping.
Here’s a proposed JSON format for the structure of the exposed data:
{
"https://html.spec.whatwg.org/multipage/#2dcontext": [
{
"path": "API/CanvasRenderingContext2D",
"title": "CanvasRenderingContext2D",
"summary": "The CanvasRenderingContext2D interface is used for…"
},
{
"path": "API/Canvas_API",
"title": "Canvas API",
"summary": "Added in HTML5, the HTML <canvas> element can be…"
}
],
"https://html.spec.whatwg.org/multipage/#abstractworker": [
{
"path": "API/AbstractWorker",
"title": "AbstractWorker",
"summary": "The AbstractWorker interface…"
}
],
So the structure is:
- the JSON object has spec URLs as keys
- the value for each key is an array containing an item for each MDN article that has a Specifications link to that spec URL
- each item in the array is an object with “
path
”, “title
” and “summary
” keys - the “
path
” value is a URL segment for that article’s path within the https://developer.mozilla.org/en-US/docs/Web/ tree - the “
title
” value is the article’s display title - the “
summary
” value is the article’sclass=seoSummary
content — or, if the article has noclass=seoSummary
, the contents of the article’s first non-empty paragraph
Of course the data would not just have https://html.spec.whatwg.org/ spec URLs, but would also have URLs for referenced terms in CSS, etc., specs too.