From c9b11839666980fef7cb778990100bbc50cdd65c Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Thu, 2 Nov 2023 19:36:36 +0000 Subject: [PATCH] build based on e6d48bb --- previews/PR37/.documenter-siteinfo.json | 2 +- previews/PR37/advanced/index.html | 2 +- previews/PR37/api/index.html | 14 +++++++------- previews/PR37/baseinterfaces/index.html | 2 +- previews/PR37/basic/index.html | 2 +- previews/PR37/index.html | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/previews/PR37/.documenter-siteinfo.json b/previews/PR37/.documenter-siteinfo.json index a6333a0..2a35415 100644 --- a/previews/PR37/.documenter-siteinfo.json +++ b/previews/PR37/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-11-02T18:50:33","documenter_version":"1.1.2"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-11-02T19:36:32","documenter_version":"1.1.2"}} \ No newline at end of file diff --git a/previews/PR37/advanced/index.html b/previews/PR37/advanced/index.html index fc9235e..36c86a1 100644 --- a/previews/PR37/advanced/index.html +++ b/previews/PR37/advanced/index.html @@ -36,4 +36,4 @@ Interfaces.test(Group.GroupInterface, Float64, int_pairs) catch e print(e.msg) -end
Each tested object must either be an instance of `Float64` or an instance of `Arguments` whose field types include at least one subtype of `Float64`. You provided a `Arguments{(:x, :y), Tuple{Int64, Int64}}` instead.

In summary, there are two things to remember:

  1. The anonymous functions in the interface conditions of Interfaces.@interface should accept a single object of type Arguments and then work with its named fields. These fields should be listed in the docstring.
  2. The list of objects passed to Interface.test must all be of type Arguments, with the right named fields. At least one field must have the type you are testing.

This page was generated using Literate.jl.

+end
Each tested object must either be an instance of `Float64` or an instance of `Arguments` whose field types include at least one subtype of `Float64`. You provided a `Arguments{(:x, :y), Tuple{Int64, Int64}}` instead.

In summary, there are two things to remember:

  1. The anonymous functions in the interface conditions of Interfaces.@interface should accept a single object of type Arguments and then work with its named fields. These fields should be listed in the docstring.
  2. The list of objects passed to Interface.test must all be of type Arguments, with the right named fields. At least one field must have the type you are testing.

This page was generated using Literate.jl.

diff --git a/previews/PR37/api/index.html b/previews/PR37/api/index.html index b5239d5..9926147 100644 --- a/previews/PR37/api/index.html +++ b/previews/PR37/api/index.html @@ -1,14 +1,14 @@ -API reference · Interfaces.jl

API reference

Docstrings

Interfaces.InterfacesModule
Interfaces

A Julia package for specifying and testing interfaces (conditions verified by a set of methods applied to a type).

source
Interfaces.ArgumentsType
Arguments{names,T}
+API reference · Interfaces.jl

API reference

Docstrings

Interfaces.InterfacesModule
Interfaces

A Julia package for specifying and testing interfaces (conditions verified by a set of methods applied to a type).

source
Interfaces.InterfaceType
Interface{Components}

Abstract supertype for all Interfaces.jl interfaces.

Components is an Tuple of Symbol.

source
Interfaces.componentsFunction
components(::Type{<:Interface})

Returns the components of the interface, as a NamedTuple of NamedTuple.

source
Interfaces.implemented_traitMethod
implemented_trait(T::Type{<:Interface}, obj)
-implemented_trait(T::Type{<:Interface{Option}}, obj)

Provides a single type for using interface implementation as a trait.

Returns Implemented{T}() or NotImplemented{T}().

source
Interfaces.implementsFunction
implements(::Type{<:Interface}, obj)
-implements(::Type{<:Interface{Options}}, obj)

Returns whether an object implements an interface, as a Bool.

obj can be an be an object or a Type.

Options can be a Symbol or a Tuple of Symbol passed to the type parameter of the Interface, to check if optional interfaces are implemented by the obj.

Without specifying Options, the return value specifies that at least all the mandatory components of the interace are implemented.

source
Interfaces.InterfaceType
Interface{Components}

Abstract supertype for all Interfaces.jl interfaces.

Components is an Tuple of Symbol.

