Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new type return by 'fsharp/documentation' and add support for "Open documentation" link from the tooltips #1861

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/Components/InfoPanel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module InfoPanel =

let mapContent res =
if isNotNull res then
let res: DocumentationDescription = (res.Data |> Array.concat).[0]
let res: DocumentationDescription = res.Data

let fsharpBlock lines =
let cnt = (lines |> String.concat "\n")
Expand All @@ -85,24 +85,15 @@ module InfoPanel =
sprintf "<pre>\n%s\n</pre>" cnt

let sigContent =
let lines =
res.Signature
|> String.split [| '\n' |]
|> Array.filter (not << String.IsNullOrWhiteSpace)

match lines |> Array.splitAt (lines.Length - 1) with
| (h, [| StartsWith "Full name:" fullName |]) ->
[| yield fsharpBlock h; yield "*" + fullName + "*" |]
| _ -> [| fsharpBlock lines |]
|> String.concat "\n"
res.Signature
|> String.split [| '\n' |]
|> Array.filter (not << String.IsNullOrWhiteSpace)
|> fsharpBlock

let commentContent = res.Comment

let footerContent =
res.Footer
|> String.split [| '\n' |]
|> Array.filter (not << String.IsNullOrWhiteSpace)
|> Array.map (fun n -> "*" + n + "*")
res.FooterLines
|> String.concat "\n\n"

let ctors =
Expand Down Expand Up @@ -138,7 +129,7 @@ module InfoPanel =
|> fsharpBlock

let types =
res.Types
res.DeclaredTypes
|> List.filter (not << String.IsNullOrWhiteSpace)
|> List.distinct
|> fsharpBlock
Expand Down Expand Up @@ -271,8 +262,17 @@ module InfoPanel =
| None -> openPanel () |> ignore

let private showDocumentation o =
Panel.updateOnLink !!o?XmlDocSig !!o?AssemblyName
// If the panel doesn't exist, open it
// This happens when using click on "Open documentation" from inside
// the tooltip
promise {
match Panel.panel with
| Some _ -> ()
| None ->
do! openPanel ()

do! Panel.updateOnLink !!o?XmlDocSig !!o?AssemblyName
}

let private selectionChanged (event: TextEditorSelectionChangeEvent) =
let updateMode = "FSharp.infoPanelUpdate" |> Configuration.get "onCursorMove"
Expand Down
4 changes: 2 additions & 2 deletions src/Core/DTO.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ module DTO =
Functions: string list
Interfaces: string list
Attributes: string list
Types: string list
DeclaredTypes: string list
Signature: string
Comment: string
Footer: string }
FooterLines: string list }

type Error =
{
Expand Down
9 changes: 6 additions & 3 deletions src/Core/LanguageService.fs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ Consider:
Position = { Line = line; Character = col } }

cl.sendRequest ("fsharp/documentation", req)
|> Promise.map checkNotificationAndCast<Result<DocumentationDescription[][]>>
|> Promise.map checkNotificationAndCast<Result<DocumentationDescription>>

let documentationForSymbol xmlSig assembly =
match client with
Expand All @@ -259,7 +259,7 @@ Consider:
XmlSig = xmlSig }

cl.sendRequest ("fsharp/documentationSymbol", req)
|> Promise.map checkNotificationAndCast<Result<DocumentationDescription[][]>>
|> Promise.map checkNotificationAndCast<Result<DocumentationDescription>>

let signature (uri: Uri) line col =
match client with
Expand Down Expand Up @@ -614,7 +614,10 @@ Consider:
opts.revealOutputChannelOn <- Some Client.RevealOutputChannelOn.Never

opts.initializationOptions <- Some !^(Some initOpts)
opts?markdown <- createObj [ "isTrusted" ==> true ]
opts?markdown <- createObj [
"isTrusted" ==> true
"supportHtml" ==> true
]

opts

Expand Down