Skip to content

WIP: Implement feature imports#1799

Closed
ExE-Boss wants to merge 2 commits intomdn:masterfrom
ExE-Boss:schema/feature-imports
Closed

WIP: Implement feature imports#1799
ExE-Boss wants to merge 2 commits intomdn:masterfrom
ExE-Boss:schema/feature-imports

Conversation

@ExE-Boss
Copy link
Contributor

@ExE-Boss ExE-Boss commented Apr 17, 2018

Fixes #813
Closes #1681

This works by having an extra __import block, which contains the features you wish to import and the optional __as key, which is used to rename the imported feature and optional entries which override the imported data.

Cycles and infinite recursion are currently allowed if imported data isn’t overriden. They might also work if imported data is overriden depending on how the extend package deals with cycles and infinite recursion.

"__import": {
  "<ref_to_import>": {
    // Override stuff here when necessary.
  }
}

To do:

  • Implement global tests
  • Implement per-file tests
  • Update documentation

@Elchi3 Elchi3 added schema Isses or pull requests regarding the JSON schema files used in this project. infra Infrastructure issues (npm, GitHub Actions, releases) of this project labels Apr 17, 2018
@connorshea
Copy link
Contributor

Just to be clear, this still ends up exporting the same data for the npm package and only effects the source code right?

I'd rather avoid having to parse references to other features in my app that consumes the data :)

@ExE-Boss
Copy link
Contributor Author

Yes, this only affects the source code, as the data exported in the npm package is already pre-parsed (although, you’ll have to watch for infinite recursion and cycles if the implementation gets merged as-is).

@ExE-Boss ExE-Boss mentioned this pull request May 29, 2018
@ExE-Boss ExE-Boss changed the title Implement feature imports WIP: Implement feature imports Aug 16, 2018
@a2sheppy
Copy link
Contributor

Any possibility we could come up with a way to allow merging of information? Consider this potential use case:

  • Create HTMLInputElement.json with only the members that are in all input elements.
  • Create a separate HTMLInputElement-type.json file for each input type, containing the items that are specific to them, or for which there is information needed beyond what's included in the main HTMLInputElement.json file.
  • Have HTMLInputElement.json import all of the -type files, with entries that have the same name merged with some appropriate formatting, such as little boxes, footnotes, subheadings or whatever.
  • Allow the HTMLInputElement-type.json files to indicate that they are based on HTMLInputElement.json. "Based on" means that they include the items that are directly in HTMLInputElement.json, but not any imported files it references.

This lets us create the JSON in a less confusing way while giving us much more control over how the results look. We could even export from the tools that build the files from the imports separate files for each input element type that could be referenced by tools that know how to do so, if we wanted to.

@a2sheppy
Copy link
Contributor

@ExE-Boss -- Do you have any examples for what the ref_to_import looks like? Is it a feature path just like we already use ("api.SomeInterface.method.feature")?

@ExE-Boss
Copy link
Contributor Author

It is currently just a feature path, as can be seen in the sample data:

"__import": {
"sample.api.onlyBasicSupport": {},
"sample.api.featureWithSubfeatures.chocoCookie": {
"__as": "superChocoCookie"
}
},
"recursiveImport": {
"__import": {
"sample.api.featureWithImports.recursiveImport": {}
}
},
"cyclicalImport": {
"a": {
"__import": {
"sample.api.featureWithImports.cyclicalImport.b": {}
}
},
"b": {
"__import": {
"sample.api.featureWithImports.cyclicalImport.a": {}
}
}
}

@a2sheppy
Copy link
Contributor

a2sheppy commented Sep 20, 2018 via email

@a2sheppy
Copy link
Contributor

a2sheppy commented Jan 8, 2019

Any chance we're actually going somewhere with this? I ask because I have stuff that I've been keeping on hold pending this landing and I don't know how long I should keep waiting.

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Jan 8, 2019

#2487 will have to be merged first to avoid merge conflicts.

@queengooborg
Copy link
Contributor

@ExE-Boss Looks like that PR has been merged now. I'm eager to see this PR get merged -- would you be up for rebasing?

@Elchi3 Elchi3 added the not ready This is not yet ready to be merged. It's pending a decision, other PR, or a prerequisite action. label Feb 4, 2019
@Elchi3
Copy link
Member

Elchi3 commented Feb 4, 2019

Thanks for your enthusiasm @vinyldarkscratch but I don't see this landing anytime soon from a maintainer's point of view. It would be a major change to how we have the data stored here and I don't think we're ready to make this change just yet. I will let you know when we want to revisit this. :)

"__compat": {
"description": "This sub-feature has imports",
"support": {
"webview_android": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be last, not first.

Copy link
Contributor Author

@ExE-Boss ExE-Boss Feb 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was written before work on #1882 began.

@queengooborg
Copy link
Contributor

Sounds like a plan, @Elchi3! I am indeed pretty eager for this, haha -- whilst going through the JSON I've run into instances where an import would be more than helpful. Looking forward to seeing this complete and merged!

@a2sheppy
Copy link
Contributor

a2sheppy commented Feb 4, 2019

Yeah, I have updates to BCD that are holding for this to land because otherwise the repetitiveness would be ugly :)

@Elchi3
Copy link
Member

Elchi3 commented Apr 10, 2019

Bulk data updates through external sources and scripts are our preferred approach to better compat data right now and we're not currently considering de-duplicating version data. Therefore I'm closing this issue. Thanks for your thoughts here! Maybe we will reconsider this idea at a later stage.

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

Labels

infra Infrastructure issues (npm, GitHub Actions, releases) of this project not ready This is not yet ready to be merged. It's pending a decision, other PR, or a prerequisite action. schema Isses or pull requests regarding the JSON schema files used in this project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants