gddo icon indicating copy to clipboard operation
gddo copied to clipboard

Inferred package links not always correct.

Open ChrisHines opened this issue 6 years ago • 4 comments

The first sentence of the package docs for github.com/go-kit/kit/log/level reads:

// Package level implements leveled logging on top of package log.

Godoc.org magically makes the word "log" into a link to the standard library log package, when in fact it is referring to the package github.com/go-kit/kit/log.

ChrisHines avatar Nov 07 '17 13:11 ChrisHines

It looks like GoDoc replaces any instances of the text package <name> with a link to that package, which explains why you're seeing just a link to the log package.

Without changing any of the functionality of GoDoc, the easiest thing to do is rephrase the comment;

// Package level implements leveled logging on top of the log package.

Here's the lines of interest; https://github.com/golang/gddo/blob/574849d519ec3acb591fc5620ee0aa3ea48081e0/gddo-server/template.go#L391-L404

Where packagePat is this; https://github.com/golang/gddo/blob/574849d519ec3acb591fc5620ee0aa3ea48081e0/gddo-server/template.go#L341

jackwilsdon avatar Sep 17 '18 02:09 jackwilsdon

Thanks for doing the research to figure that out. Rephrasing the comment is doable.

ChrisHines avatar Sep 17 '18 03:09 ChrisHines

/cc @dsnet FYI. This issue is something to be aware of when trying to linkify identifiers within the docs.

dmitshur avatar Sep 17 '18 16:09 dmitshur

It also looks like it does something similar for RFCs (and converting h3s to h4s, but that's not as interesting);

https://github.com/golang/gddo/blob/574849d519ec3acb591fc5620ee0aa3ea48081e0/gddo-server/template.go#L340

https://github.com/golang/gddo/blob/574849d519ec3acb591fc5620ee0aa3ea48081e0/gddo-server/template.go#L376-L390

jackwilsdon avatar Sep 17 '18 17:09 jackwilsdon