golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.07k stars 17.68k forks source link

x/tools/cmd/godoc: comments in [][]T are omitted in doc rendering #6917

Open kortschak opened 10 years ago

kortschak commented 10 years ago
What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. mkdir foo && cd foo
2. curl http://play.golang.org/p/MdnYIPw4Ee.go > foo.go
3. godoc .

What is the expected output?

PACKAGE DOCUMENTATION

package foo
    import "."

VARIABLES

var NUC_4 = [][]int{
    /*       - A C G T */
    /* - */ {0, 0, 0, 0, 0},
    /* A */ {0, 5, -4, -4, -4},
    /* C */ {0, -4, 5, -4, -4},
    /* G */ {0, -4, -4, 5, -4},
    /* T */ {0, -4, -4, -4, 5},
}

What do you see instead?

PACKAGE DOCUMENTATION

package foo
    import "."

VARIABLES

var NUC_4 = [][]int{

    {0, 0, 0, 0, 0},
    {0, 5, -4, -4, -4},
    {0, -4, 5, -4, -4},
    {0, -4, -4, 5, -4},
    {0, -4, -4, -4, 5},
}

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Linux

Which version are you using?  (run 'go version')
go1.2
go.tools 25a7477727f3

Please provide any additional information below.
robpike commented 10 years ago

Comment 1:

This is a tool bug but godoc is included in the release. Looks like a serious bug,
relatively speaking: godoc shouldn't throw away comments. It's probably easy to fix,
though. Tagging for 1.3.

Labels changed: added repo-tools, release-go1.3.

Owner changed to @griesemer.

Status changed to Accepted.

griesemer commented 10 years ago

Comment 2:

This is non-trivial to fix: At the moment, godoc shows only comments that are collected
by go/doc; and go/doc only collects comments that are associated with a declaration
(above, or on the same line).
It should be possible to use the newer CommentMap mechanism instead (or in addition),
but that will require quite a bit of re-engineering in go/doc and godoc.
This should be fixed eventually, but before putting in the work, the long-term strategy
of go/ast, go/doc, and friends needs to be worked out first. There are higher-priority
issues for 1.3.

Labels changed: added release-none, removed release-go1.3.

Owner changed to ---.

Status changed to LongTerm.