Граф коммитов

233 Коммитов

Автор SHA1 Сообщение Дата
Weida Hong 7d0ea0a0e8 internal/godoc/dochtml: enhance output parsing for example func
Current logic for detecting "concluding line comment" is not strict
enough that it may cause false-positive, causing some normal comment
(and code following it) to be discarded in the rendered web page.

Ensure that "concluding line comment" can only be prefixed by spaces.
Also add corresponding test case.

Fixes golang/go#65450

Change-Id: Ief9ec5326aa94965ca02d3278398cc5663ba395f
GitHub-Last-Rev: 7312ff3dff
GitHub-Pull-Request: golang/pkgsite#93
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/600415
kokoro-CI: kokoro <noreply+kokoro@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-09-13 13:08:37 +00:00
Jonathan Amsterdam 47024e5792 internal/godoc/dochtml/internal/render: unique headings redux
This CL takes an alternative approach to generate unique headings.
It builds on the work of https://go.dev/cl/573595,
which was a fix for https://go.dev/issue/64582.

- It takes a more direct approach to constructing a unique string
  from an ast.Decl.

- The function that does that is tested separately, reducing
  the test cases needed for formatDocHTML.

- It saves the generated headings, so the HTML doesn't have to
  be reparsed.

NOTE: This will break all links to headings that are not in the package
comment. Happily, such headings are rare: only 40 of the top thousand
packages have one. It might seem we could avoid any breakage by only
applying a suffix to duplicate headings. But then at any time
in the future, a unique heading could become a duplicate, causing
a break. Better one break now than an unending stream of them.

Change-Id: I379712b54c6bc9c6a9343d0006639085a40e23d9
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/608035
kokoro-CI: kokoro <noreply+kokoro@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2024-09-10 17:35:46 +00:00
Jonathan Amsterdam e0bd492bb7 internal/fetch,godoc: handle lint exceptions
This CL addresses the errors found by staticcheck when we upgraded
to Go 1.23. All were deprecation warnings, and they were silenced
by "ignore" directives until we could deal with them.

In all cases, ignore the lint message was the right choice.
The CL adds justifications.

Change-Id: I09d4bb96cb9913f8e35189ed3a4af9deaa092447
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/610801
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
2024-09-05 13:10:54 +00:00
Jonathan Amsterdam 0709f9d1cc internal/godoc/codec: improve documentation
Change-Id: I7b2d5721ee5502897be4d49d8c69ed16ee33fa8d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/610715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
2024-09-04 23:28:05 +00:00
Jonathan Amsterdam 6851d87f22 go.mod: upgrade to go 1.23
The go.mod major version now matches what we use for Dockerfiles.

The version of staticcheck that works with Go 1.23 revealed several
uses of deprecated functions. Some of these were easy to change,
but other require more care and will be addressed in some later CLs.

Change-Id: I7f8344e419b8be6351d51db90faa64cef04057a0
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/609142
Reviewed-by: Robert Findley <rfindley@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-04 11:03:35 +00:00
Jonathan Amsterdam 676c19eae9 all: get all.bash to work
- Fix npm vulns.
- Fix the minimized-css check to look only at the working dir.

Change-Id: Iecf2c5ef35813fef16df22147f795cda814fef2b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/608037
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
2024-08-24 13:58:12 +00:00
Jonathan Amsterdam fca1531c8b internal/godoc/dochtml/internal/render: move tests to txtar
Move most of the cases of the formatDocHTML test to txtar files.
They were too hard to read.

The remaining cases have to do with passing an ast.Decl.
We may move them later or we may try a different approach
to generating unique heading IDs, which is the purpose of passing
in the decl.

Change-Id: I99c71ed1f04b469cb540ff72a31a39eb6cbb1050
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/607616
kokoro-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-22 15:27:54 +00:00
Jonathan Amsterdam 7be9f26791 internal/godoc/dochtml: add comments
Also change renderInfo's first return value to template.FuncMap
for clarity.

Change-Id: I2ad2906d260d405225d54723401276e419545ecc
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/607418
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
2024-08-22 11:56:24 +00:00
Joseph Shin 53b9917759 internal/godoc/dochtml/internal/render: ensure unique heading ids
The existing implementation takes a simple approach of using the heading
text and replacing non-safe characters.  This leads to potential duplicate
heading ids, so use a map to keep track of used heading ids and generate
unique ids with various strategies until a unique id is generated.

Fixes golang/go#64582

Change-Id: I95f823c3782411454cff7353b49d90fab5799a45
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/573595
TryBot-Result: Gopher Robot <gobot@golang.org>
TryBot-Bypass: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-08-21 14:16:17 +00:00
Joseph Shin 71f98d56b5 internal/godoc/dochtml/internal/render: properly handle multi-line comments
The existing implementation rewinds lastOffset when indents are replaced
because lastOffset is calculated against the modified literal.  lastOffset
acts as a file pointer against the source so calculate offset against the
source literal before stripping indents.

Fixes golang/go#56762

Change-Id: I86fcef9eb24742e707b4a723a9767baac5433b9c
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/586099
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
Commit-Queue: Jonathan Amsterdam <jba@google.com>
TryBot-Bypass: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-08-20 21:09:57 +00:00
Jonathan Amsterdam 9b2cbf616e devtools/cmd/dumpdoc: tool for writing out package documentation
This is a tool for an experiment.
It reads package documentation from the database and writes it
to a file in gob format.

Change-Id: I3b6cfde24ce155a647c3c43caff68be63832f80f
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/566416
kokoro-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-23 17:34:38 +00:00
Jonathan Amsterdam 424156b7a0 internal/godoc: increase max imports per package
This will let us process git.runstone.com/DataCollect-BD/cisco-network-telemetry-proto@v1.1.0.

Also, remove an unused constant from internal/fetch.

Change-Id: Ib57078b84f5ee32b59fe934d153ede47d238e1d5
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/565677
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2024-02-21 20:22:07 +00:00
Michael Matloob c63424d1f1 internal: move templatecheck tests to their own package
The new package the templatecheck tests are in is not a transitive
dependency of cmd/pkgsite, so that cmd/pkgsite no longer has a
transitive test dependency on github.com/jba/templatecheck.

To make this work we had to expose the templates from the
internal/frontend and internal/godoc packages for the tests to use.

For golang/go#61399

Change-Id: I1290ec24b53af77a82671c8fc068867e12857ce3
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/550936
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
kokoro-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-12-19 20:48:54 +00:00
Thiago d8c9c76640 internal/godoc/dochtml: add type parameters on func synopsis
Adding type parameters on functions synopsis.

Fixes golang/go#60954

Change-Id: If72c1b4d401b6cd32c335b1ed136063e7c965743
GitHub-Last-Rev: 375797ea2c
GitHub-Pull-Request: golang/pkgsite#79
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/535555
Reviewed-by: Suzy Mueller <suzmue@golang.org>
kokoro-CI: kokoro <noreply+kokoro@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-08 11:23:22 +00:00
Prudhvi Krishna Chintala 7431aa5932 static/frontend: fix to make link purpose clear to users.
Change-Id: I4ebdf32f03936e6af927c204e28548e39994cd77
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/520255
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
kokoro-CI: kokoro <noreply+kokoro@google.com>
2023-09-05 19:16:35 +00:00
cui fliter 81f6f8d417 internal: fix some comments
Change-Id: I837c46bba9cd5c012670b432274c6e3318a3275b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/465997
Reviewed-by: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Auto-Submit: Suzy Mueller <suzmue@golang.org>
2023-02-09 20:53:57 +00:00
Jamal Carvalho f93c7b3d88 deploy,devtools: upgrade to go1.20rc3
- Disabled staticcheck while go1.20 is unsupported.
- Fixed out of bounds error in doc html parsing.
- Fixed test issue related to rand package changes.

Change-Id: Ib7b30ed9c40505a5a51d986426f0e41e53a298b1
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/464296
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
2023-02-01 16:01:36 +00:00
Hana (Hyang-Ah) Kim 694b5d3c2a all: convert interface{} to any
Change-Id: I1f3b7cc8899c7707abb01e3d14807c37c3451382
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/449695
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-11-15 20:10:34 +00:00
Jamal Carvalho 0b28882579 internal: re-enable staticcheck SA1019
Replaces use of strings.Title with a caser from
/x/text/cases.

Change-Id: I35f9f96720bb84b40cef3d7bfda1a7370991c5cd
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/413317
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2022-06-30 15:52:19 +00:00
Jonathan Amsterdam bd81bd72a1 internal/godoc/dochtml/...: remove EnableCommandTOC
It is always true.

Change-Id: I9039b4d77b8bd629e2da4821769565ec9ba43020
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/414395
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
2022-06-28 15:41:02 +00:00
Jonathan Amsterdam 2f86252311 internal/godoc/dochtml: add test for package in same module
Verify that links to packages in the same module are versioned.

Change-Id: I31394b6cb15d58a842691cee8887f2d8d5a02cf2
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/414394
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2022-06-28 15:40:54 +00:00
Jonathan Amsterdam 3a44de74de internal/godoc/dochtml: add test for doc comment links
Change-Id: Idc778d3984cbb907e71eaf68610b5f3bc6fd5ef0
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/414314
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
2022-06-28 15:40:46 +00:00
Jonathan Amsterdam 2341ac8ffd static,tests: fix doc ul display, update tests
- Add bullets and numbers to lists generated from documentation comments.

- Update tests.

- Commented out one screentest that is failing for unknown reasons.

Change-Id: I042c89970d8dd5477e3eca5743f9a082bda4f5a3
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/413680
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2022-06-25 16:19:57 +00:00
Jonathan Amsterdam 05926c8ab6 internal/godoc/dochtml/internal/render: use default comment parser
Use the comment.Parser returned by doc.Package.Parser.

Change-Id: I1507f1ab83abb5a0c1e311c3bdf8f76943c809de
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/413676
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
2022-06-24 17:11:57 +00:00
Jonathan Amsterdam 01c898673e internal/godoc/dochtml/internal/render: fix numbered lists
Spacing inside the li element was incorrect.

Also added a test.

Also removed extraneous print statement.

Change-Id: Ic84082b6b4eee18c1db9c22952fa1e455a0b4ff5
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/413318
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
2022-06-23 16:17:28 +00:00
Jonathan Amsterdam f5535a617f internal/godoc/dochtml: remove fork of go/doc
Remove our fork of go/doc and replace with the real go/doc.

Change-Id: Ia9631acb22a8f2d98666ddeaff7ee2e9ba906600
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/413316
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-06-23 16:17:21 +00:00
Jonathan Amsterdam ce2fca103e move code out of linkify_comment.go
Move all code into linkify.go.

Code motion, except for shortened package prefix.

Change-Id: Id2683386bd1c959888ed9e7089919ad61f0b8768
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/413315
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-06-23 16:17:15 +00:00
Jonathan Amsterdam d8dd958ddd internal/godoc/dochtml/internal/render: use go/doc/comment
Parse doc comments with the new go/doc/comment package.

Change-Id: If79c1035086b2b70f1207cb84153f8c0bcbd6599
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/412676
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
2022-06-21 13:41:44 +00:00
Jonathan Amsterdam 3359ccdb05 internal/godoc/dochtml/internal/render: test table of contents
Also, tweak spacing to make it look more like handwritten HTML.

Change-Id: Iefd2ffad42ad83ebcb246e931f239f8605b04c23
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/412319
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-06-21 13:29:44 +00:00
Jonathan Amsterdam 24f94ffc54 many: re-enable staticcheck and fix problems
Most of the checks were about io/ioutil. There were a couple of
other minor ones. I didn't address the check for strings.Title;
instead, I turned off that check globally with a staticcheck.conf
file.

Change-Id: I286a6894fb1fd891818ab9e451c891f52a3828fc
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/412675
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2022-06-17 13:49:06 +00:00
Dan Kortschak e0862a69f6 internal/godoc/dochtml/internal/render: remove redundant accounting code
Change-Id: I4adfbdcc3cb0f644d42837c441aabbc8a8c70fab
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/398775
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-05-27 14:50:26 +00:00
Jamal Carvalho d90bf6eb5f internal,static: remove legacy outline template
The legacy outline template was mistakenly left active. This change
removes the legacy template which fixed a bug where an empty outline
section would show an triangle expand icon.

Change-Id: I46478ccb34ad3f5bd2f6d0657ad607f7d8e3daa8
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/402214
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-04-27 14:30:32 +00:00
Jonathan Amsterdam fa2d646637 internal/godoc/internal/doc: support examples on generic methods
Remove bracket contents from generic method example identifiers
to allow them to be paired with examples.

Port of https://go.dev/cl/401761.

Fixes golang/go#52363.

Change-Id: I4404c833d1aa98308407cdc6199fbe6261f256c9
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/401621
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-04-25 15:27:55 +00:00
Jonathan Amsterdam 25aa26ec8e internal/godoc/dochtml: only recognize "Deprecated" at paragraph start
Treat a function or method as deprecated only if the string
"Deprecated:" occurs at the start of a paragraph.  Previously, we
looked for it at the start of a line.

Also, remove the "deprecated-off" golden file because it was no longer
used.

Fixes golang/go#46913.

Change-Id: I0d16598915677e17565e9944ce67092dcdd208f5
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/400994
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-04-19 16:03:18 +00:00
Russ Cox 8ea409f829 all: gofmt
Gofmt to update doc comments to the new formatting.

For golang/go#51082.

Change-Id: Ia9e71e7ecac75822ff43d6c7e60f512442a5fa50
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/399617
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2022-04-11 21:55:57 +00:00
Dan Kortschak a5c2c4e9ac internal/godoc/dochtml/internal/render: don't smart quote in <pre> blocks
Fixes golang/go#51807.

Change-Id: I8ab6c9362ef79a286c0480d14a4905f8fe4c0c84
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/394034
Trust: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jamal Carvalho <jamalcarvalho@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2022-04-07 20:38:15 +00:00
Dan Kortschak 8ce55dc4b4 all: fix typos
Change-Id: I71373b98c4bf80b176f0f01c3ce50335813678b1
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/391974
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Trust: Cherry Mui <cherryyz@google.com>
2022-04-04 17:28:02 +00:00
Jonathan Amsterdam e6e5f74961 many: use strings.Cut
Change-Id: I63aff7182ffba765bbd5b104089562b04bff0960
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/388956
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-03-07 15:50:25 +00:00
Jonathan Amsterdam 8e38f7741c internal/godoc/dochtml/internal/render: refactor Renderer.declHTML
Split out the part that renders doc comments to a separate function.

This will make it easier to integrate the (probably) forthcoming
go/doc/comments package.

Change-Id: If7a29ee42a7b66c1acae96fdc27c15b4502d3e28
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/385199
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-02-11 23:55:26 +00:00
Jonathan Amsterdam 7c5776d44b internal/godoc/dochtml/internal/render: remove DisablePermalinks
Remove the DisablePermalinks option. We never use it.

Change-Id: I2ff53e141a7f4ab6217225f10f87a12739a7034d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/385196
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-02-11 23:55:14 +00:00
Jonathan Amsterdam 8b65ee42bb internal/godoc/dochtml: remove hotlink code
Remove the code that creates implicit links to Go identifiers in
documentation comments.

This code has always been disabled, and with the likely acceptance of
some form of https://go.dev/issue/51082, which favors explicit links
in godoc over implicit ones, it is unlikely ever to be enabled.

Removing it will pave the way for easier integration with the
go/doc/comment package in the above proposal.

Change-Id: Ief69b392af44a1efde48fd648ef04de6574a8910
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/385194
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-02-11 23:55:05 +00:00
Jonathan Amsterdam 0007cf85bf internal/godoc/internal/doc: mark comparable as predeclared
Fixes golang/go#51141.

Change-Id: Id92108ff3c561ab33a119c395cbad09555b864f5
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/385198
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-11 20:45:01 +00:00
Jonathan Amsterdam 7b10ef3861 internal/godoc/internal/doc: reconcile with master
Adopt minor changes from go/doc at the current go tip
(be0d049a42ee4b07bfb71acb5e8f7c3d2735049a).

After this CL, the only major difference between this package and
go/doc is example processing.

To clarify the differences, move the pkgsite-specific example
processing code and tests to separate files.

Change-Id: Ifc781c7a9ccb219813b5a23ed3dbe454c8d5a5b1
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/384337
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-02-09 19:43:08 +00:00
Jonathan Amsterdam a70a3c2b47 internal/godoc: make work with generics
We need to register a new AST node to support
encoding.

Also add a test.

For golang/go#48264

Change-Id: Ib9a0205ff4daeb55ee3447945fca513d2e4cb9c8
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/382977
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2022-02-04 19:29:54 +00:00
Jonathan Amsterdam fa3d909bfc internal/godoc/internal/doc: update go go1.18beta1
Incorporate the changes in go/doc made for generics into our fork of
go/doc.

For golang/go#48264

Change-Id: Ic31d0d58ffbe731b5d425506564ecda3774ae840
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/382975
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-02-04 18:26:28 +00:00
Jamal Carvalho f4542b7b04 internal: GOOS setting preserved across doc links
When a doc page is rendered with a GOOS value set
this value is preserved in links within the doc page.

Fixes golang/go#49424

Change-Id: I26d1a3466365d2ee940f9afe0801af114ee03c47
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/377396
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2022-01-11 15:44:15 +00:00
Jonathan Amsterdam 51e9505d35 internal/godoc/internal/doc: bring in line with Go 1.17.3
This CL brings our fork of go/doc as close as possible to the
go/doc code in Go 1.17.3. We fork lazyregexp to remove diffs
with that, copy over some new files, and update other code
without changing any functionality.

Change-Id: If0589907d119cc9c84b0c36ef052bd412ee24b5a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/372755
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-12-20 21:52:34 +00:00
Jonathan Amsterdam b29d14345b internal/godoc: remove IsDeprecated from go/doc
pkgsite has a fork of the standard library's go/doc package. This CL
is part of an attempt to reconcile the two so pkgsite can use the
standard library go/doc.

Remove the IsDeprecated field from our go/doc. We can determine
if a symbol is deprecated using its doc, which is exported, so
we don't need to have that logic in the go/doc package itself.

Also, the experiment that displays deprecated symbols is fully
active, so remove code that depends on it.

We will remove the actual experiment definition in a later CL.

Change-Id: I723ffc4ee48c32e791eab896df61cfc389874f98
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/372754
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-12-16 17:36:20 +00:00
Jonathan Amsterdam 818e48fe61 many: cmd/pkgsite embeds static assets
The `pkgsite` command now embeds all the static assets it needs, so it
need not be told the location of the static/ directory with a
flag. The binary is self-contained and can be placed and invoked from
anywhere.

This required embedding the static/ and third_party/
directories. Since //go:embed cannot reference files outside the
containing package's tree, we had to add trivial Go packages in
static/ and third_party/ to construct `embed.FS`s for those
directories.

Also, the frontend needed to accept `fs.FS` values where it
previously took paths, and `template.TrustedFS` values where it
previously used `template.TrustedSources`. We ended up clumsily
requiring four separate config values:

- A TrustedFS to load templates.

- Two fs.FSs, one for static and one for third_party, to load other
  assets.

- The path to the static directory as a string, solely to support
  dynamic loading in dev mode.

For golang/go#48410

Change-Id: I9eeb351b1c6f23444b9e65b60f2a1d3905d59ef9
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/359395
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-10-28 17:01:30 +00:00
Jamal Carvalho 87f5a1befe static/doc: less repetative deprecation UI
Fixes golang/go#48678

Change-Id: I9864e1a7bfdb71999480774d68c926a1b559e451
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/355189
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-10-14 15:23:24 +00:00