Closed Kapeli closed 7 years ago
There was nothing in Go 1.8.1 changing godoc.
Or do you mean before Go 1.8?
Even then, I don't think this is true. We added #anchors in Go 1.8 but didn't change or remove any.
Ah, you're right. The change seems to have happened with the 1.8 release, not 1.8.1.
If you go to this snapshot from Feb 2017 (Go 1.7.5) you'll be able to jump to the TypeBlock constant: https://web.archive.org/web/20170211005446/https://golang.org/pkg/archive/tar/#TypeBlock.
This doesn't work with the live version anymore: https://golang.org/pkg/archive/tar/#TypeBlock.
Notice the span id
in the screenshot below:
There's no more span id
in the latest docs:
Hm, strange.
It'd be nice if somebody could bisect (or manually review godoc commits--- there aren't many) and figure out when we (I?) broke it.
/cc @odeke-em @shurcooL
I bisected x/tools/cmd/godoc
.
The problem starts with https://github.com/golang/tools/commit/e1bdc76d0461f7041136c70e0a1356ea0f5e01d0.
With the parent commit, the generated HTML looks like this:
With https://github.com/golang/tools/commit/e1bdc76d0461f7041136c70e0a1356ea0f5e01d0, you get:
I'm not up to date with how cmd/godoc
handles anchor links in the latest version. I recall seeing some changes that pushed their generation on the frontend via JavaScript. So at this point, I'm not sure if the anchor is supposed to be generated on backend or frontend. I might be misremembering this (perhaps that was for other pages of golang.org, not /pkg/ pages).
/cc @jayconrod
Here's a diff of the generated HTML at localhost:6060/pkg/archive/tar/:
Header type flags.
const ( - TypeReg = '0' // regular file - TypeRegA = '\x00' // regular file - TypeLink = '1' // hard link - TypeSymlink = '2' // symbolic link - TypeChar = '3' // character device node - TypeBlock = '4' // block device node - TypeDir = '5' // directory - TypeFifo = '6' // fifo node - TypeCont = '7' // reserved - TypeXHeader = 'x' // extended header - TypeXGlobalHeader = 'g' // global extended header - TypeGNULongName = 'L' // Next file has a long name - TypeGNULongLink = 'K' // Next file symlinks to a file w/ a long name - TypeGNUSparse = 'S' // sparse file + TypeReg = '0' // regular file + TypeRegA = '\x00' // regular file + TypeLink = '1' // hard link + TypeSymlink = '2' // symbolic link + TypeChar = '3' // character device node + TypeBlock = '4' // block device node + TypeDir = '5' // directory + TypeFifo = '6' // fifo node + TypeCont = '7' // reserved + TypeXHeader = 'x' // extended header + TypeXGlobalHeader = 'g' // global extended header + TypeGNULongName = 'L' // Next file has a long name + TypeGNULongLink = 'K' // Next file symlinks to a file w/ a long name + TypeGNUSparse = 'S' // sparse file )
var ( - ErrWriteTooLong = errors.New("archive/tar: write too long") - ErrFieldTooLong = errors.New("archive/tar: header field too long") - ErrWriteAfterClose = errors.New("archive/tar: write after close") + ErrWriteTooLong = errors.New("archive/tar: write too long") + ErrFieldTooLong = errors.New("archive/tar: header field too long") + ErrWriteAfterClose = errors.New("archive/tar: write after close") )
var ( - ErrHeader = errors.New("archive/tar: invalid tar header") + ErrHeader = errors.New("archive/tar: invalid tar header") )@@ -409,11 +409,11 @@
func FileInfoHeader(fi os.FileInfo, link string) (*Header, error)+
func FileInfoHeader(fi os.FileInfo, link string) (*Header, error)
FileInfoHeader creates a partially-populated Header from fi. If fi describes a symlink, FileInfoHeader records link as the link target. If fi describes a directory, a slash is appended to the name. Because os.FileInfo's Name method returns only the base name of @@ -428,11 +428,11 @@
func (h *Header) FileInfo() os.FileInfo+
func (h *Header) FileInfo() os.FileInfo
FileInfo returns an os.FileInfo for the Header.
@@ -467,11 +467,11 @@func NewReader(r io.Reader) *Reader+
func NewReader(r io.Reader) *Reader
NewReader creates a new Reader reading from r.
@@ -481,11 +481,11 @@func (tr *Reader) Next() (*Header, error)+
func (tr *Reader) Next() (*Header, error)
Next advances to the next entry in the tar archive.
io.EOF is returned at the end of the input. @@ -497,11 +497,11 @@
func (tr *Reader) Read(b []byte) (int, error)+
func (tr *Reader) Read(b []byte) (int, error)
Read reads from the current entry in the tar archive. It returns 0, io.EOF when it reaches the end of that entry, until Next is called to advance to the next entry.
@@ -543,11 +543,11 @@func NewWriter(w io.Writer) *Writer+
func NewWriter(w io.Writer) *Writer
NewWriter creates a new Writer writing to w.
@@ -557,11 +557,11 @@func (tw *Writer) Close() error+
func (tw *Writer) Close() error
Close closes the tar archive, flushing any unwritten data to the underlying writer.
@@ -571,11 +571,11 @@func (tw *Writer) Flush() error+
func (tw *Writer) Flush() error
Flush finishes writing the current file (optional).
@@ -584,11 +584,11 @@func (tw *Writer) Write(b []byte) (n int, err error)+
func (tw *Writer) Write(b []byte) (n int, err error)
Write writes to the current entry in the tar archive. Write returns the error ErrWriteTooLong if more than hdr.Size bytes are written after WriteHeader.
@@ -599,11 +599,11 @@func (tw *Writer) WriteHeader(hdr *Header) error+
func (tw *Writer) WriteHeader(hdr *Header) error
WriteHeader writes hdr and prepares to accept the file's contents. WriteHeader calls Flush if it is not the first header. Calling after a Close will return ErrWriteAfterClose.
```@shurcooL, thanks!
/cc @jayconrod @alandonovan
I looked into this today. After my change, linksFor
generates empty links for const and var declarations. Previously, it included the identifier name. LinkifyText
skips over these, since it doesn't know what id to write.
I should have a fix for this tomorrow.
Thanks!
CL https://golang.org/cl/40300 mentions this issue.
Reopening for cherry-pick.
Any chance the golang.org docs could be regenerated using the fixed version of godoc?
@Kapeli, yes, that's what I mean by "reopening for cherry-pick".
@bradfitz, you said "reopening", but the issue continues to be closed. Is there a different meaning to the word "reopening", or did you forget to actually reopen it?
Forgot.
Cherry-pick doesn't apply cleanly. I've asked @jayconrod to take a look.
Cherry-pick doesn't apply cleanly.
https://github.com/golang/tools/commit/3bcb6efb399c5289003b99a1c165bd9797ff406c (the commit that closed this issue) is a minor patch/bug fix for https://github.com/golang/tools/commit/e1bdc76d0461f7041136c70e0a1356ea0f5e01d0, where this regression was introduced. But the corresponding issue for that commit is milestoned for Go 1.9. If it's not a part of 1.8 release, then this fixup shouldn't be needed either.
@shurcooL, thanks!
Confirming what @shurcooL said, this bug is not on the 1.8 branch and does not need to be cherry-picked.
Before 1.8.1, I was able to go to https://golang.org/pkg/archive/tar/#TypeBlock and it would scroll to the relevant constant. This no longer works.
Somewhat related: this makes it impossible for Dash to index constants and variables in the Go docs.