From b14b1291a1463a8387a14b42b532c273d0452815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=ADma=2C=20Jan?= Date: Thu, 22 Feb 2024 14:50:15 +0100 Subject: [PATCH] Fix documenting of custom agent type. Using `define_agent`, if an agent is defined in `__module`, we also point `Core.@__doc__` to document the type inside that module. --- Project.toml | 2 +- src/agents.jl | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 203c7e2..2ec8279 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/agents.jl b/src/agents.jl index 88eacaa..73eb93d 100644 --- a/src/agents.jl +++ b/src/agents.jl @@ -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 @@ -125,7 +126,7 @@ function aagent(base_type, super_type, type, __module) function $(tname)(name::AbstractString, args...) where { $(param_tnames_constraints...), - } + } uuid = AlgebraicAgents.uuid4() inners = Dict{String, AbstractAlgebraicAgent}() relpathrefs = Dict{AbstractString,