Description
Summary
I would like to give package developers a way to declare names that are part of their package's public API without needing to export
them.
This feature request has two parts:
- The
Base.@public
macro, which declares a name as public withoutexport
ing it. - The
Base.public_not_exported(m::Module)::Vector{Symbol}
function, which returns the list of all non-exported public names in the modulem
.
This feature request is non-breaking. Therefore, it can be implemented in a Julia 1.x release.
Part 1: Base.@public
macro
For example, suppose that my package has a public function named fit. Because that word is so common, I don't want to export it from my package. But I want to indicate that it is part of the public API in a structured way that downstream tools (Documenter.jl, JuliaHub, editors/IDEs, etc.) can understand.
So in this example, I could do something like the following:
module Foo
export cool_stuff # public and exported
@public fit # public but not exported
function cool_stuff end
function fit end
function private_stuff end # private
end # module
Part 2:Base.public_not_exported
function
The signature of the function will be: Base.public_not_exported(m::Module)::Vector{Symbol}
.
Example usage:
julia> Base.public_not_exported(Foo)
1-element Vector{Symbol}:
:fit
Related Discussions
There is some related discussion in JuliaDocs/Documenter.jl#1507. However, I really want this to be something that any tool can use, so I don't want it to be specific to Documenter.