source
Interfaces.componentsFunction
components(::Type{<:Interface})

Returns the components of the interface, as a NamedTuple of NamedTuple.

source
Interfaces.implemented_traitMethod
implemented_trait(T::Type{<:Interface}, obj)
+implemented_trait(T::Type{<:Interface{Option}}, obj)

Provides a single type for using interface implementation as a trait.

Returns Implemented{T}() or NotImplemented{T}().

source
Interfaces.implementsFunction
implements(::Type{<:Interface}, obj)
+implements(::Type{<:Interface{Options}}, obj)

Returns whether an object implements an interface, as a Bool.

obj can be an be an object or a Type.

Options can be a Symbol or a Tuple of Symbol passed to the type parameter of the Interface, to check if optional interfaces are implemented by the obj.

Without specifying Options, the return value specifies that at least all the mandatory components of the interace are implemented.

source
Interfaces.testMethod
test(m::Module)
 test(::Type{<:Interface}, m::Module)
-test(::Type{<:Interface}, obj::Type)

Test if an interface is implemented correctly for an object, returning true or false.

If no interface type is passed, Interfaces.jl will find all the interfaces available and test them.

source
Interfaces.@implementsMacro
@implements(interface, objtype)
+test(::Type{<:Interface}, obj::Type)

Test if an interface is implemented correctly for an object, returning true or false.

If no interface type is passed, Interfaces.jl will find all the interfaces available and test them.

source
Interfaces.@implementsMacro
@implements(interface, objtype)
 @implements(dev, interface, objtype)

Declare that an interface implements an interface, or multipleinterfaces.

The macro can only be used once per module for any one type. To define multiple interfaces a type implements, combine them in square brackets.

Passing the keyword dev as the first argument lets us show test output during development. Do not use dev in production code, or output will appear during package precompilation.

Example

Here we implement the IterationInterface for Base julia, indicating with (:indexing, :reverse) that our object can be indexed and works with Iterators.reverse:

using BaseInterfaces
-@implements BaseInterfaces.IterationInterface{(:indexing,:reverse)} MyObject
source
Interfaces.@interfaceMacro

@interface(interfacename, components, [description])

Define an interface that can apply to types <: Any.

