OK, the docs are clear about it, but isn’t it inconsistent, that it is different for functions?
I have the following use case, which is probably not unique: I’d like to have separate sections for exported, public, and internal types and functions in Documenter.jl produced documentation. The public keyword provided by Documenter.jl itself is from pre-Julia v1.11 era, corresponds to isexported, and of little use.
For functions, following works e.g. for the “Public” section:
Filter = t -> (! Base.isexported(MyPkg, Symbol(t)) && Base.ispublic(MyPkg, Symbol(t)))
What’s the collection you pass that Filter over? And how did you construct it? It seems like you’re going about this backwards from how I’d do it. I’d use names(MyPkg) for your starting point — those are the symbols you need, and then you can filter them by exported/public/internal and even further refine them by their value with getproperty(MyPkg, :foo).
You’re just getting “lucky” that named functions know about their names and happen to have a Symbol constructor that gives you that name back. But it’s not even necessarily the exported name from the module.
In your example you already know the name so you should just instantiate the Symbol directly, but the API for getting the definition name from a function or type object is nameof:
julia> module A
foo() = 0
struct Bar end
end
Main.A
julia> nameof.((A.Bar, A.foo))
(:Bar, :foo)
julia> yada1, yada2 = A.Bar, A.foo; nameof.((yada1, yada2))
(:Bar, :foo)
This is what Symbol does, which obviously doesn’t work for ispublic:
They function the same, the printing in the REPL is just different. Prefixing an identifier with : is effectively creating a literal Symbol in the parser.