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

[SymbolGraphGen] Use shorter names for nested types #70592

Open
1 of 2 tasks
karwa opened this issue Nov 20, 2022 · 3 comments
Open
1 of 2 tasks

[SymbolGraphGen] Use shorter names for nested types #70592

karwa opened this issue Nov 20, 2022 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@karwa
Copy link
Contributor

karwa commented Nov 20, 2022

Description

If a type has nested types (e.g. a generic Collection with a nested Index type), then for any functions which accept or return that nested type, DocC writes out the full type name (e.g. Foo<X>.Index). Even on Foo<X>'s own documentation page.

For example, on the documentation page for WebURL.KeyValuePairs<Schema>, the index type is written out in full:

image

This leads to poor readability. Actually trying to understand what these functions do requires careful examination of their signatures (especially the 3rd and 4th functions, as they wrap across multiple lines).

If I go in the web inspector and shorten these names to demonstrate what they could look like, I think you'll agree that it's much easier to digest what these functions do:

image

It's a shame. Clearly, these function signatures are not all that complex, but the presentation in the first image makes them appear unwieldy and intimidating. This is how I wrote it in my code; I just used the name Index, and since it was in the scope of the KeyValuePairs type, the compiler knew I was talking about WebURL.KeyValuePairs<Schema>.Index.

I think it's important for DocC to present these functions in the clearest possible way, so I would like it to avoid qualifying type names which are already obvious based on context.

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue.

Expected Behavior

No response

Actual behavior

No response

Steps To Reproduce

No response

Swift-DocC Version Information

Xcode 14.1 (14B47b)

Swift Compiler Version Information

swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
Target: x86_64-apple-macosx12.0
@karwa karwa added the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label Nov 20, 2022
@karwa
Copy link
Contributor Author

karwa commented Nov 21, 2022

Interestingly, Xcode seems to do this, although it also describes some types entirely differently. Notice that the Docc-render version of insert(contentsOf:) describes the parameter as only some Collection, but Xcode includes the primary associated type (some Collection<(some StringProtocol, some StringProtocol)>)

image

@d-ronnqvist d-ronnqvist changed the title Use shorter names for nested types [SymbolGraphGen] Use shorter names for nested types Dec 21, 2023
@d-ronnqvist
Copy link
Contributor

Similar to #70588, this information comes from the different compilers. If there's a way to emit shorter names in the declarations that would most likely be performed there.

@d-ronnqvist d-ronnqvist transferred this issue from swiftlang/swift-docc Dec 21, 2023
@d-ronnqvist
Copy link
Contributor

cc @QuietMisdreavus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

2 participants