components = (
+@implements BaseInterfaces.IterationInterface{(:indexing,:reverse)} MyObject
source
Interfaces.@interfaceMacro

@interface(interfacename, components, [description])

Define an interface that can apply to types <: Any.

components = (
     mandatory = (
         length = x -> length(x) = prod(size(x)),
         ndims = x -> ndims(x) = length(size(x)),
@@ -17,4 +17,4 @@
 )
 description = "A description of the interface"
 
-@interface MyInterface Any components description
source

Index

+@interface MyInterface Any components description
source

Index

diff --git a/previews/PR37/baseinterfaces/index.html b/previews/PR37/baseinterfaces/index.html index 885d056..4ffb367 100644 --- a/previews/PR37/baseinterfaces/index.html +++ b/previews/PR37/baseinterfaces/index.html @@ -1,2 +1,2 @@ -BaseInterfaces.jl reference · Interfaces.jl

BaseInterfaces reference

Docstrings

BaseInterfaces.ArrayInterfaceType
    ArrayInterface

An Interfaces.jl Interface with mandatory components (:type, :eltype, :ndims, :size, :getindex, :indexstyle) and optional components (:setindex!, :similar_type, :similar_eltype, :similar_size, :similar_eltype_size).

Base Julia AbstractArray interface

source
BaseInterfaces.DictInterfaceType
    DictInterface

An Interfaces.jl Interface with mandatory components (:iterate, :eltype, :keytype, :valtype, :keys, :values, :getindex) and optional components (:setindex!,).

AbstractDict interface requires Arguments, with d = the_dict mandatory, and when setindex is needed, k = any_valid_key_not_in_d, v = any_valid_val

source
BaseInterfaces.IterationInterfaceType
    IterationInterface

An Interfaces.jl Interface with mandatory components (:iterate, :isiterable, :eltype, :size, :in) and optional components (:reverse, :indexing).

An interface for Base Julia iteration

source
BaseInterfaces.SetInterfaceType
    SetInterface

An Interfaces.jl Interface with mandatory components (:isempty, :eltype, :length, :iteration, :in) and optional components (:copy, :empty, :hasfastin, :setdiff, :intersect, :union, :copymutable, :emptymutable, :empty!, :delete!, :push!, :sizehint!).

The AbstractSet interface

source

Index

+BaseInterfaces.jl reference · Interfaces.jl

BaseInterfaces reference

Docstrings

BaseInterfaces.ArrayInterfaceType
    ArrayInterface

An Interfaces.jl Interface with mandatory components (:type, :eltype, :ndims, :size, :getindex, :indexstyle) and optional components (:setindex!, :similar_type, :similar_eltype, :similar_size, :similar_eltype_size).

Base Julia AbstractArray interface

source
BaseInterfaces.DictInterfaceType
    DictInterface

An Interfaces.jl Interface with mandatory components (:iterate, :eltype, :keytype, :valtype, :keys, :values, :getindex) and optional components (:setindex!,).

AbstractDict interface requires Arguments, with d = the_dict mandatory, and when setindex is needed, k = any_valid_key_not_in_d, v = any_valid_val

source
BaseInterfaces.IterationInterfaceType
    IterationInterface

An Interfaces.jl Interface with mandatory components (:iterate, :isiterable, :eltype, :size, :in) and optional components (:reverse, :indexing).

An interface for Base Julia iteration

source
BaseInterfaces.SetInterfaceType
    SetInterface

An Interfaces.jl Interface with mandatory components (:isempty, :eltype, :length, :iteration, :in) and optional components (:copy, :empty, :hasfastin, :setdiff, :intersect, :union, :copymutable, :emptymutable, :empty!, :delete!, :push!, :sizehint!).

The AbstractSet interface

source

Index

diff --git a/previews/PR37/basic/index.html b/previews/PR37/basic/index.html index f3a7bcd..207f18b 100644 --- a/previews/PR37/basic/index.html +++ b/previews/PR37/basic/index.html @@ -44,4 +44,4 @@ print(e) end

 Testing AnimalInterface is implemented for Main.Chicken
-Interfaces.InterfaceError(Main.Animals.AnimalInterface, :age, 1, " \"all animals have a `Real` age\"", Main.Chicken(), MethodError(Main.Animals.age, (Main.Chicken(),), 0x00000000000082fb))

This page was generated using Literate.jl.

+Interfaces.InterfaceError(Main.Animals.AnimalInterface, :age, 1, " \"all animals have a `Real` age\"", Main.Chicken(), MethodError(Main.Animals.age, (Main.Chicken(),), 0x00000000000082fb))

This page was generated using Literate.jl.

diff --git a/previews/PR37/index.html b/previews/PR37/index.html index 5aded04..c93b0a8 100644 --- a/previews/PR37/index.html +++ b/previews/PR37/index.html @@ -1,2 +1,2 @@ -Home · Interfaces.jl

Interfaces

Stable Dev Build Status Coverage

Macros for defining the required behaviours of Julia interfaces, and stating that an object implements them.

The goal is to get as much as possible out of defining an interface, specifically:

  • Traits: All @implements declarations produce compile-time traits that can be checked by other packages - for the whole interface and all of it's optional components.
  • Tests: @implements declarations should be tested in package tests.
  • Docs: interface documentation can be inserted into trait documentation.

See the IterationInterface in BaseInterfaces.jl (a subpackage of this package) or the documentation for examples of @interface and @implements.

Note: the syntax here is likely to change as we work out the best ways to define interfaces

If you think it should behave differently or there is better syntax, please make an issue.

+Home · Interfaces.jl

Interfaces

Stable Dev Build Status Coverage

Macros for defining the required behaviours of Julia interfaces, and stating that an object implements them.

The goal is to get as much as possible out of defining an interface, specifically:

  • Traits: All @implements declarations produce compile-time traits that can be checked by other packages - for the whole interface and all of it's optional components.
  • Tests: @implements declarations should be tested in package tests.
  • Docs: interface documentation can be inserted into trait documentation.

See the IterationInterface in BaseInterfaces.jl (a subpackage of this package) or the documentation for examples of @interface and @implements.

Note: the syntax here is likely to change as we work out the best ways to define interfaces

If you think it should behave differently or there is better syntax, please make an issue.