Skip to content

Commit

Permalink
Fix docs in src/Jobs/Jobs.jl & src/Thunks.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
singularitti committed Aug 17, 2022
1 parent 117f412 commit b932ecd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 22 deletions.
8 changes: 5 additions & 3 deletions src/Jobs/Jobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ Create a simple job.
- `desc::String=""`: describe briefly what this job does.
- `user::String=""`: indicate who executes this job.
```@example
a = Job(Thunk(sleep)(5); user="me", desc="Sleep for 5 seconds")
b = Job(Thunk(run, `pwd` & `ls`); user="me", desc="Run some commands")
# Examples
```jldoctest
julia> a = Job(Thunk(sleep)(5); user="me", desc="Sleep for 5 seconds");
julia> b = Job(Thunk(run, `pwd` & `ls`); user="me", desc="Run some commands");
```
"""
mutable struct Job
Expand Down
54 changes: 35 additions & 19 deletions src/Thunks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,41 @@ export Thunk, reify!, getresult

# Idea from https://github.com/tbenst/Thunks.jl/blob/ff2a553/src/core.jl#L11-L20
"""
Thunk(function, args::Tuple, kwargs::NamedTuple)
Thunk(function, args...; kwargs...)
Thunk(function)
Hold a function and its arguments for lazy evaluation. Use `reify!` to evaluate.
```@example
a = Thunk(x -> 3x, 4)
reify!(a)
b = Thunk(+, 4, 5)
reify!(b)
c = Thunk(sleep)(1)
getresult(c) # `c` has not been evaluated
reify!(c) # `c` has been evaluated
f(args...; kwargs...) = collect(kwargs)
d = Thunk(f)(1, 2, 3; x=1.0, y=4, z="5")
reify!(d)
e = Thunk(sin, "1") # Catch errors
reify!(e)
Thunk(::Function, args::Tuple, kwargs::NamedTuple)
Thunk(::Function, args...; kwargs...)
Thunk(::Function)
Hold a `Function` and its arguments for lazy evaluation. Use `reify!` to evaluate.
# Examples
```jldoctest
julia> a = Thunk(x -> 3x, 4);
julia> reify!(a)
Some(12)
julia> b = Thunk(+, 4, 5);
julia> reify!(b)
Some(9)
julia> c = Thunk(sleep)(1);
julia> getresult(c) # `c` has not been evaluated
julia> reify!(c) # `c` has been evaluated
Some(nothing)
julia> f(args...; kwargs...) = collect(kwargs);
julia> d = Thunk(f)(1, 2, 3; x=1.0, y=4, z="5");
julia> reify!(d)
Some(Pair{Symbol, Any}[:x => 1.0, :y => 4, :z => "5"])
julia> e = Thunk(sin, "1"); # Catch errors
julia> reify!(e);
```
"""
mutable struct Thunk
Expand Down

0 comments on commit b932ecd

Please sign in to comment.