-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.
Milestone
Description
I propose adding a gopls command that uses doc/comment to render documentation comments of package-level declarations. The intent is that this command would be used by a development environment to render pkgsite-style documentation for workspace packages. This could serve the following purposes:
- Viewing documentation for code changes that have not been published yet.
- Viewing documentation for private repositories.
- Reviewing documentation as I write it, to ensure it is formatted the way I want.
- Viewing documentation from within my development environment, without needing to switch to a browser.
I'll grant the first three items can be achieved by running pkgsite locally, but that does not address (4), it is less than convenient, and in my experience does not work well for (3).
I propose:
gopls/internal/lsp/cache/docs, which will locate documentation comments, parse them withdoc/comment.Parser, and convert thedoc/comment.Docinto marshallable types such that the result can be cached.gopls/internal/lsp/command.Interface.RenderDocs, which will retrievedoc/comment.Docs from a snapshot and render them:
type RenderDocsParams struct {
Package protocol.URI
Declaration protocol.Location // location of the declaration to generate docs for, optional, omit to render for the entire package
Format string // comment, html, markdown, or text
HeadingLevel int // doc/comment.Printer.HeadingLevel
HeadingIdTmpl string // template for rendering header IDs with doc/comment.Printer.HeadingID
DocLinkTmpl string // template for rendering document links with doc/comment.Printer.DocLinkURL
DocLinkBaseURL string // doc/comment.Printer.DocLinkBaseURL
TextPrefix string // doc/comment.Printer.TextPrefix
TextCodePrefix string // doc/comment.Printer.TextCodePrefix
TextWidth int // doc/comment.Printer.TextWidth
}
type RenderDocsResult struct {
Result string
}hyangah
Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.