Skip to content

Conversation

@QuietMisdreavus
Copy link
Contributor

Bug/issue #, if applicable: rdar://93203894

Summary

Symbols for operator functions that include multiple dots (e.g. the
ClosedRange ... operator) are currently curated into an unnamed
"Implementations" section due to improper string splitting behavior.
This enhances the detection two ways:

  1. For symbols where the "source origin" is available in our given
    symbol graphs, it loads the name information from the parent symbol.
  2. For symbols where the "source origin" is not available, it improved
    the string splitting behavior by dropping empty-string components
    before reading names from it.

This allows Comparable and Equatable implementations to curate their
inherited operators properly.

Dependencies

None

Testing

Steps:

  1. Generate documentation for a module which includes a conformance to Comparable.
  2. Ensure that the Comparable range operators are correctly organized into a "Comparable Implementations" page.
  3. Repeat with a protocol that defines a custom ellipsis operator (e.g. the .... operator in the FancyProtocol symbol graph added in this PR).

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
  • [ n/a ] Updated documentation if necessary

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

// If we don't have a resolved `sourceOrigin` parent, fall back to parsing its display name

// Detect the path components of the providing the default implementation.
let typeComponents = originDisplayName.components(separatedBy: ".").filter({ !$0.isEmpty })
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: The default behavior of the Swift native String.split actually does this filtering for empty components automatically: https://developer.apple.com/documentation/swift/string/split(separator:maxsplits:omittingemptysubsequences:)

Suggested change
let typeComponents = originDisplayName.components(separatedBy: ".").filter({ !$0.isEmpty })
let typeComponents = originDisplayName.split(separator: ".")

Comment on lines 636 to 638
defer {
try? FileManager.default.removeItem(at: bundleURL)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: testBundleAndContext uses a test teardown block to remove any created temp files.

Suggested change
defer {
try? FileManager.default.removeItem(at: bundleURL)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should probably clean up all the other tests that use their own defer blocks, then; i was working off the pattern elsewhere in the file! 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I've started to clean it up as I encounter them. Here are some changes from my link resolution PR. That PR broke a lot of tests in the early stages of the integration 😅

@QuietMisdreavus
Copy link
Contributor Author

I've pushed up changes for the review comments.

@swift-ci Please test

Copy link
Contributor

@ethan-kusters ethan-kusters left a comment

Choose a reason for hiding this comment

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

Looks great. Thank you!!

@QuietMisdreavus
Copy link
Contributor Author

Rebased onto the latest main.

@swift-ci Please test

rdar://93203894

Symbols for operator functions that include multiple dots (e.g. the
ClosedRange `...` operator) are currently curated into an unnamed
"Implementations" section due to improper string splitting behavior.
This enhances the detection two ways:

1. For symbols where the "source origin" is available in our given
   symbol graphs, it loads the name information from the parent symbol.
2. For symbols where the "source origin" is not available, it improved
   the string splitting behavior by dropping empty-string components
   before reading names from it.

This allows Comparable and Equatable implementations to curate their
inherited operators properly.
@QuietMisdreavus
Copy link
Contributor Author

Rebased.

@swift-ci Please test

@QuietMisdreavus QuietMisdreavus merged commit 2f88d53 into swiftlang:main Jun 14, 2022
@QuietMisdreavus QuietMisdreavus deleted the origin-split branch June 14, 2022 16:45
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.

3 participants