I’ve been thinking lately about ways we could provide small amounts of added data that would make the information we already provide easier to interpret in ever more useful ways.
Feature/subfeature type guidance
First, I think we ought to add a type
or kind
field to features that would let us specify the kind of feature that’s being described. This field would take values such as these (in the API JSON; the appropriate values would need to be decided, if needed at all, for the others):
- For top-level features:
interface
typedef
enum
class
constant
- For sub-features:
method
property
constant
constructor
This would let us avoid having to do things like manually add description
fields to provide proper styling for entries in compatibility tables (proper styling that may be MDN-specific).
Using substitutions to avoid MDN-specific styling
Currently, when we do things like write information in the note
field, we tend to do things like embed HTML to do things like include links, style the name of interfaces and methods, and so forth. We could avoid this by adding the ability to use some simple substitutions. The client making use of the data would then apply the appropriate substitution, optionally adding appropriate styles.
This way, MDN could add <code>...</code>
around things like we do, while other BCD clients could use their preferred styling.
More importantly, we could use this in concert with the first idea (adding types to BCD entries) to automatically add parentheses to function names and such at the same time, to get the presentation just the way we want it, while other clients, again, could choose to do so or not.
Even better, this makes it relatively trivial for clients to change up their style rules over time, because the substitutions would be getting done somewhere other than in the content itself, so they’d simple re-render content after updating their code and the output would all get updated accordingly.