Skip to content

Commit

Permalink
internal/lsp: convert comments to markdown before sending to client
Browse files Browse the repository at this point in the history
This converts all the comments from golang doc syntax to popper markdown.

Fixes #34161

Change-Id: If513100170e7d8c159bfa93b0d1e36d293e9872f
GitHub-Last-Rev: 093f82e
GitHub-Pull-Request: #165
Reviewed-on: https://go-review.googlesource.com/c/tools/+/197760
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
  • Loading branch information
JAicewizard authored and stamblerre committed Oct 4, 2019
1 parent b228186 commit 27eeabb
Show file tree
Hide file tree
Showing 3 changed files with 631 additions and 3 deletions.
19 changes: 16 additions & 3 deletions internal/lsp/hover.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,33 @@ func (s *Server) toProtocolHoverContents(ctx context.Context, h *source.HoverInf
if content.Kind == protocol.Markdown {
signature = fmt.Sprintf("```go\n%s\n```", h.Signature)
}

switch options.HoverKind {
case source.SingleLine:
content.Value = h.SingleLine
doc := h.SingleLine
if content.Kind == protocol.Markdown {
doc = source.CommentToMarkdown(doc)
}
content.Value = doc
case source.NoDocumentation:
content.Value = signature
case source.SynopsisDocumentation:
if h.Synopsis != "" {
content.Value = fmt.Sprintf("%s\n%s", h.Synopsis, signature)
doc := h.Synopsis
if content.Kind == protocol.Markdown {
doc = source.CommentToMarkdown(h.Synopsis)
}
content.Value = fmt.Sprintf("%s\n%s", doc, signature)
} else {
content.Value = signature
}
case source.FullDocumentation:
if h.FullDocumentation != "" {
content.Value = fmt.Sprintf("%s\n%s", signature, h.FullDocumentation)
doc := h.FullDocumentation
if content.Kind == protocol.Markdown {
doc = source.CommentToMarkdown(h.FullDocumentation)
}
content.Value = fmt.Sprintf("%s\n%s", signature, doc)
} else {
content.Value = signature
}
Expand Down
Loading

0 comments on commit 27eeabb

Please sign in to comment.