Skip to content

Commit

Permalink
allow custom module name
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Oct 19, 2023
1 parent 5e79202 commit 7c079ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/implements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ function _implements_inner(interface, objtype; show=false)
end
quote
# Define a `implements` trait stating that `objtype` implements `interface`
Interfaces.implements(::Type{<:$interfacetype}, ::Type{<:$objtype}) = true
Interfaces.implements(T::Type{<:$interfacetype{Options}}, O::Type{<:$objtype}) where Options =
Interfaces._all_in(Options, Interfaces.optional_keys(T, O))
$Interfaces.implements(::Type{<:$interfacetype}, ::Type{<:$objtype}) = true
$Interfaces.implements(T::Type{<:$interfacetype{Options}}, O::Type{<:$objtype}) where Options =
$Interfaces._all_in(Options, $Interfaces.optional_keys(T, O))
# Define which optional components the object implements
Interfaces.optional_keys(::Type{<:$interfacetype}, ::Type{<:$objtype}) = $optional_keys
$Interfaces.optional_keys(::Type{<:$interfacetype}, ::Type{<:$objtype}) = $optional_keys
nothing
end |> esc
end
Expand Down
10 changes: 5 additions & 5 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ description = "A description of the interface"
macro interface(interface::Symbol, components, description)
quote
# Define the interface type (should it be concrete?)
abstract type $interface{Components} <: Interfaces.Interface{Components} end
abstract type $interface{Components} <: $Interfaces.Interface{Components} end
# Define the interface component methods
@assert $components isa NamedTuple{(:mandatory,:optional)}
Interfaces.components(::Type{<:$interface}) = $components
$Interfaces.components(::Type{<:$interface}) = $components
@assert $description isa String
Interfaces.description(::Type{<:$interface}) = $description
$Interfaces.description(::Type{<:$interface}) = $description
# Generate a docstring for the interface
let description=$description,
interfacesym=$(QuoteNode(interface)),
m_keys=Interfaces.mandatory_keys($interface),
o_keys=Interfaces.optional_keys($interface)
m_keys=$Interfaces.mandatory_keys($interface),
o_keys=$Interfaces.optional_keys($interface)
@doc """
$(" ") $interfacesym
Expand Down

0 comments on commit 7c079ad

Please sign in to comment.