Skip to content

Commit 03eff8d

Browse files
committed
add comment in generation
1 parent 4a39e85 commit 03eff8d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Sources/HexColorMacroMacros/HexColorMacroMacro.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ public struct HexToColorMacro: ExpressionMacro {
9898
return ""
9999
}
100100

101-
return "Color(\(arg_colorSpace ?? ".sRGB"), red: \(raw: rgb.r.description), green: \(raw: rgb.g.description), blue: \(raw: rgb.b.description), opacity: \(arg_opacity ?? "1"))"
101+
return """
102+
// \(raw: hexString)
103+
Color(\(arg_colorSpace ?? ".sRGB"), red: \(raw: rgb.r.description), green: \(raw: rgb.g.description), blue: \(raw: rgb.b.description), opacity: \(arg_opacity ?? "1"))
104+
"""
102105
}
103106
}
104107

@@ -122,7 +125,10 @@ public struct HexToUIColorSRGBMacro: ExpressionMacro {
122125
return ""
123126
}
124127

125-
return "UIColor(red: \(raw: rgb.r.description), green: \(raw: rgb.g.description), blue: \(raw: rgb.b.description), alpha: \(arg_opacity ?? "1"))"
128+
return """
129+
// \(raw: hexString)
130+
UIColor(red: \(raw: rgb.r.description), green: \(raw: rgb.g.description), blue: \(raw: rgb.b.description), alpha: \(arg_opacity ?? "1"))
131+
"""
126132
}
127133
}
128134

@@ -146,7 +152,10 @@ public struct HexToUIColorP3Macro: ExpressionMacro {
146152
return ""
147153
}
148154

149-
return "UIColor(displayP3Red: \(raw: rgb.r.description), green: \(raw: rgb.g.description), blue: \(raw: rgb.b.description), alpha: \(arg_opacity ?? "1"))"
155+
return """
156+
// \(raw: hexString)
157+
UIColor(displayP3Red: \(raw: rgb.r.description), green: \(raw: rgb.g.description), blue: \(raw: rgb.b.description), alpha: \(arg_opacity ?? "1"))
158+
"""
150159
}
151160
}
152161

0 commit comments

Comments
 (0)