Skip to content

Commit

Permalink
Support new type return by 'fsharp/documentation' and add support for…
Browse files Browse the repository at this point in the history
… "Open documentation" link from the tooltips
  • Loading branch information
Maxime Mangel committed Apr 7, 2023
1 parent 6afdf0e commit 42537c4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
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

0 comments on commit 42537c4

Please sign in to comment.