-
Notifications
You must be signed in to change notification settings - Fork 479
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
Linkcheck does not traverse into docstrings #2329
Comments
Or maybe, instead of all the refactoring, we can just put a "fake" |
Two notes about testing and refactoring here:
|
Ah, I missed Replacing For what it's worth, for the equivalent test in |
When
makedocs
is called withlinkcheck=true
, theDocumenter.linkcheck
routine does not traverse intoDocsNode
. That is, broken links inside of docstrings will not be reported.The reason for this is
Documenter.jl/src/docchecks.jl
Lines 183 to 184 in c6abf9d
Since the
node.element
for a docstring is aDocsNode
, nothing happens.To fix this,
linkcheck(node::MarkdownAST.Node, doc::Document; method::Symbol=:HEAD)
should receiveelement=node.element
as an explicit second parameter, so that we can dispatch on that. Other places inDocumenter
follow the same approach, e.g., thedomify
function in theHTMLWriter
.An alternative solution would be for
AbstractTrees.PreOrderDFS
to traverse intoDocsNode
, but that might be a lot trickier. Besides,DocumenterCitations
has the exact same problem, and there eitherlinkcheck
would have to dispatch for elements of typeBibliographyNode
orAbstractTrees.PreOrderDFS
would have to traverse intoBibliographyNode
.I would maybe also refactor
Documenter.linkcheck
a little bit. Right now it is difficult to unit-test. The call tocurl
should be probably be isolated more into alinkcheck(url::String)
method that returns(status, scheme, location)
: I don't think that network access on Github workflow runners (or anywhere else the test suite runs) is necessarily robust. For unit-testing, you'd want to mock the call tocurl
and use a pre-defined(status, scheme, location)
for a givenurl
.We could easily add a
cache
keyword argument tolinkcheck(doc)
andlinkcheck(node, doc; method=:HEAD)
(which should belinkcheck(node, element, doc; method=:HEAD)
, as discussed above). Thiscache
would aDict
mappingurl::String
=>(status, scheme, location)
. It would be internal use only (specifically for unit testing, that is). If aurl
is in thecache
(set up in a test), we'd just use the cached values instead of callinglinkcheck(url)
that goes out tocurl
and the network.The text was updated successfully, but these errors were encountered: