-
Notifications
You must be signed in to change notification settings - Fork 1.1k
WIP: Verify links in docs #17163
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
base: main
Are you sure you want to change the base?
WIP: Verify links in docs #17163
Conversation
I also wanted to add a check for external urls with the following method:
This verification is quite important because to check that the url corresponds to a static documentation, I check that it contains /docs/ (which is maybe to be done differently). But this can correspond to any other external documentation link such as https://docs.oracle.com/javase/8/docs/api/java/lang/FunctionalInterface.html and this puts a warning. But with this method, the time to generate the documentation is much more increased, so I found it not very efficient to add it. If you have other methods I am interested. |
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 implementation currently generates a lot of false-positives (over 2000) most of which look like this:
Link to foreach is not valid
Link to flatMap is not valid
Link to toLeft is not valid
Link to `java.lang.ref.Reference` is not valid
Link to scala.collection.Iterator, method `grouped` is not valid
Link to scala.math.Ordering is not valid
Link to scala.math.Ordering is not valid
Link to scala.collection.Iterator, method `sliding` is not valid
It also generates warnings for valid links, such as:
Link to https://dotty.epfl.ch/docs/reference/changed-features/numeric-literals will return a 404 not found
Thank you very much for your feedback @Florian3k. |
No, I don't think they're supposed to be clickable. |
Okay, so don't need to test them I think. I can just test for internal and external (When I will find a way) link. |
They are not supposed to be clickable. Only links formatted as such I think scaladoc should only check internal links, not all the links. And there should be an option to exclude some paths. See how this is done in Laika, for instance. |
Hi, I looked at how Laika did it to disable the warnings and I noticed two different methods: First methodA yaml in a folder, with each file and sub-folder having a warning validation disabled.
Second methodA yaml with a folder list, all the files in each folder have warning validation disabled
So I plan to do both methods, I think I can do a lot of it. But I'm stuck for the beginning, I don't know how to get the path of a file containing the @see in order to know in which folder it is located. |
Hey @Dedelweiss, thank you very much for the investigation. I keep thinking that only links within double brackets should be checked, not the content of the |
Oh yes, I'm sorry, I did misread your previous comment. Indeed it would be better to target more generally the double brackets links in order to test a maximum of them. I'll correct that. Thanks a lot for the feedback. |
Edited: Indeed, there is a link I can use but the other PR is about double brackets to the API. And this one is about the links in the comments of the codes. So these two RPs are still different. Hey @julienrf, looking into it, I noticed that it came back to this PR#17099 I did earlier. |
@Dedelweiss do you mind elaborating on what is blocking you? I guess for now we can already check links to static pages and assets (which use the regular link and image markup: What do you think? |
I was more stuck on the other PR/Issue with the outcome and question in it. But you have cleared up my doubts very well, thank you very much @julienrf.
Indeed, I think it's interesting to do it like that, so I'll go with that. Thanks for the feedback. |
- Add a check of valid url and internal link - Add condition flag for the warning
8dd0f8f
to
8ddb272
Compare
Hello @julienrf, |
In my opinion, it is very important that “API links” (ie, links to symbols of the API usually written with the wikidoc syntax like Once that is done, it would be really great to support both types of links everywhere (so, including API links in the static pages and pages links in the API docs). All that could be done in separate PRs (especially if the “nice to have” one requires significant development). |
Here is my proposed PR to check that the links in the API comments (@see) are valid and point to valid static documentation.
Validations:
The link is valid
Assets
Example:

Static pages
Example:
[foo](./foo.md)
API documentation
Example:
[[com.example.Foo]]
A validation is already done in Comments.resolveLink. But there is an Issue Warning for link to API doc (Double brackets) are silently ignored #17550
Def ProcessLink:
This function allows to check both that a string is a valid url with the Try, but also that this link leads to an existing static documentation.
When one of these two conditions is not met, a warning is sent when the documentation is generated.
Result:
Disable Validation:
First method
A yaml in a folder, with each file and sub-folder having a warning validation disabled.
Second method
A yaml with a folder list, all the files in each folder have warning validation disabled
Fixes: #16229