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

x/tools/cmd/godoc: add -tags like go build #3398

Open
ugorji opened this issue Mar 26, 2012 · 16 comments
Open

x/tools/cmd/godoc: add -tags like go build #3398

ugorji opened this issue Mar 26, 2012 · 16 comments
Milestone

Comments

@ugorji
Copy link
Contributor

ugorji commented Mar 26, 2012

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull", "hg update default", rebuild, and
retry
what you did to reproduce the problem.  Thanks.

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Run godoc on a package having some files with build constraints e.g. // +build ignore
2. The files are skipped by godoc and their contents are not reflected in godoc output.
I don't see the files listed either.
3.

What is the expected output?

I expected to see the information in godoc.

What do you see instead?
Nothing.

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')
Running at tip, but go version gives:
go version weekly.2012-03-22 +de7e784537ac

Please provide any additional information below.
@rsc
Copy link
Contributor

rsc commented Mar 26, 2012

Comment 1:

godoc ignores files that say "// +build ignore".
It uses the files that would be built by go build.
That seems like it is working as intended.
Maybe after Go 1 we could give godoc a flag to
allow the specification of additional build tags,
like go build's -tags.
Russ

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@ugorji
Copy link
Contributor Author

ugorji commented Mar 27, 2012

Comment 2:

That would be nice.
I stumbled upon this because I tagged some of my code which should only run on an
appengine instance with // +build appengine. After that, I couldn't see them anymore
using godoc. My only solution seemed to be to remove the build constraints.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 3:

Labels changed: added go1.1maybe.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 4:

Labels changed: added size-m.

@rsc
Copy link
Contributor

rsc commented Mar 12, 2013

Comment 5:

[The time for maybe has passed.]

Labels changed: removed go1.1maybe.

@adg
Copy link
Contributor

adg commented Mar 18, 2013

Comment 6:

Labels changed: added godoc.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 7:

Labels changed: added go1.2.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 8:

Labels changed: added feature.

@robpike
Copy link
Contributor

robpike commented Aug 21, 2013

Comment 9:

This would be nice, but it won't happen for Go 1.2.

Labels changed: removed go1.2.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 10:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 11:

Labels changed: removed feature.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 12:

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

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 13:

Labels changed: added repo-tools.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/godoc: add -tags like go build x/tools/cmd/godoc: add -tags like go build Apr 14, 2015
@rsc rsc removed the repo-tools label Apr 14, 2015
@jeffallen
Copy link
Contributor

If you are someone like me who just stumbled across this old bug and are looking for a quick hack to solve your problem right now, use "go get golang.org/x/tools" to get the godoc source code then hack it like this:

diff --git a/godoc/server.go b/godoc/server.go
index 3b452e5e..d231425e 100644
--- a/godoc/server.go
+++ b/godoc/server.go
@@ -64,6 +64,7 @@ func (h *handlerServer) GetPageInfo(abspath, relpath string, mode PageInfoMode,
 	// Note: If goos/goarch aren't set, the current binary's GOOS/GOARCH
 	// are used.
 	ctxt := build.Default
+	ctxt.BuildTags = []string{"vartime"}
 	ctxt.IsAbsPath = pathpkg.IsAbs
 	ctxt.IsDir = func(path string) bool {
 		fi, err := h.c.fs.Stat(filepath.ToSlash(path))

Then use "go build" to build a local copy of godoc that is using the build tags you need.

@gopherbot
Copy link

Change https://golang.org/cl/129099 mentions this issue: x/tools/cmd/godoc: add -tags like go build

@SchumacherFM
Copy link
Contributor

Good evening,

as I currently need this feature in godoc to display documentation for specific build tags, I've added it to godoc. It took me a couple of days and I think it is ready for review 😊.
See the CL https://golang.org/cl/129099

Below I've added some printscreens how the design looks like for HTML and CLI.
If there are better ideas to display the build tag information, let me know.

It would be great if some one from the Go Team, etc can review the code.

screen shot 2018-08-12 at 7 43 40 pm

screen shot 2018-08-12 at 7 45 09 pm

screen shot 2018-08-12 at 7 45 41 pm

screen shot 2018-08-12 at 7 46 01 pm

screen shot 2018-08-12 at 7 47 45 pm

screen shot 2018-08-12 at 7 48 29 pm

screen shot 2018-08-12 at 7 50 54 pm

SchumacherFM added a commit to SchumacherFM/tools that referenced this issue Aug 12, 2018
The specified build tags in the -tags flag for the godoc command
parses additional Go source files. All identifiers are getting listed
alongside with the information from which build tag they originate.

Fixes golang/go#3398

Change-Id: Ifcb716303d7c77ff5348156115197ea9b06c9dc2
SchumacherFM added a commit to SchumacherFM/tools that referenced this issue Aug 27, 2018
The specified build tags in the -tags flag for the godoc command
parses additional Go source files. All identifiers are getting listed
alongside with the information from which build tag they originate.

Fixes golang/go#3398

Change-Id: Ifcb716303d7c77ff5348156115197ea9b06c9dc2
SchumacherFM added a commit to SchumacherFM/tools that referenced this issue Sep 6, 2018
The specified build tags in the -tags flag for the godoc command
parses additional Go source files. All identifiers are getting listed
alongside with the information from which build tag they originate.

Fixes golang/go#3398

Change-Id: Ifcb716303d7c77ff5348156115197ea9b06c9dc2
SchumacherFM added a commit to SchumacherFM/tools that referenced this issue Oct 14, 2018
The specified build tags in the -tags flag for the godoc command
parses additional Go source files. All identifiers are getting listed
alongside with the information from which build tag they originate.

Fixes golang/go#3398

Change-Id: Ifcb716303d7c77ff5348156115197ea9b06c9dc2
SchumacherFM added a commit to SchumacherFM/tools that referenced this issue Nov 6, 2018
The specified build tags in the -tags flag for the godoc command
parses additional Go source files. All identifiers are getting listed
alongside with the information from which build tag they originate.

Fixes golang/go#3398

Change-Id: Ifcb716303d7c77ff5348156115197ea9b06c9dc2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants