1
0
mirror of https://github.com/golang/go synced 2024-10-01 05:18:33 -06:00
Commit Graph

333 Commits

Author SHA1 Message Date
Kevin Burke
4bc20fc791 godoc: fix indenting on Firefox
See comment in the patch for an explanation, Firefox (specifically
with the Menlo font) does not like tabs beginning in column 9, so we
start it in column 10.

Updates webcompat/web-bugs#17530
Fixes golang/go#26316
Fixes golang/go#23500

Change-Id: I4c96118b8c3b13ee1fd21ce85bd7c681e99a4b4f
Reviewed-on: https://go-review.googlesource.com/131716
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-08-30 21:44:40 +00:00
Brad Fitzpatrick
f6ba574295 godoc/dl: update Mac & Windows minimum versions
Updates golang/go#27213

Change-Id: I25813e9aafcdb39d4f93e27b98d8672c770234a6
Reviewed-on: https://go-review.googlesource.com/131402
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-08-26 00:09:51 +00:00
Agniva De Sarker
b776bcbf45 godoc/vfs: improve comment on GOROOT
GOROOT is not a function, so use "is" instead of "returns".
This was originally raised during review of golang.org/cl/131315.

Also add a missing period.

Change-Id: Ie28d38529889702ae5035d0f48d8122b6bee6819
Reviewed-on: https://go-review.googlesource.com/131316
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2018-08-26 00:05:47 +00:00
Agniva De Sarker
6c1c5e93cd godoc/vfs: reorder comment paras to display the correct one
This is a fixup for golang.org/cl/130796.

Change-Id: If151325738b59ab61a7b456a140d3bc8dff57b9c
Reviewed-on: https://go-review.googlesource.com/131315
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2018-08-24 17:52:16 +00:00
Agniva De Sarker
ba93f9405e godoc: update to use new goroot finding logic
The logic to determine whether a filesystem root was in GOROOT or GOPATH
still relied on runtime.GOROOT(), whereas cmd/godoc was updated to copy
the goroot finding logic from standard library.

Hence, godoc is unable to determine if a filesystem is in GOROOT or not
when the binary is outside runtime.GOROOT(). So we expose a new variable
and set that from cmd/godoc to avoid copying the logic again for the 3rd time.

Fixes golang/go#27162

Change-Id: I160dcdbdd262e671f09f7bf01c329be5eac280ad
Reviewed-on: https://go-review.googlesource.com/130796
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-23 15:26:32 +00:00
Kazuhiro Sera
4354ead92e all: fix typos in comments
This pull request fixes several typos in comments. I believe that they're safe enough.

Change-Id: Ic7c594bdb89dcd04f8775f225abbc0f966f3728e
GitHub-Last-Rev: 2394feb263714c83b419f45eccb3c6c9fdff7fed
GitHub-Pull-Request: golang/tools#45
Reviewed-on: https://go-review.googlesource.com/128956
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-10 18:15:57 +00:00
Russ Cox
ad8705d9f6 godoc/redirect: redirect design docs to Gerrit, not GitHub
Gerrit's rendering is cleaner and Gerrit is the source of truth anyway.

Fixes golang/go#26871.

Change-Id: I0bf69d174662c7acc083b03b009bac92f781a17c
Reviewed-on: https://go-review.googlesource.com/128596
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-08-08 21:07:32 +00:00
Mostyn Bramley-Moore
9e9f7f69ec godoc: skip build tag annotations when displaying examples
After moving the filepath.Walk example to a standalone example file
in CL 122237 (so it could use a standalone function), godoc includes
the build tag annotation ("// +build !windows,!plan9" in this case)
in the runnable example.  The example runs correctly, but the
annotation might be confusing for new users.

Change the behavior so that godoc skips these annotations when
displaying examples.

To avoid false positives in older versions of "go vet", which are still used
on the build dashboard, we avoid using a multiline string in the test.

Fixes golang/go#26490.

Change-Id: I1da4b3b7e1e5a85a76773e25d9355b3f92479c19
GitHub-Last-Rev: bc5ed29bd368e5bcf11fed7a0c7f14b872fef065
GitHub-Pull-Request: golang/tools#42
Reviewed-on: https://go-review.googlesource.com/126256
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-31 18:38:43 +00:00
Andrew Bonventre
0700b576e4 godoc: don't display tar instructions for malformed download query
Ensure that the filename passed via ?download= matches the given
regexp before showing the command-line instructions to download it.

Change-Id: Ieb7c6912409474f31637ff1193fd195eb9f172b3
Reviewed-on: https://go-review.googlesource.com/126717
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-07-30 21:13:59 +00:00
Andrew Bonventre
bfb5194568 Revert "godoc: skip build tag annotations when displaying examples"
This reverts commit faa8a71ab5.

Reason for revert: +build tag in test causes build to fail :(

Change-Id: I8942a6dcc29faaceada23b63ba80ea881b3b2ca6
Reviewed-on: https://go-review.googlesource.com/126195
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-26 21:04:03 +00:00
Mostyn Bramley-Moore
faa8a71ab5 godoc: skip build tag annotations when displaying examples
After moving the filepath.Walk example to a standalone example file
in CL 122237 (so it could use a standalone function), godoc includes
the build tag annotation ("// +build !windows,!plan9" in this case)
in the runnable example.  The example runs correctly, but the
annotation might be confusing for new users.

With this change, godoc skips these annotations when displaying examples.

Fixes golang/go#26490.

Change-Id: Ice3d6a2ce4db5b5176c9c6fcabc01b69c323016d
GitHub-Last-Rev: 52beabd3d2a9cb9a556bfa3bd998a2e31ac96960
GitHub-Pull-Request: golang/tools#40
Reviewed-on: https://go-review.googlesource.com/125040
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-26 20:38:08 +00:00
Brad Fitzpatrick
65cc56d756 godoc: fix tests on Go 1.9
Updates golang/go#11811
Updates golang/go#26531

Change-Id: I9cc7daf551b76c3f06b9dd827c5733513c06895e
Reviewed-on: https://go-review.googlesource.com/125816
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-25 19:11:30 +00:00
Gustav Westling
60ffea201e godoc: correctly parse packages with digits in the package name
Fixes golang/go#26514

Change-Id: I4540737425c225c0f0c6104b5b3524621d2b0c6f
GitHub-Last-Rev: 9d5fefb6ed31579b723293c7f43fcf677ac4cddb
GitHub-Pull-Request: golang/tools#41
Reviewed-on: https://go-review.googlesource.com/125335
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-22 15:00:05 +00:00
Brad Fitzpatrick
99195f4d4f godoc/dl: also serve go-import meta tags at golang.org/dl for cmd/go
Updates golang/go#23223

Change-Id: Iacecbb5e095fd3d6acb3f8e1fb238db63d1e0b6d
Reviewed-on: https://go-review.googlesource.com/125195
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-20 05:57:21 +00:00
Brad Fitzpatrick
827f47db85 godoc/dl: add meta tags for go get golang.org/dl/go1.N
Updates golang/go#23223

Change-Id: I628cea181d3a0e6bb25fdd98e098581aa222e049
Reviewed-on: https://go-review.googlesource.com/123679
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-20 03:34:01 +00:00
Andrew Bonventre
42aedba1e0 godoc/dl: update download link from /x/build/version to /dl
Change-Id: Id2baaa87ab23e27ce5018271c8bb4e73750fb437
Reviewed-on: https://go-review.googlesource.com/125137
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-20 03:31:16 +00:00
Brad Fitzpatrick
32950ab3be godoc: add version info for struct fields
Follow-up to CL 85396, which only did types, funcs, and methods.

This adds version info to struct fields (in the form of small
comments) if the struct field's version is different from the struct
itself, to minimize how often this fires.

Updates golang/go#5778

Change-Id: I34d60326cbef88c108d5c4ca487eeb98b039b16e
Reviewed-on: https://go-review.googlesource.com/124495
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Devon O'Dell <dhobsd@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-17 23:22:00 +00:00
Devon H. O'Dell
57f659e14d godoc: show version information for stdlib
This change reads $GOROOT/api/go1.*.txt when godoc starts and caches
information about which versions of Go introduce functions, types, and
methods. This information is displayed currently only in HTML output.
Functions, types, and methods introduced as part of Go 1 are not
annotated, as their presence at that version is implied.

This change does not address constants or variables, and completely
ignores the syscall package. The former are future work, the latter is
likely an exercise in futility. In all cases, this is because the story
around displaying the version information is not well developed.

Fixes golang/go#5778

Change-Id: Ieb3cc0da7b18e195bc9c443f14fd8a82e8b2bbf8
Reviewed-on: https://go-review.googlesource.com/85396
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Devon O'Dell <dhobsd@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-17 18:09:30 +00:00
Brad Fitzpatrick
1c99e1239a godoc: default to GOOS/GOARCH js/wasm when rendering syscall/js docs
Otherwise it was just blank. With this CL, this URL should start rendering docs:

   https://tip.golang.org/pkg/syscall/js/

Tested locally.

Change-Id: I2d9b7286f374e9372be372987bb5d12ce5044ce9
Reviewed-on: https://go-review.googlesource.com/121315
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-28 16:39:57 +00:00
Agniva De Sarker
3c1bb8b785 godoc: accept scanner.RawString too during EBNF parsing
Commit c8915a0696 changed the text/scanner
package to return a scanner.RawString (rather than a scanner.String) token
for raw string literals. This broke the EBNF parser which didn't look
for scanner.RawString.

Updated the EBNF parser code to reflect that change.

Fixes golang/go#25986

Change-Id: Ib9c133a7c357dd750a4038d2ed39be86a245995c
Reviewed-on: https://go-review.googlesource.com/120659
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-25 04:25:21 +00:00
Alan Donovan
53440098a4 godoc/static: resolve merge conflict, committed in error
Change-Id: Ica50edbae03eb1c6efad702841b926ffaf1c98ec
Reviewed-on: https://go-review.googlesource.com/119476
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-06-18 17:10:13 +00:00
Alan Donovan
e10d6c9a84 godoc/static: use a stable quote function
Printf(%q) aka strconv.AppendQuote depends on the Unicode tables du
jour, which means gen_test breaks after a Go release in which Unicode
evolves. This change uses a very dumb quotation function that emits
only ASCII and is independent of the Go release.

Perhaps an even better fix would have been to parse the generated file.

Change-Id: I197942f1c36a8b53d6a37be4bb2b1e63a208f7e2
Reviewed-on: https://go-review.googlesource.com/119157
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-18 16:36:09 +00:00
Agniva De Sarker
465e6f3992 godoc: add link to expand/close all examples
Fixes golang/go#3081

Change-Id: I096b22691a08d72b88dbe925e17893d24ba3c992
Reviewed-on: https://go-review.googlesource.com/118935
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 19:57:36 +00:00
Alan Donovan
903a227b9b godoc/static: mimic the pre-1.10 behavior of strconv.Quote
Thanks to iant for identifying the root cause.

Tested with go1.9 and go1.10.

Fixes golang/go#25880

Change-Id: Ibc3a2aadd92c1e512cf6c537134ee085398e8e6c
Reviewed-on: https://go-review.googlesource.com/118955
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-14 19:21:16 +00:00
Alan Donovan
49ce10d933 godoc/static: suppress gen_test on go1.9
Either string quotation or Go formatting has since changed.
Will investigate later, but this fixes the dashboard for now.

Change-Id: Ieab3800fc2c24ba86026d25dea12853131c04948
Reviewed-on: https://go-review.googlesource.com/118715
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-14 18:36:27 +00:00
Andy Lindeman
e1f909067f godoc: correct abspath when looking for cmds
godoc is erroneously detecting paths like syscall and unsafe as possible
commands.

A previous attempt at a fix adjusted the parameters of pkgHandler in
pres.go, but that change had unexpected ripple effects that broke links
and other features of godoc. This change is scoped only to the godoc
command line tool.

cmdline_test.go is updated to match the parameters used in the real
pkgHandler in pres.go.

Fixes golang/go#14447

Change-Id: I8f740c6847e46523b8443722b16942192bdf9cb8
GitHub-Last-Rev: cfc24f2d4c3519c4c87628b2021f65a4725cda6b
GitHub-Pull-Request: golang/tools#27
Reviewed-on: https://go-review.googlesource.com/96515
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-13 15:42:59 +00:00
Robert Griesemer
02fcd6aaf1 godoc: fix test failure
Adjust code to satisfy vet.

Change-Id: I532b4d988eb29b413520de60b8520d9e100b42c9
Reviewed-on: https://go-review.googlesource.com/118557
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-13 15:25:43 +00:00
Filippo Valsorda
4e38c85762 godoc/dl: add valsorda to users allowed to upload
Change-Id: Iac4a80b030be9c275323a27d2dfba4f83942cbf9
Reviewed-on: https://go-review.googlesource.com/117195
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-07 18:59:51 +00:00
Yury Smolsky
a5b4c53f6e playground.js: display vet errors when program has no output
When program has no output and vet errors are encountered,
initialize data.Events as an empty array.

Fixes golang/go#25455.

Change-Id: Icedd77685b784505da3bb6383629cdfa8b8b22e9
Reviewed-on: https://go-review.googlesource.com/113875
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-25 02:41:13 +00:00
Yury Smolsky
48418e5732 godoc: display "go vet" errors before the output of a program
This change adds an option to run "go vet" for the playground program
and display errors before any output. To enable this, the playground
function has to be supplied with opts.enableVet set to true.
Vet check is performed only for succesfully run programs,
meaning that the "/compile" endpoint returned no errors.

This change highlights lines printed to stderr as errors (in red).

There is a corresponding change for the Playground: CL 100776.

Updates golang/go#7597
Updates golang/go#24576

Change-Id: I8c0f8c1189c461338b5bce57777b12aecab268fb
Reviewed-on: https://go-review.googlesource.com/107455
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-08 19:22:17 +00:00
jimmyfrasche
76f5b51ce4 x/tools/godoc: make front page video respond to layout changes (2/2)
This part of a multi-repo change. See CL 108677 for details.

Note: this change also requires a CL to golang/go to complete the fix,
though either CL without the other is harmless.

Updates golang/go#24997.

Change-Id: I99ca9a4e6df16347b8706f24cef9689b3345854a
Reviewed-on: https://go-review.googlesource.com/108678
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-08 19:21:29 +00:00
Agniva De Sarker
ae8027637c godoc/static: add test for static.go file generation
Moved the code which generates static.go to remain in the static package.
This makes the code testable.

Additionally, it is very easy for developers to forget to run "go generate"
to update static.go. Because while development, the templates directory
can be directly passed as a flag to read the files from it.

This test catches that.

Change-Id: I314907b98907bb14e4eabfd3c532ba2d84ce7c5f
Reviewed-on: https://go-review.googlesource.com/110158
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-03 19:34:25 +00:00
Jeevanandam M
f4ce24f1d8 godoc/static: cleanup unused lines in makestatic.go
Change-Id: I9b930efb5efd4b32c41c40d2399e04bacd75b470
GitHub-Last-Rev: 53db7899927e5ae255310c6a765526a10552649f
GitHub-Pull-Request: golang/tools#36
Reviewed-on: https://go-review.googlesource.com/111155
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 05:28:33 +00:00
Agniva De Sarker
a25dedfa53 godoc: set the GOROOT path properly in cmdline mode
- Setting the GOROOT build path to the value passed from the command line.

- Clarified the return values to named parameters for extra clarity.

- And while here, added some missed out error handling. Just logging the error
to preserve original behavior.

Fixes golang/go#13296

Change-Id: I91427eee790928a3cfb51ae207747e9a17bd5496
Reviewed-on: https://go-review.googlesource.com/110275
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-02 17:46:13 +00:00
Andrew Bonventre
c47212f6f0 godoc: don't exclude version field from File struct
When uploading a new release, it deserializes the payload into
a File struct for processing. It needs the Version field to
determine which release it's in.

Change-Id: I171f416dbb1b1b6c354948ea9a31b9c8694f892e
Reviewed-on: https://go-review.googlesource.com/110627
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-05-01 16:35:01 +00:00
Agniva De Sarker
8e070db38e godoc: remove vendor prefixes for border-radius
All major browsers support the border-radius directive
without any vendor prefix. Hence, removing them.

https://caniuse.com/#search=border-radius

Change-Id: I2da5f109296df3c7f191df95876bd6849f51d9ae
Reviewed-on: https://go-review.googlesource.com/110155
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-28 22:29:17 +00:00
Agniva De Sarker
0b5ca0b040 godoc: use relative css unit
To scale the website elements independently of the default font size,
we use the css rem unit. This scales the elements proportionally if the
user has set a different font size than the default.

We make all calculations assuming that 1rem=16px, which is the
default font size for browsers.

Tested manually on FF 59 and Chrome 65 with permutations of different
resolutions and different default font-sizes upto 36px.

Fixes golang/go#6150

Change-Id: I7ded227ee2c55178271667009ab98ee0b4e7e8b3
Reviewed-on: https://go-review.googlesource.com/94935
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-04-27 00:46:46 +00:00
Agniva De Sarker
1a83a0b548 godoc: fix counting of package files in GetPageInfo
CL 107155 introduced this bug due to oversight. There can be
a scenario where a folder has no source .go or .c files,
but has an ignored .go file. In that case, both the if conditions
to check the length of pkgfiles slice will evaluate to true.

Added a test case for it to prevent this happening in future.

Change-Id: I7181699bbf7580888a6f7923c5aeb842356941a8
Reviewed-on: https://go-review.googlesource.com/107195
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-16 18:17:07 +00:00
Kevin Burke
d9caac3737 godoc: add benchmark for directory scan
I'd like to propose changes to the directory scanner implementation,
and it would be good to be able to measure how changes compare in
terms of allocations and time taken.

Change-Id: I4ff4bbd38b5e3522f50d31473f2ac607bb0de802
Reviewed-on: https://go-review.googlesource.com/94904
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-15 15:36:21 +00:00
Agniva De Sarker
327197e6b0 godoc,blog: perform minor cleanup
- Remove a stray comment which was no longer needed. The accompanying
issue golang.org/issue/7524 was discussed and closed.
- Combine 2 if conditions into a single if-else because
length of a slice can never be negative.
- Remove http links from golangOrgAbsLinkReplacer now that all
links have been changed to https in the blog articles.

Change-Id: I2fe2ec245b580a91760c9331e9626b367f1b6740
Reviewed-on: https://go-review.googlesource.com/107155
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-14 19:30:04 +00:00
Agniva De Sarker
8b3cccae50 godoc/vfs: improve implementation of RootType
- Removed the StandAlone and Asset root types as they were just there
for other vfses to satisfy the FileSystem interface and causing unnecessary
confusion. Returning just empty strings in those scenarios now to clarify
that it is a dummy placeholder.

- Removed the prefix "Fs" from RootType as it was unnecessary.

- Using the RootType type to pass down to the html templates
instead of converting to string. The templates are capable of converting
to the actual string representation when comparing the value.

Change-Id: Iadc039f1354ecd814eec0af1e52cdbaaeff0cc89
Reviewed-on: https://go-review.googlesource.com/106196
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-11 20:41:25 +00:00
Agniva De Sarker
faed997d2c godoc: cleanup package templates
Separate the templates of package root directory and other
directories. This removes several if-else conditions and
makes the template code much cleaner.

To be merged after CL 95835.

For golang/go#3305

Change-Id: I435441dbe214e4c89271483173df7c30a42ee28f
Reviewed-on: https://go-review.googlesource.com/101295
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-04-10 16:42:09 +00:00
Agniva De Sarker
16d1af8d88 godoc: group package home page list by root
This CL groups the package list into two groups - standard library(GOROOT),
and third-party code(GOPATH).

It also wraps the list with a collapsible div header used in the package
documentation page. This makes the entire page easy to view and manage, and also
makes it consistent with the rest of the pages.

To implement this, a new function was added to the filesystem interface
which returns the root type of the filesystem. In most cases, it is either GOROOT
or GOPATH. There are other kinds of filesystems which are not used in the home page,
so additional values have been added to satisfy the interface.

A side effect of this is that the html template code has become a bit spaghetti-like
with if conditions all over. This is because the same template is used to render
a package directory as well as the package home page. A better way is to use
two separate templates for the different tasks. This cleans out a lot of the
if conditions and make for a much cleaner code. This has been taken care in CL 101295.

Fixes golang/go#3305
Fixes golang/go#15020

Change-Id: I876357dc76280a7df2ed08d7c6bc53d9a41e69ab
Reviewed-on: https://go-review.googlesource.com/95835
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-04-10 16:41:40 +00:00
Agniva De Sarker
ac136b6c2d godoc: sort package listing
The directory slice gets created first from newDirTree and then
gets appended again after reading from the dirchs channel. Hence
we need to sort the slice after all the entries are added.

Fixes golang/go#24601

Change-Id: I9282e8643a4448b2c1c84495b7642610f6c56d50
Reviewed-on: https://go-review.googlesource.com/103955
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Kevin Burke <kev@inburke.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-01 16:57:15 +00:00
Dmitri Shuralyov
370143dbca godoc/static: add perf, review, sync subrepos
They exist and are considered to be worth listing based on the decision
made in golang/go#24432. They weren't listed previously. This change
fixes that.

Document the remaining subrepos that are not meant to be listed (per
decision in golang/go#24432), so it's clear that it's intentional for
them to not be visible at https://golang.org/pkg/#subrepo.

Closes golang/go#24432.
Updates golang/go#14304.

Change-Id: Icc50ebfcdbc490c32519d92a1a838eb3f54c823d
Reviewed-on: https://go-review.googlesource.com/103075
Reviewed-by: Austin Clements <austin@google.com>
2018-03-30 16:45:20 +00:00
Yury Smolsky
4c0f0e48a6 godoc: add vet support to playground.js
Playground needs godoc to support calls to /vet endpoint in playground.js.
Optional parameter "vetEl" is added to the function "playground".
If it's passed then the js installs the click handler to the element.

There is a corresponding CL 100776 for the playground code.

Updates golang/go#7597

Change-Id: Ica2e7cb9d76f6f19a1805c182e666b8142762da9
Reviewed-on: https://go-review.googlesource.com/100775
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-03-23 17:42:02 +00:00
Kevin Burke
96caea4103 godoc: fix runaway goroutine use
Previously we would spin up a new goroutine for every directory
we needed to parse. Since parent directories cannot exit until
children have exited, in large GOPATH directories we could have 8000+
goroutines evaluating directories concurrently. The race detector uses
tsan, and tsan can handle a maximum of 8192 concurrent threads at one
time.

Limit the number of concurrent threads. It is difficult to do this
in a way that does not involve a child being blocked on a parent
completing to spin up goroutines for itself to complete. Solve this by
completing work on the main thread if there are no additional workers
available to help complete work.

I was expecting limiting the concurrency to hurt performance, but it
actually significantly improves it. Benchmarks were performed using CL
94904 at tip, and with goroutines at 2, 4, and 8 times the number of
CPU's.

$ benchstat tip.benchmark gated-2.benchmark gated-4.benchmark gated-8.benchmark
name \ time/op    tip.benchmark  gated-2.benchmark  gated-4.benchmark  gated-8.benchmark
NewDirectory-4       293ms ± 2%         262ms ± 4%         252ms ± 4%         253ms ± 2%

name \ alloc/op   tip.benchmark  gated-2.benchmark  gated-4.benchmark  gated-8.benchmark
NewDirectory-4       218MB ± 0%         218MB ± 0%         218MB ± 0%         218MB ± 0%

name \ allocs/op  tip.benchmark  gated-2.benchmark  gated-4.benchmark  gated-8.benchmark
NewDirectory-4        513k ± 0%          508k ± 0%          509k ± 0%          510k ± 0%

Fixes golang/go#22110.

Change-Id: If01f78f1fc53cd195e4f8f6988c3c39b3c275992
Reviewed-on: https://go-review.googlesource.com/94955
Reviewed-by: Yury Smolsky <yury@smolsky.by>
Reviewed-by: Kevin Burke <kev@inburke.com>
2018-03-18 01:21:57 +00:00
Dmitri Shuralyov
14b3f5b193 godoc/static: add x/time subrepo
It exists, but wasn't listed previously. This change fixes that.

Fixes golang/go#24430.

Change-Id: Iaf83a4b7353794e6f411941de811ed1554955179
Reviewed-on: https://go-review.googlesource.com/101241
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-17 16:38:46 +00:00
Yury Smolsky
39919aea04 cmd/godoc: provide -all flag to output unexported identifiers
This flag includes unexported identifiers in command-line mode.
It is equivalent to ?m=all in web mode.

Fixes golang/go#8093

Change-Id: I1e5a69626929d3430638d900f3e975b272a98c90
Reviewed-on: https://go-review.googlesource.com/99435
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-03-16 16:52:36 +00:00
Agniva De Sarker
5ad4d95e58 godoc: add the defer attribute to script tags
This allows the scripts to be downloaded concurrently as the
body is being parsed.

Deferred scripts are executed in order and only after the entire
document has been loaded. So essentially the entire effect remains same
but we reduce the network download time.

Also, CL 90396 missed out updating static.go. Packaging the change along
with this.

Change-Id: Ia850bd50b49f2a9e0e4fbc29617858ab0fa8a0b9
Reviewed-on: https://go-review.googlesource.com/100295
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-03-15 17:24:39 +00:00