diff --git a/src/intertypes/InterTypes.jl b/src/intertypes/InterTypes.jl index d728817..a8fa84d 100644 --- a/src/intertypes/InterTypes.jl +++ b/src/intertypes/InterTypes.jl @@ -82,6 +82,16 @@ end NamedACSetType(typespec::ACSetTypeSpec) end +exports(::InterTypeDecl) = Symbol[] + +function exports(acset_type::NamedACSetType) + if !isnothing(acset_type.typespec.genericname) + [acset_type.typespec.genericname] + else + [] + end +end + function hashdecls end struct InterTypeModule @@ -98,6 +108,15 @@ struct InterTypeModule end end +function exports(mod::InterTypeModule) + export_list = Symbol[] + for (name, decl) in pairs(mod.declarations) + push!(export_list, name) + append!(export_list, exports(decl)) + end + export_list +end + function intertype end abstract type ExportTarget end diff --git a/src/intertypes/julia.jl b/src/intertypes/julia.jl index fcd0402..dec9556 100644 --- a/src/intertypes/julia.jl +++ b/src/intertypes/julia.jl @@ -313,7 +313,7 @@ function include_intertypes(into::Module, file::String, imports::AbstractVector) into.include(as_intertypes(mod), file) # recompute the hash mod = InterTypeModule(name, mod.imports, mod.declarations) - into.eval(Expr(:export, keys(mod.declarations)...)) + into.eval(Expr(:export, exports(mod)...)) mod end diff --git a/test/intertypes/InterTypes.jl b/test/intertypes/InterTypes.jl index bcf13e3..4003599 100644 --- a/test/intertypes/InterTypes.jl +++ b/test/intertypes/InterTypes.jl @@ -69,7 +69,14 @@ g = EDWeightedGraph() add_parts!(g, :V, 2) add_part!(g, :E, src=1, tgt=2, weight=EdgeData(:mass_ave, 42)) -@test testjson(m) +@test testjson(g) + +sg = WeightedGraph{Symbol}() + +add_parts!(sg, :V, 2) +add_part!(sg, :E, src=1, tgt=2, weight=:mass_ave) + +@test testjson(sg) generate_module(wgraph, JSONTarget)