Skip to content

Use a more detailed page type for C++ namespaces in navigator index #817

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

Conversation

mportiz08
Copy link
Contributor

Bug/issue #, if applicable: 122340677

Summary

This adds a new namespace case to the NavigatorIndex.PageType enum that can be used in RenderIndex to emit a more specific "namespace" page type instead of a generic "symbol" type in the Render Index JSON.

This is needed so that Swift-DocC-Render can distinguish namespaces from other generic symbols in the navigator and render them appropriately, like choosing an icon that is specific to namespaces.

Testing

Steps:

  1. Run swift run docc convert Tests/SwiftDocCTests/Test\ Bundles/CxxSymbols.docc
  2. Verify that the node for the Foo namespace symbol in Tests/SwiftDocCTests/Test\ Bundles/CxxSymbols.docc/.docc-build/index/index.json now has a type value of "namespace" and not "symbol"

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

Copy link
Contributor

@d-ronnqvist d-ronnqvist left a comment

Choose a reason for hiding this comment

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

Looks good to me. I would just ask that we continue to be defined the page type enum cases in the order of their raw value.

@@ -309,6 +309,9 @@ public class NavigatorIndex {
case languageGroup = 127
case container = 254
case groupMarker = 255 // UInt8.max

// C++ symbols
case namespace = 48
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for how these enum cases are organized, please add this case above the special items so that the cases continue to be defined in the order of their raw value.

Copy link
Contributor

Choose a reason for hiding this comment

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

I also believe that this is a source breaking change since any existing code that was switching over this public enum now has a new case that it would need to handle. Maybe there's nothing we can do about it but it's worth calling mentioning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just for how these enum cases are organized, please add this case above the special items so that the cases continue to be defined in the order of their raw value.

420502e

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also believe that this is a source breaking change since any existing code that was switching over this public enum now has a new case that it would need to handle. Maybe there's nothing we can do about it but it's worth calling mentioning.

Are you aware of any way to do this in a non source breaking manner?

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately I don't know of any other way. If we need to make a source breaking change it might be worth discussing if we should make a larger change now so that future changes can be made in a non-source breaking manner.

@d-ronnqvist d-ronnqvist added the source breaking DocC's public API isn't source compatible with earlier versions label Feb 6, 2024
Copy link
Contributor

@daniel-grumberg daniel-grumberg left a comment

Choose a reason for hiding this comment

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

I think it's OK to break source compatibility here.

@d-ronnqvist
Copy link
Contributor

I think it's OK to break source compatibility here.

@daniel-grumberg Do you think that we should add something like this _nonfrozenEnum_useDefaultCase case to signal to clients that this enum may get additional cases again in the future or do you think it's unlikely that we'll add any other cases to this enum in the future?

@daniel-grumberg
Copy link
Contributor

daniel-grumberg commented Feb 16, 2024

I think it's OK to break source compatibility here.

@daniel-grumberg Do you think that we should add something like this _nonfrozenEnum_useDefaultCase case to signal to clients that this enum may get additional cases again in the future or do you think it's unlikely that we'll add any other cases to this enum in the future?

I think that would be a great idea but let's do it as a follow up patch.

@daniel-grumberg
Copy link
Contributor

@swift-ci please test

@d-ronnqvist
Copy link
Contributor

@swift-ci please test

@d-ronnqvist d-ronnqvist merged commit 31456c4 into swiftlang:main Feb 16, 2024
@mportiz08 mportiz08 deleted the use-more-explicit-type-for-namespaces-in-navigator-index branch February 16, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source breaking DocC's public API isn't source compatible with earlier versions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants