golang / gddo

Go Doc Dot Org
https://godoc.org
BSD 3-Clause "New" or "Revised" License
1.1k stars 265 forks source link

Inferred package links not always correct. #525

Open ChrisHines opened 6 years ago

ChrisHines commented 6 years ago

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.

jackwilsdon commented 6 years ago

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

ChrisHines commented 6 years ago

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

dmitshur commented 6 years ago

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

jackwilsdon commented 6 years ago

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