Skip to content

Conversation

QuietMisdreavus
Copy link
Contributor

Bug/issue #, if applicable: rdar://129338238, swiftlang/swift-docc-symbolkit#97

Summary

This PR updates Swift-DocC to render constraint information for sameShape constraints, as received from SymbolKit. sameShape constraints are used in functions with parameter packs, to ensure that the packs have the same length and/or type data.

Dependencies

swiftlang/swift-docc-symbolkit#103

Testing

Generate a symbol graph for a function that uses multiple parameter packs, such as this one from the above-linked issue:

public func function<each Element0, each Element1>(
  _: (repeat (each Element0, each Element1))
) { }

Steps:

  1. swift run docc convert /path/to/test.docc
  2. Ensure that Swift-DocC successfully builds documentation without crashing.

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

}

func testRenderSameShape() async throws {
let (_, bundle, context) = try await testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { bundleURL in
Copy link
Contributor

@d-ronnqvist d-ronnqvist Sep 15, 2025

Choose a reason for hiding this comment

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

Don't use this test fixture in new tests.

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.

We don't use "LegacyBundle_DoNotUseInNewTests" in new tests. Please create a new minimal tests setup that reproduces the problem and use that in the test instead.

@QuietMisdreavus
Copy link
Contributor Author

It looks like DocC doesn't use constraint information directly from a symbol (instead only sourcing it from extensions), and Swift places sameShape constraints there, so the test will have to be a "run this and don't crash" situation.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@d-ronnqvist
Copy link
Contributor

It looks like DocC doesn't use constraint information directly from a symbol (instead only sourcing it from extensions), and Swift places sameShape constraints there, so the test will have to be a "run this and don't crash" situation.

Is there some place where it would make sense to display this information on the page? That would both help us verify that DocC handles this type of constraint and would communicate that information to the reader.

case .conformance: return "conforms to"
case .sameType: return "is"
case .superclass: return "inherits"
case .sameShape: return "is the same shape as"
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering that we this user-facing text. Should this PR also display that somewhere?

)!

let catalog = Folder(name: "unit-test.docc", content: [
InfoPlist(displayName: "SameShapeConstraint", identifier: "com.test.example"),
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: this isn't needed

Suggested change
InfoPlist(displayName: "SameShapeConstraint", identifier: "com.test.example"),

@QuietMisdreavus
Copy link
Contributor Author

Is there some place where it would make sense to display this information on the page?

It would probably make sense to insert conditionals like this as part of the declarations section or something like that. I don't think Swift-DocC-Render is equipped to display conformance information there, though, so an update to display this data would also require an update there.

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.

LGTM

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