Skip to content

Conversation

@mportiz08
Copy link
Contributor

Bug/issue #, if applicable: 82968068

Summary

Adds renderer support for the newly introduced variantOverrides key 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:

demo

Details

As described in swiftlang/swift-docc#11, the variantOverrides data 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:

  1. Download/unzip example.zip
  2. Configure VUE_APP_DEV_SERVER_PROXY=/path/to/example and run npm run serve.
  3. Load the example page at http://localhost:8080/documentation/mykit/myclass and note that there is now a language toggle in the sidebar.
  4. Note that "Swift" is not a link and click the "Objective-C" link.
  5. Verify that the following changes have been made to the page:
  • "Objective-C" is no longer a link and "Swift" is
  • the page title changes from init(fileURLWithPath:) to initFileURLWithPath:
  • the declaration changes from init(fileURLWithPath path: String) to - (instancetype)initFileURLWithPath:(NSString *)path;
  • the last link in the first "Topics" group changed from "myFunction in Swift" to "myFunction in Objective-C"
  • the abstract for the same link also changes in a similar way
  1. Verify that you can toggle back to Swift and see the original data.
  2. Toggle to Objective-C and close the web browser—then open the same browser and load http://localhost:8080/documentation/mykit/myclass again—verify that it switches to Objective-C (not expected to work in private window/tab or across different browsers)

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 variantOverrides data 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.

  • Added tests
  • Ran npm test, and it succeeded
  • Updated documentation if necessary

@mportiz08
Copy link
Contributor Author

@swift-ci test

@mportiz08
Copy link
Contributor Author

@swift-ci test

@mportiz08 mportiz08 merged commit 6a83cbe into swiftlang:main Oct 29, 2021
@mportiz08 mportiz08 deleted the support-variant-overrides branch October 29, 2021 23:47
hqhhuang referenced this pull request in hqhhuang/swift-docc-render Mar 11, 2022
New Hero/Introduction section design: Remove Dark Hero from symbol pages

Fixes: rdar://89970711
mportiz08 pushed a commit to mportiz08/swift-docc-render that referenced this pull request Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants