-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `frameworks` key * Added AppKit support * Lint * Cleanup * Lint * Update YAML template * Update template * Refactor color indentation * Cleanup * Update README * Update CHANGELOG * Version bump * Split template * Fix AppKit + SwiftUI combination * Add template tests * Make typealias private * Update fixtures * HEREDOC -> SWIFT
- Loading branch information
1 parent
768dc70
commit 5127586
Showing
28 changed files
with
1,243 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stylegen | ||
class Indent | ||
def initialize(level, string = nil) | ||
@level = level | ||
@data = [] | ||
@data << string unless string.nil? | ||
end | ||
|
||
def <<(string) | ||
@data << string | ||
end | ||
|
||
def to_s | ||
result = @data.join.lines.map do |line| | ||
if line.strip.empty? | ||
line | ||
else | ||
"#{' ' * @level}#{line}" | ||
end | ||
end | ||
result.join | ||
end | ||
|
||
def self.with_level(level) | ||
indent = Indent.new(level) | ||
indent << yield | ||
indent.to_s | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stylegen | ||
module Partials | ||
class Colors | ||
attr_reader :data | ||
|
||
def initialize(data) | ||
@data = data | ||
end | ||
|
||
def to_s | ||
result = [] | ||
result << '// MARK: Colors' | ||
result << '' | ||
result << "#{data.effective_access_level} extension #{data.struct_name} {".lstrip | ||
|
||
data.color_entries.each do |entry| | ||
unless entry[:description].nil? | ||
entry[:description].strip.lines.each do |line| | ||
result << " /// #{line.strip}" | ||
end | ||
end | ||
|
||
result << " static let #{entry[:property]} = #{entry[:color].to_s(data.struct_name, 4).lstrip}" | ||
result << '' unless entry == data.color_entries.last | ||
end | ||
|
||
result << '}' | ||
result << '' | ||
result.join("\n") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stylegen | ||
module Partials | ||
class FileHeader | ||
attr_reader :data | ||
|
||
def initialize(data) | ||
@data = data | ||
end | ||
|
||
def to_s | ||
replacements = { | ||
'STYLEGEN_FILENAME' => data.basename, | ||
'STYLEGEN_VERSION' => data.version, | ||
'STYLEGEN_YEAR' => Date.today.year | ||
} | ||
|
||
"#{header_template}\n".gsub(/{{(\w+)}}/) { replacements[Regexp.last_match(1)] || '' } | ||
end | ||
|
||
private | ||
|
||
def header_template | ||
data.custom_header&.strip || <<~HEADER.chomp | ||
// | ||
// {{STYLEGEN_FILENAME}} | ||
// | ||
// Autogenerated by stylegen ({{STYLEGEN_VERSION}}) | ||
// DO NOT EDIT | ||
// | ||
HEADER | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stylegen | ||
module Partials | ||
class Imports | ||
attr_reader :data | ||
|
||
def initialize(data) | ||
@data = data | ||
end | ||
|
||
def to_s | ||
result = [] | ||
|
||
if data.multiplatform? | ||
result << '#if canImport(UIKit)' | ||
result << 'import UIKit' | ||
result << '#elseif canImport(AppKit)' | ||
result << 'import AppKit' | ||
result << '#endif' | ||
elsif data.supports_uikit? | ||
result << 'import UIKit' | ||
elsif data.supports_appkit? | ||
result << 'import AppKit' | ||
end | ||
|
||
result << 'import SwiftUI' if data.swiftui? | ||
result << '' | ||
result.join("\n") | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.