Add support for variant overrides #10
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug/issue #, if applicable: 82968068
Summary
Adds renderer support for the newly introduced
variantOverrideskey in DocC Render JSON, which allows for using the same JSON file to represent documentation data for a symbol which is available in more than one variant—most commonly for a symbol available in both Swift and Objective-C languages.For symbols available in both Swift/Objective-C, there will now be an affordance in the sidebar that can be used to toggle between the current language.
Example:
Details
As described in swiftlang/swift-docc#11, the
variantOverridesdata may contain overrides for a given variant expressed as a JSON Patch—this patch can be applied to the Render JSON to obtain the language specific version of any data that may be rendered on the page. When this overrides data is available for a Swift symbol that is also available in Objective-C, the language toggle will be presented and used to switch between the different page data.Dependencies
swiftlang/swift-docc#11
Testing
Using fake example fixture data, verify that the language toggle is presented and can be used.
Steps:
VUE_APP_DEV_SERVER_PROXY=/path/to/exampleand runnpm run serve.init(fileURLWithPath:)toinitFileURLWithPath:init(fileURLWithPath path: String)to- (instancetype)initFileURLWithPath:(NSString *)path;Also verify that an existing documentation bundle renders in the same way that it normally does—the language toggle will only be used going forward when
variantOverridesdata is provided and these changes should otherwise be backwards compatible with older Render JSON.Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
npm test, and it succeeded