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

Added clr files parser #81

Merged
merged 3 commits into from
Jan 8, 2016
Merged

Added clr files parser #81

merged 3 commits into from
Jan 8, 2016

Conversation

ilyapuchka
Copy link
Contributor

This PR adds support for clr files using the same templates used for text files.

public func parseFile(path: String) {
if let colorsList = NSColorList(name: "UserColors", fromFile: path) {
for keyColorPair in colorsList.allKeys.map({ ($0, colorsList.colorWithKey($0)) }) {
let colorName = keyColorPair.0.stringByReplacingOccurrencesOfString(" ", withString: "")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the removal of spaces necessary here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In palettes who knows what users can have. At least we provide some sanity checks. Of course if user have Color#1 like names it will not work anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But you don't need that. It's not the work of the parser to sanitize the color name. It's the work of the template filters, like here.

That's because people could want to customize their template and use the real name (with spaces and all) for purposes other than just use them as the swift identifier, but to use them to generate comments for each color, or to associate a color name as a String or implement a nice CustomStringConvertible or whatnot. But if they use it as a swift identifier, that's their responsibility to call the swiftIdentifier Stencil filter on the name in their template in the appropriate place(s).

@AliSoftware
Copy link
Collaborator

Aside from the 1-2 comments I did on your last commit, looks good to merge, nice work 👍

AliSoftware added a commit that referenced this pull request Jan 8, 2016
Added `.clr` (color palettes) parser
@AliSoftware AliSoftware merged commit 3e531e3 into SwiftGen:master Jan 8, 2016
@ilyapuchka ilyapuchka deleted the clr branch September 7, 2018 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants