Skip to content

Conversation

@mportiz08
Copy link
Contributor

Bug/issue #, if applicable: 108472125

Summary

This adds support for rendering certain attribute tokens as links to symbols instead of just plaintext.

As a basic example, DocC would generate a linkable @StringBuilder token in the contrived buildABC function here:

@resultBuilder
public struct StringBuilder {
  static func buildBlock(_ parts: String...) -> String {
    parts.joined(separator: "\n")
  }
}

@StringBuilder public func buildABC() -> String {
  "a"
  "b"
  "c"
}

Dependencies

swiftlang/swift#63637

Testing

To test this using swift-docc-plugin, you may need a recent 5.9 toolchain version of Swift to ensure that the symbol graph tokens get generated with the data for linking (see above dependency).

Steps:

  1. Build this branch with npm run build
  2. Preview docs for an example package that has an example like the one above with env DOCC_HTML_DIR=/path/to/dist swift package --disable-sandbox preview-documentation --target [target]
  3. Verify that the example attribute can be clicked in a declaration, which should take you to that symbol page.

Here is an example package (target "AttributeExamples") that has the @StringBuilder example code from above:
AttributeExamples.zip

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

Copy link
Contributor

@dobromir-hristov dobromir-hristov left a comment

Choose a reason for hiding this comment

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

Changes look good to be, havent tested yet with docc branch.

Copy link
Contributor

@hqhhuang hqhhuang 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!

@mportiz08
Copy link
Contributor Author

@swift-ci test

@mportiz08 mportiz08 merged commit dc7d0bb into swiftlang:main May 5, 2023
@mportiz08 mportiz08 deleted the support-linkable-attributes branch May 5, 2023 17:59
mportiz08 added a commit to mportiz08/swift-docc-render that referenced this pull request May 5, 2023
mportiz08 added a commit that referenced this pull request May 9, 2023
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