Skip to content
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

Match documentation extensions to symbols using link resolver #565

Merged

Conversation

d-ronnqvist
Copy link
Contributor

@d-ronnqvist d-ronnqvist commented Apr 25, 2023

Bug/issue #, if applicable:

Summary

This uses the link resolver to match documentation extensions with symbols. This allows for using link resolution features in documentation extension title links. For example:

  • Documentation extension title links can now omit disambiguation when the colliding paths have different capitalization
  • Documentation extension title links can now contain special characters
  • Documentation extension title links can now omit the leading module name when the bundle only contains one module
  • Documentation extension title links can now use Swift or Objective-C symbol names to extend the documentation for a symbol that's available in both languages
  • Documentation extension title links that don't match any known symbol now result in a warning with the same rich information as other unresolved symbol links.

Dependencies

None

Testing

In a Swift package with a documentation catalog;

  • Add code where two symbols have the same case insensitive name:

    public struct Outer {
        public enum Inner {}
        public var inner: Inner
    }
    
  • Add a documentation extension file and link to one of the symbols without prefixing with the module and without disambiguation:

    # ``Outer/Inner``
    
    Some documentation extension content here.
    

    The content of this documentation extension file should be included on the documentation page for the Inner enumeration.

  • Add another documentation extension file and link to a symbol that doesn't exist in the module:

    # ``ThisDoesNotExist``
    
    This should result in a warning
    

    There should be a warning saying that the module doesn't contain a "ThisDoesNotExist" symbol.

  • Add another documentation extension file and link to first symbol but make the symbol link more spelled out:

    # ``MyModule/Outer/Inner-enum``
    
    This symbol already has a documentation extension elsewhere
    

    There should be a warning saying that multiple documentation extension files match the Inner enumeration.

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

@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist d-ronnqvist merged commit a85f999 into swiftlang:main Apr 27, 2023
@d-ronnqvist d-ronnqvist deleted the match-doc-extension-with-link-resolver branch April 27, 2023 15:51
d-ronnqvist added a commit to d-ronnqvist/swift-docc that referenced this pull request Apr 27, 2023
…ang#565)

* Use link resolution to match documentation extensions with symbols

Also, fix incorrect source url in technology root diagnostic

rdar://108392613

* Add test for matching language specific documentation extension links

* Allow documentation extension links to resolve relative to the module

rdar://76252171

* Warn when a documentation extension doesn't match a symbol

rdar://108392639

* Expect different behavior in tests when the old link resolver is used

* Restore old implementation detail for ConvertService only

* Restore test assertion about documentation extension in asset store
d-ronnqvist added a commit that referenced this pull request Apr 27, 2023
…569)

* Use link resolution to match documentation extensions with symbols

Also, fix incorrect source url in technology root diagnostic

rdar://108392613

* Add test for matching language specific documentation extension links

* Allow documentation extension links to resolve relative to the module

rdar://76252171

* Warn when a documentation extension doesn't match a symbol

rdar://108392639

* Expect different behavior in tests when the old link resolver is used

* Restore old implementation detail for ConvertService only

* Restore test assertion about documentation extension in asset store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants