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] Allow documenting API using modernized syntax even when ABI prevents an update to the code #70711

Open
glessard opened this issue Jan 3, 2024 · 1 comment
Labels
duplicate Resolution: Duplicates another issue feature A feature request or implementation SymbolGraphGen The swiftSymbolGraphGen library, responsible for gathering and emitting symbol graphs.

Comments

@glessard
Copy link
Contributor

glessard commented Jan 3, 2024

Feature Name

Documentation with Modernized Syntax for old API

Description

Some older API in the standard library are defined using classic generics syntax, and cannot be changed for historical (ABI) reasons. It would be nice to be able to display these using a source-compatible modernized syntax in documentation.

Motivation

Some API are declared using old generics syntax, and would read better using modernized syntax. For example:

public func initializeMemory<C: Collection>(as: C.Element.Type, fromContentsOf source: C) -> UnsafeMutableBufferPointer<C.Element>

would read better as:

public func initializeMemory<Element>(as: Element.type, fromContentsOf source: some Collection<Element>) -> UnsafeMutableBufferPointer<Element>

The second version names the important type (Element), while making the incidental type (the collection) anonymous. The original version, using classic syntax, names the incidental type while obscuring the important one.

This would not be an ABI-compatible change, though it is source-compatible.

Importance

It would allow our documentation to use modern syntax even in cases where the function definition requires the old syntax for historical reasons (e.g. ABI stability).

Alternatives Considered

No response

@d-ronnqvist
Copy link
Contributor

DocC itself isn't tied to any specific language so it wouldn't rewrite function signatures. Instead the symbol information that's displayed in DocC comes from the source language's compilers.

This has previously been reported here #70588

@d-ronnqvist d-ronnqvist added the duplicate Resolution: Duplicates another issue label Jan 4, 2024
@d-ronnqvist d-ronnqvist changed the title Allow documenting API using modernized syntax even when ABI prevents an update to the code [SymbolGraphGen] Allow documenting API using modernized syntax even when ABI prevents an update to the code Jan 4, 2024
@d-ronnqvist d-ronnqvist transferred this issue from apple/swift-docc Jan 4, 2024
@d-ronnqvist d-ronnqvist added feature A feature request or implementation SymbolGraphGen The swiftSymbolGraphGen library, responsible for gathering and emitting symbol graphs. labels Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Resolution: Duplicates another issue feature A feature request or implementation SymbolGraphGen The swiftSymbolGraphGen library, responsible for gathering and emitting symbol graphs.
Projects
None yet
Development

No branches or pull requests

2 participants