-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
all: builders and TryBots should check documentation for broken links #37047
Comments
Thanks for opening an issue about this. I agree it's not entirely trivial, but if implemented in a way that doesn't cause too much noise or false positives, I also agree that this would be helpful. I believe @jayconrod wanted this too. I can't find an existing issue; it may have been a comment in a CL. Edit: Found it, it was this comment in a CL. |
Thinking about this some more: we have control over |
Hello, I'm newbee in golang but want to dive in the core code. |
@alain91, the tricky part of this issue will likely be getting the rendered documentation (in order to obtain the links it contains), and indexing that documentation (in order to be able to detect broken relative links). I'm not familiar with that part of the codebase myself, so I don't know how accessible it would be to a newcomer. |
I'm only newcomer in go. I have experience with parser, html decoder... |
@bcmills I took a crack at implementing something like this. This just walks the filepath, generates documentation html, then calls HEAD on any tag values with an
Without ignoring external links (just ignoring localhost and example URLs) I get:
That proxy link represents the default That issue link (found in docs here) returns a 404 because of a trailing period (created issue #37640 to track this). Both of the ARM links are actually broken (here and here in docs). I am not sure if/how this should be included in the trybots since I am not familiar with how exactly they are configured. |
I sent go.dev/cl/548059 to check all links inside the go.dev server. I will leave this open to track potentially checking #fragment too. |
Change https://go.dev/cl/548059 mentions this issue: |
Test that links are to /foo not https://go.dev/foo and also check that the links actually point at real pages. Manually fix problems that the test found. For golang/go#37047. Change-Id: I825eec3c2cadb9d259caff51cd893f3023ab533a Reviewed-on: https://go-review.googlesource.com/c/website/+/548059 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change https://go.dev/cl/601656 mentions this issue: |
Copying the test to the main Go repository requires vendoring x/net/html as a test-only dependency, which works (prototype in go.dev/cl/600816) but adds size and requires a copy of the test to be maintained in an extra place. Instead, reuse x/website's test by invoking it as a trybot. This is viable because x/website tests pick up main Go tree content from the runtime.GOROOT() directory, which is what the trybot ends up using as its Go version. (Checked in go.dev/cl/601039.) For golang/go#37047. Fixes golang/go#68633. Change-Id: I69cc638c489cbb847e7b46e4af90e0197ddd6695 Reviewed-on: https://go-review.googlesource.com/c/build/+/601656 Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
We occasionally end up with broken or outdated links in documentation (see #46545, #37042 (comment), #27860, #21951, #19244).
Testing for broken links would not be entirely trivial, but nonetheless pretty straightforward to implement: we have an HTML parser in
golang.org/x/net/html
, and it is easy enough to issue aHEAD
request for link targets to see if they resolve. (For links with anchors, we would probably want to also check theContent-Type
header and then parse the actual linked HTML to ensure that the anchor exists.)CC @golang/osp-team
The text was updated successfully, but these errors were encountered: