Skip to content

Instantly share code, notes, and snippets.

@nevillco
Created July 7, 2023 17:01
Show Gist options
  • Select an option

  • Save nevillco/aec0c67a7457a99fb220336614bc8184 to your computer and use it in GitHub Desktop.

Select an option

Save nevillco/aec0c67a7457a99fb220336614bc8184 to your computer and use it in GitHub Desktop.
StaticMemberIterable as Sourcery template
<% let implementingTypes = types.all.filter { $0.annotations["StaticMemberIterable"] != nil } -%>
<% for type in implementingTypes { -%>
<%_ %>// MARK: - <%= type.name %>
<%_ %>extension <%= type.name %> {
static let allCases: [Self] = [
<%_ let variables = type.staticVariables.sorted { $0.name < $1.name } -%>
<%_ for variable in variables { _%><%_ -%>
.<%= variable.name %>,
}
<%_ } _%>]<% -%>
<%_ %>}
<% } %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment