Skip to content

Commit

Permalink
Fix documenting of custom agent type.
Browse files Browse the repository at this point in the history
Using `define_agent`, if an agent is defined
in `__module`, we also point `Core.@__doc__` to
document the type inside that module.
  • Loading branch information
thevolatilebit committed Feb 22, 2024
1 parent dccb8fb commit 6037134
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
with:
version: '1.8'
version: '1.9'
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Documenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@latest
with:
version: '1.8'
version: '1.10'
- uses: actions/cache@v3
env:
cache-name: cache-artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1]
julia-version: [1.10]
julia-arch: [x86]
os: [ubuntu-latest]
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
julia_version: ['1.8']
julia_version: ['1.9', '1.10']
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "AlgebraicAgents"
uuid = "f6eb0ae3-10fa-40e6-88dd-9006ba45093a"
version = "0.3.22"
version = "0.3.23"

[deps]
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
Expand Down
3 changes: 2 additions & 1 deletion src/agents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ function define_agent(base_type, super_type, type, __module, constructor)
$$(QuoteNode(constructor))
end
end

# it is important to evaluate the macro in the module of the toplevel eval
Base.eval($__module, expr)
end

Core.@__doc__($(esc(Docs.namify(new_name))))
Core.@__doc__($__module.$(Docs.namify(new_name)))
nothing
end
end
Expand Down
6 changes: 4 additions & 2 deletions src/queries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ Accepts both anonymous queries (`_.name`) and named queries (`name=_.name`). By
"""
macro transform(exs...)
n_noname::Int = 0
queries = map(ex -> Meta.isexpr(ex, :(=)) ? (ex.args[1], ex.args[2]) :
(n_noname += 1; ("query_$n_noname", ex)), exs)
queries = map(
ex -> Meta.isexpr(ex, :(=)) ? (ex.args[1], ex.args[2]) :
(n_noname += 1; ("query_$n_noname", ex)),
exs)
names, queries = map(x -> x[1], queries), map(x -> x[2], queries)
quote
queries = TransformQuery.($(names),
Expand Down
8 changes: 5 additions & 3 deletions test/agents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ end
system_dump = AlgebraicAgents.save(system)

@test system_dump == Dict{String, Any}("name" => "diagram",
"inners" => Dict{String, Any}[Dict("name" => "agent1",
"inners" => Dict{String, Any}[
Dict("name" => "agent1",
"arguments" => [1],
"type" => MyAgentLoadsave),
Dict("name" => "agent2", "arguments" => [2], "type" => MyAgentLoadsave)],
Expand All @@ -123,8 +124,9 @@ end
agent1 = inners(system_reloaded)["agent1"]
@test agent1 isa MyAgentLoadsave

opera_dump = Dict("instantious" => [
Dict("call" => () -> println("instantious interaction")),
opera_dump = Dict(
"instantious" => [
Dict("call" => () -> println("instantious interaction"))
],
"futures" => [Dict("time" => 2.0, "call" => () -> println("future"))],
"controls" => [Dict("call" => () -> println("control"))])
Expand Down

0 comments on commit 6037134

Please sign in to comment.