Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Swift 3.0 API Guidelines Pass 1 #132

Merged
merged 32 commits into from
Jul 8, 2016

Conversation

mliberatore
Copy link
Contributor

Begins work on API renaming as part of #123

📝 This is pointing at the new swift-3.0 branch, not develop.

These are all manual edits made to API names (and a bit of refactoring where appropriate). That is to say, none of this work was performed by the migrator. Migration occurred in #127.

Related:

Uses better Swift 3 naming for the `path` methods.
@@ -32,7 +32,7 @@ public extension UIFont {

- returns: A Source Sans Pro `UIFont` at the specified size and weight.
*/
public static func sourceSansProFontOfSize(_ fontSize: CGFloat, weight: FontWeight = .regular) -> UIFont {
public static func sourceSansProFont(ofSize fontSize: CGFloat, weight: FontWeight = .regular) -> UIFont {
Copy link
Member

Choose a reason for hiding this comment

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

We can remove the word font from these methods, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which font do you propose removing? The one from sourceSansProFont or fontSize?

I was deliberately keeping these in line with ’s:

public class func systemFont(ofSize fontSize: CGFloat) -> UIFont

But I see how you could make an argument similar to UIColor.whateverColor()UIColor.whatever().

Copy link
Member

Choose a reason for hiding this comment

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

But I see how you could make an argument similar to UIColor.whateverColor() → UIColor.whatever().

This is exactly how I’m thinking of it. I think we can safely remove both, but if we want to be a bit more conservative just the first one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So just to be clear, you’re thinking:

public static func sourceSansPro(ofSize: size CGFloat, weight: FontWeight = .regular) -> UIFont
public static func menloRegular(ofSize size: CGFloat) -> UIFont

With call sites looking like:

UIFont.sourceSansPro(ofSize: 32.0)
UIFont.menloRegular(ofSize: 16.0)

I’d be happy to make the change but am worried we’re deviating from the naming changes in UIFont. UIFont APIs were renamed, from e.g.:

public class func systemFontOfSize(fontSize: CGFloat, weight: CGFloat) -> UIFont

to:

public class func systemFont(ofSize fontSize: CGFloat, weight: CGFloat) -> UIFont

with no dropping of "font".

At this stage, would a radar be more appropriate (perhaps we can call out specifics in the API guidelines to warrant these APIs changing), or do you think it’s not worth keeping directly in sync with similar signatures in UIKit?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I guess you’re right. There is one difference UIFont.system wouldn’t make a lot of intuitive sense because system doesn’t really sound like a specific font, whereas UIFont.futura definitely reads like UIColor.red. I think a radar for now and leaving it as is a good approach. Let me know if you want me to file it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m happy to take care of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And good point about system. I go back and forth on UIFont.system, personally. In context, I think it would seem reasonable on its own: label.font = .system, but with a parameter, not so much: label.font = .system(ofSize: 32).

Copy link
Contributor Author

@mliberatore mliberatore Jul 8, 2016

Choose a reason for hiding this comment

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

@mbbischoff mbbischoff merged commit f2973c2 into swift-3.0 Jul 8, 2016
@mbbischoff mbbischoff deleted the swift-3.0-api-guidelines-pass-1 branch July 8, 2016 19:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants