FeatureRegistries.FeatureRegistries
— ModuleFeatureRegistries.jl is a Julia package to create registries of a package’s features, letting package users discover and use them more easily. FeatureRegistries.jl lets you create tables that list package features so that
- users can explore and discover features,
- users can search features through a consistent interface; and
- developers of third-party packages can transparently add functionality
Usage
Package users
Package users of packages can use registries through:
find
/filter
/findfirst
to subset the list of features based on filters,info
(registry)
to get more information on a specific registry,registry[id]
to inspect an entry in a registry,load
(registry)
to access a feature
See also how to use registries.
Package developers
Developers can create registries using Registry
and Field
, push!(registry)
.
FeatureRegistries.Field
— Methodstruct Field(T, name; kwargs...)
A field defines what data will be stored in one column of a Registry
.
Keyword arguments
description::String = ""
: More information on the field contents and how they can be used. May contain Markdown formatting.optional = false
: Whether a registry entry can be entered without alue in this field.default = missing
: The default value used ifoptional === true
. If a non-missing
value is passed, the value ofoptional
is ignored and the field is treated as optional.defaultfn = (row, key) -> default
: Function to compute dynamically compute a default value from an entry. If passed, the value ofdefault
is ignored.
Examples
A simple Field
with entries of type String
:
Field(String, "My Field")
FeatureRegistries.Registry
— MethodRegistry(fields; kwargs...)
Create a feature registry with columns of Field
s.
Keyword arguments
name::String
: A descriptive name.fields::NamedTuple
:description::String = ""
: Description text for the registry. Shown wheninfo(registry)
is called.loadfn = identity
: Function to apply over a row whenload
is called. For example, callingload(registry["id"])
will callloadfn
.
FeatureRegistries.RegistryEntry
— Typestruct RegistryEntry(row, registry)
An entry in a feature registry registry
with values row
. Returned when indexing into a FeatureRegistry
, i.e. registry[id]
.
FeatureRegistries.exampleregistry
— Methodexampleregistry()
Create a Registry
of mathematical functions for testing purposes.
Examples
{cell}
using FeatureRegistries
registry = FeatureRegistries.exampleregistry()
FeatureRegistries.find
— Methodfind(registry, [; col = filter, ...])
Find entries in a registry that match a set of filters given as keyword arguments. The keyword name must correspond to a field in registry
, while the value is a filter that is checked against each field value.
See how to use registries for examples.
FeatureRegistries.info
— Functioninfo(registry)
Show information about a registry, specifically its name, description and fields.
Examples
{cell}
using FeatureRegistries: exampleregistry, info
registry = exampleregistry()
info(registry)
FeatureRegistries.load
— Methodload(entry)
load(registry[id])
Load a feature represented by a registry entry. The behavior depends on the Registry
.
FeatureRegistries.runtests
— MethodFeatureRegistries.runtests(pattern...; kwargs...)
Equivalent to ReTest.retest(FeatureRegistries, pattern...; kwargs...)
. This function is defined automatically in any module containing a @testset
, possibly nested within submodules.
FeatureRegistries.string_format
— Methodstring_format(str)
Ensure that a string is shown with double quotes.
```julia-repl julia> string_format("hi") ""hi""