-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Move MDN feature table rendering to BCD project #1392
Comments
Draft API: const bcd = require('mdn-browser-compat-data');
/* Generate default HTML for development */
let html = bcd.render(
bcd.webextensions.api.alarms,
bcd.renderers.mdnFeatureTable);
/* Alter behaviour by passing in configuration object */
let fancyHtml = bcd.render(
bcd.webextensions.api.alarms,
bcd.renderers.mdnFeatureTable,
{'style': 'fancy'} /* TODO: write fancy version */
);
/* Equivalent calls */
/* Call renderer directly */
let html = bcd.renderers.mdnFeatureTable(bcd.webextensions.api.alarms);
/* Call with strings */
let html = bcd.render(
'webextensions.api.alarms', /* Data is assumed to be BCD path */
'mdnFeatureTable'); /* Renderer is assumed to be in bcd.renderers */
/* Generate HTML for display on MDN */
const l10nStrings = {
'no-data-found': {
'en-US': 'No compatibility data found.',
'es': 'No se han encontrado datos de compatibilidad.'
} /*, more localized strings */
};
let mdnHTML = bcd.render(
bcd.webextensions.api.alarms,
bcd.renderers.mdnFeatureTable,
{'locale': 'es',
'strings': l10nStrings,
'inBeta': true
}
);
/* Generate aggregate tables */
mdnData = require('mdn-data');
let aggregateHTML = bcd.render(
bcd.css,
bcd.renderers.mdnAggregateTable,
{
'properties': mdnData.css.properties,
'group': 'CSS Grid Layout'
}); |
So we thought a bit more about this: What do we want?
How do we want it?Currently we have two ways of rendering a Compatibility Table on two differents codebase. We have 0 lines of codes in the packaged version of BCD. (It is a pure dataset). Our idea would be to generify the code that generates the HTML so it can be called easily. This module would expose
This new module would depend on Expected ResultsAn independent renderer modules able to render the HTML table that would be used by Kumascript and by another tool that needs to render a Compatibility Tables such as a Github Bot that would comment on PR with the tables. |
We've started a new repo, https://github.com/mdn/browser-compat-toolkit, for the source code tools we're maintaining related to this data. @flaki has been doing some interesting work with the rendering code that may be appropriate in that repo. |
Closing this as the current thoughts have quite evolved from the original issue title and I'm in favor of having this repo to be just about the data itself. Thanks for starting the new repo, I hope it will be used by BCD and MDN at some point so that we have a canonical MDN renderer repo the community can easily contribute to. |
I believe future contributors will be thinking "This part of the compatibility table on MDN is wrong, I want to fix it". It will be useful for these contributors as well as the reviewers to be able to see what the MDN table will looks like after a pull request is merged. This means that BCD contributors will want to be able to generate MDN tables.
Currently, MDN feature tables are rendered in the KumaScript macro Compat, such as
{{compat("webextensions.api.alarms")}}
. The core of this logic can be moved to this repository, so that BCD authors can generate MDN tables. The{{Compat}}
macro can then focus on adding additional data, such as localizations, legacy tables, and links back to the BCD project.The text was updated successfully, but these errors were encountered: