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

Extension constraints including conditional conformance #717

Closed
andersio opened this issue Dec 25, 2016 · 5 comments
Closed

Extension constraints including conditional conformance #717

andersio opened this issue Dec 25, 2016 · 5 comments

Comments

@andersio
Copy link

andersio commented Dec 25, 2016

Not sure if I have missed something — it seems Jazzy does not generate a section title for extensions with different constraints to differentiate themselves from each other. Is that only possible by manually adding // MARK: -?

@SDGGiesbrecht
Copy link
Contributor

SDGGiesbrecht commented Dec 26, 2016

You are correct. There is no automation for this yet.

Using // MARK: - is exactly how I do it right now. Compare this source and this output (2016‐12‐26).

I have even added this custom rule to SwiftLint so that I cannot forget to mark where‐extensions.

@reitzig
Copy link

reitzig commented Aug 1, 2017

For reference.

Input:

/// Fly, you Foos!
public struct Foo<T> {
    /// Creates a new instance with a single `T`.
    public init(t: T) {}
}

public extension Foo where T == Int {
    /// Creates a new instance with the sum of many `T`.
    public init(t: T...) {
        self.init(t: t.reduce(0, {$0 + $1}))
    }
}

Expected output: unclear, but it should be obvious that init(t: T...) is only available for some choices of T.

Actual output:
screen shot 2017-08-01 at 15 54 29

@SDGGiesbrecht
Copy link
Contributor

This goes hand in hand with #if statements (#750).

@johnfairh johnfairh changed the title Extension constraints. Extension constraints including conditional conformance May 9, 2018
@johnfairh
Copy link
Collaborator

I'm playing with a prototype to deal better with extensions: automatically generates sections for extension constraints as well as documenting protocol conformances added by extensions, conditional or unilateral.

So we get this kind of thing:

Screenshot 2019-04-15 at 13 49 30
...with autolinking in the constraint:
Screenshot 2019-04-19 at 09 24 51

Conformances from extensions are shown alongside original type declarations:
Screenshot 2019-04-15 at 12 55 49

And extensions of external types use the actual extension declarations rather than the extended type:
Screenshot 2019-04-15 at 13 52 56

Screenshot 2019-04-19 at 10 01 34

Need to write more tests and sort out dependencies but should get here.

@johnfairh
Copy link
Collaborator

(finally) fixed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants