Skip to content
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

cmd/doc: show Bugs section #33970

Closed
pascaldekloe opened this issue Aug 30, 2019 · 12 comments
Closed

cmd/doc: show Bugs section #33970

pascaldekloe opened this issue Aug 30, 2019 · 12 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@pascaldekloe
Copy link
Contributor

The new go doc does not show documented bugs conform the convention.

For example, go doc -all godoc.org/pascaldekloe/jwt | grep -i bug has no results. The HTML representation catches the comments correctly at https://godoc.org/github.com/pascaldekloe/jwt#pkg-note-bug .

Bugs are an essential part of the documentation.

  • go doc -all should have a bugs section (like godoc(8) does)
  • go doc <selection> should include the relevant bugs for the respective selection
@agnivade
Copy link
Contributor

Sounds reasonable to me.

@robpike @mvdan

@agnivade agnivade changed the title BUG documentation unavailable on command line cmd/doc: show Bugs section Aug 30, 2019
@agnivade agnivade added FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed Documentation labels Aug 30, 2019
@agnivade agnivade added this to the Unplanned milestone Aug 30, 2019
@pascaldekloe
Copy link
Contributor Author

Technically this is not a feature. The old godoc had bug listing on the command line.

@agnivade
Copy link
Contributor

Right. But cmd/doc didn't. So it is a feature request for cmd/doc. But I get what you mean :).

@mvdan
Copy link
Member

mvdan commented Aug 30, 2019

I assume that @ianthehat or @dmitshur have some ideas here, since I undesrtand they plan on sharing more code between similar tools like go doc and gddo.

@pascaldekloe
Copy link
Contributor Author

The old go doc als listed bugs correctly @agnivade. I see now how my description is a bit misleading. This is a bug, or maybe an undocumented feature los. 😏

@mvdan
Copy link
Member

mvdan commented Aug 30, 2019

Are you positive? If so, can you reproduce that with a specific old version of Go? For example, see https://godoc.org/golang.org/dl, or the Docker images.

@pascaldekloe
Copy link
Contributor Author

Yes, version 1.11 of go doc (without any flags) reports the bugs section nicely.

@robpike
Copy link
Contributor

robpike commented Aug 31, 2019

It already mostly does this. Try 'go doc strings, or go doc -all strings, which is equivalent functionality to what the the godoc` server shows for the package, and you will see:

BUG: The rule Title uses for word boundaries does not handle Unicode punctuation properly.

If you are asking that the bug information be shown always, I disagree, as go doc TrimFunc should not display the output for a bug about Title.

What it does not do is show the bug if you explicitly ask about Title. That should be fixed.

@agnivade
Copy link
Contributor

Aha ! It shows it as part of the function itself. I was searching for a separate section like godoc shows. My bad, I should have grepped for "BUG".

@robpike - Do you think it makes sense to move all BUGs and show them as a separate section at the bottom like godoc does ? Apart from also showing them when someone explicitly asks for that function/method.

@pascaldekloe
Copy link
Contributor Author

pascaldekloe commented Aug 31, 2019

The strings package example has a BUG comment embedded into the function comment block. In that case go doc prints the bugs section indeed. However, the detection fails with the -all flag, and the comment block is printed as is, including (rsc) marker.

% go doc strings | tail -n 5
type Replacer struct{ ... }
    func NewReplacer(oldnew ...string) *Replacer

BUG: The rule Title uses for word boundaries does not handle Unicode punctuation properly.

% go doc -all strings | grep -i bug -B 2 -A 3
    words mapped to their Unicode title case.

    BUG(rsc): The rule Title uses for word boundaries does not handle Unicode
    punctuation properly.

func ToLower(s string) string
% go doc github.com/pascaldekloe/jwt | grep -i bug
% ~/sdk/go1.11.6/bin/go !*
~/sdk/go1.11.6/bin/go doc github.com/pascaldekloe/jwt | grep -i bug
BUG: Some broken implementations fail to parse tokens
% 

So it turns out there are 32 issues.

  1. The -all flag disables bug comment detection.
  2. Go version 1.13 no longer detects bug comments in blocks.
  3. Go should include bug notes with a selection where applicable [new feature].

How to proceed? Shall I split this issue up into separate reports?

@pascaldekloe
Copy link
Contributor Author

include bug notes with a selection where applicable

Bit of a rabbit hole. Do we include a function body and all of its functions invoked? 😅 Also, doc.reader clears the Body of each ast.FuncDecl now to save some memory, so the location information is lost.

@gopherbot
Copy link

Change https://go.dev/cl/511935 mentions this issue: cmd/doc: print bugs with -all flag

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 7, 2023
@dmitshur dmitshur modified the milestones: Unplanned, Go1.22 Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants