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.
Fixesgolang/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>
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>
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>
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>
- 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>
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>
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>
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.
Fixesgolang/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>
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.
Fixesgolang/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>
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>
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>
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>
- 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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
Remove bracket contents from generic method example identifiers
to allow them to be paired with examples.
Port of https://go.dev/cl/401761.
Fixesgolang/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>
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.
Fixesgolang/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>
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>
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>
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>
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>
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>
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>
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>
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>
When a doc page is rendered with a GOOS value set
this value is preserved in links within the doc page.
Fixesgolang/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>
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>
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>
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>