-
Notifications
You must be signed in to change notification settings - Fork 491
Add a way for users to tell Documenter about unexported names that are part of their package's public API #1507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
983391f
to
d91987b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, I like this. Sorry for not reviewing this earlier.
-
I think we should also update to using the new
name_is_public
in document checks:Documenter.jl/src/DocChecks.jl
Line 85 in 4be8243
isexported = Base.isexported(mod, name) -
I was wondering whether "unexported" sounds better in the variable names. But FWIW, it does look like "non-exported" is more commonly used.
-
Needs a rebase, but that should not be problematic (just
.travis.yml
has been removed in the meanwhile).
@@ -76,3 +76,5 @@ include("TestUtilities.jl"); using .TestUtilities | |||
@info "doctest() Documenter's manual" | |||
@quietly include("manual.jl") | |||
end | |||
|
|||
include("public_names.jl") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we include this in the main testset?
""" | ||
`a` is exported, and it is part of the public API. | ||
""" | ||
function a end | ||
|
||
""" | ||
`b` is not exported, but it is part of the public API. | ||
""" | ||
function b end | ||
|
||
""" | ||
`c` is not exported, but it is part of the public API. | ||
""" | ||
function c end | ||
|
||
""" | ||
`d` is not exported, and it is private (internal). | ||
""" | ||
function d end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it might be worth turning these into 1-line docstrings to save a few lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! What is the syntax for a one line docstring?
I agree that we definitely could do with this feature, I guess my question would be whether this is the right "level" to be adding it in, rather than further down in the docsystem, either within The following implementation with struct Public <: Abbreviation end
const PUBLIC = Public()
export PUBLIC
format(::Public, buf, doc) = nothing
ispublic(doc::Docs.DocStr) = any(x -> isa(x, Public), doc.text)
Which has the benefit of working on the docstring rather than the binding since it could be useful to only make particular signatures of a binding public rather than all of them. |
If it will only be used by Documenter, wouldn't it be better to have this as a kwarg to |
…e part of their package's public API
41643fd
to
2babb39
Compare
The A few thoughts:
|
Yeah exactly. Eventually I would like to have some kind of ecosystem-wide convention. In Julia 2.0, I'd like to maybe have a keyword |
I'd like to avoid making package authors take on an additional dependency just so that they can use this convention. Something in Base Julia (e.g. |
I think it is sufficient to just work on the name, rather than specific docstrings. Basically, we are trying to emulate the functionality of |
The I still disagree with relying on convention and globals with magic names like this does. Why not implement an API for getting/setting the |
Honestly, I forgot about Compat. That would indeed be a way to get around the compatibility issue, which is my only objection to implementing it in Base. |
I'm not familiar enough with the I do think we need this feature, and not just for Documenter, but in a way that all tools can use. |
I don't have a lot of time at the moment to directly work one this, but can try provide some breadcrumbs at least to an initial implementation if need be. Something like the following as a MVP could get us partway there: julia> macro metadata!(expr, data)
:(merge!(Docs.@ref($(esc(expr))).data, $(esc(data))))
end
@metadata! (macro with 1 method)
julia> macro metadata(expr)
:(Docs.@ref($(esc(expr))).data)
end
@metadata (macro with 1 method)
julia> @metadata sin(::Number)
Dict{Symbol, Any} with 5 entries:
:typesig => Tuple{Number}
:module => Base.Math
:linenumber => 432
:binding => Base.sin
:path => "math.jl"
julia> @metadata! sin(::Number) Dict(:public => true)
Dict{Symbol, Any} with 6 entries:
:typesig => Tuple{Number}
:module => Base.Math
:linenumber => 432
:binding => Base.sin
:path => "math.jl"
:public => true A function-based API for retrieval ( |
Fixes #1506
This pull request adds the ability for users to tell Documenter about unexported names that are part of their package's public API.
When using
@autodocs
, these names will be shown whenPublic = true
, and will not be shown whenPublic = false
.In order to use this feature, simple define a vector of symbols named
NONEXPORTED_PUBLIC_NAMES
at the top level of your module. (We can definitely bikeshed the nameNONEXPORTED_PUBLIC_NAMES
.)Here's an example:
In this example, Documenter will consider the names
a
,b
, andc
to be public (even thoughb
andc
are not exported).d
will be considered to be private.