-
Notifications
You must be signed in to change notification settings - Fork 501
Description
Consider the following markdown documentation:
[Two words](@ref).
[Different words](@ref).
## Two wordsThe first link is correctly interpreted as a reference to the header "Two words".
The second link is more problematic. In the process of resolving the link, Documenter creates the slug Different-words for it, and since there is no header named "Different words", Documenter will treat Different-words to be a link to a docstring Different - words (i.e., invocation of Base.:(-)). In most code bases, the user gets a warning
┌ Warning: Cannot resolve @ref for md"[Different words](@ref)" in src/index.md.
│ - No docstring found in doc for binding `Base.-`.
└ @ Documenter ~/julia/Documenter.jl/src/utilities/utilities.jl:49
However, in julia's codebase, there is a docstring for Base.:(-) and so [Different words](@ref) would be resolved as a link to that function's docstring. This behavior is not optimal because it falsely succeeds in resolving non-existent links (see JuliaLang/julia#58073).
A quick-and-dirty solution would be to add the following at the beginning of find_docref:
# Check if the slug matches multiple dash-delimited words
if occursin(r"^\w+(-\w+){1,}$", code)
return (
error = "unable to get the binding for `$code` in module $(mod)",
exception = nothing,
)
end