Skip to content

Commit

Permalink
Minor version bump and more metadata docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokazama committed Feb 3, 2020
1 parent 4f45129 commit fc6e081
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FieldProperties"
uuid = "127e4479-4c95-493a-afaa-609d38175b70"
authors = ["zchristensen "]
version = "0.4.1"
version = "0.4.2"

[deps]
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/metadata.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Metadata

TODO further document how to use metadata
This section covers some basic types that are useful in constructing metadata for storing properties.

```@docs
AbstractMetadata
Expand Down
50 changes: 50 additions & 0 deletions src/metadata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,56 @@ end
Subtype of `AbstractMetadata` that provides `getproperty` syntax for accessing
the values of a dictionary.
## Examples
```jldoctest
julia> using FieldProperties
julia> m = Metadata(; a = 1, b= 2)
Metadata{Dict{Symbol,Any}} with 2 entries
a: 1
b: 2
julia> getindex(m, :a)
1
julia> get(m, :a, 3)
1
julia> get!(m, :a, 3)
1
julia> m.a
1
julia> m[:a] = 2
2
julia> m.a
2
julia> m.b
2
julia> m.b = 3
3
julia> m.b
3
julia> m.name = "ridiculously long name that we don't want to print everytime the other properties are printed.";
julia> m.suppress = (:name,)
(:name,)
julia> m
Metadata{Dict{Symbol,Any}} with 4 entries
a: 2
b: 3
name: <suppressed>
suppress: (:name,)
```
"""
struct Metadata{D} <: AbstractMetadata{D}
dictextension::D
Expand Down
2 changes: 2 additions & 0 deletions test/metadata_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@test propertynames(m) == Tuple(keys(m)) == (:a, :b)
@test getkey(m, :a, 1) == getkey(FieldProperties.dictextension(m), :a, 1)

#= TODO delete these once we know that they are still covered by docs
@test getindex(m, :a) == 1
@test get(m, :a, 3) == 1
Expand All @@ -19,6 +20,7 @@
@test m.b == 2
m.b = 3
@test m.b == 3
=#
@test length(m) == 2
delete!(m, :a)
@test !haskey(m, :a)
Expand Down

2 comments on commit fc6e081

@Tokazama
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/8828

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.2 -m "<description of version>" fc6e08183c4f8a3f7dc31ac89f9819349bdb53c9
git push origin v0.4.2

Please sign in to comment.