-
Notifications
You must be signed in to change notification settings - Fork 97
Add links to haddock and hscolour pages in documentation #699
Conversation
df <- getSessionDynFlags | ||
(docFp, srcFp) <- | ||
case nameModule_maybe name of | ||
Just mod -> liftIO $ do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires calling into IO
, which means now that after lukel97@7dc6e26 I'm not sure how to integrate this with doc local completions, which seems to be a function purely based off of the ParsedModule
cc @pepeiborra
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Local completions can use IO
so I presume that's not what is blocking you.
Local completions do not use the ghc api to extract documentation, i.e. they do not call getDocumentationTryGhc
, since that requires a ModIface
which is only available after type checking. Instead, they get the documentation from the parse tree by calling D.IDE.Spans.Documentation.getDocumentation
.
So I think the problem is that there are two code paths to get documentation and this PR needs to be extended to cover both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also needs to get access to the DynFlags
which I'm not sure how to get outside of the GHC session, i.e. in getDocumentation
. In localCompletionsForParsedModule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to run this code for local completions anyway? Locally defined identifiers will not have any documentation links
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I was thinking that too. The PR currently just ignores it in Logic.hs
:
mkComp n ctyp ty =
CI ctyp pn thisModName ty pn Nothing doc (ctyp `elem` [CiStruct, CiClass])
where
pn = ppr n
doc = SpanDocText $ getDocumentation [pm] n
doc = SpanDocText (getDocumentation [pm] n) (SpanDocUris Nothing Nothing)
e70eaf2
to
dde671a
Compare
Since this could have performance implications, could you run the benchmark suite (see https://github.com/digital-asset/ghcide/blob/master/README.md#hacking-on-ghcide) and share the differential results? |
Currently this only searches local documentation (generated with `cabal haddock --haddock-hyperlink-source` or equivalent) but could be extended to support searching via Hoogle in the future. And it works for any of the core libraries since they come installed with documentation. Will show up in hover and (non-local) completions. Also fixes extra markdown horizontal rules being inserted with no content in between them.
@pepeiborra sorry for the delay, here are the results
|
Not sure why the startup time is lower, if I'm reading this correctly |
It looks like you are comparing two wildly different branches, there are lots of performance differences that are not explained by the changes in this PR. |
@pepeiborra at the bottom of
|
After rebasing things look more sensible
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you!
…ide#699) Currently this only searches local documentation (generated with `cabal haddock --haddock-hyperlink-source` or equivalent) but could be extended to support searching via Hoogle in the future. And it works for any of the core libraries since they come installed with documentation. Will show up in hover and (non-local) completions. Also fixes extra markdown horizontal rules being inserted with no content in between them.
…ide#699) Currently this only searches local documentation (generated with `cabal haddock --haddock-hyperlink-source` or equivalent) but could be extended to support searching via Hoogle in the future. And it works for any of the core libraries since they come installed with documentation. Will show up in hover and (non-local) completions. Also fixes extra markdown horizontal rules being inserted with no content in between them.
…ide#699) Currently this only searches local documentation (generated with `cabal haddock --haddock-hyperlink-source` or equivalent) but could be extended to support searching via Hoogle in the future. And it works for any of the core libraries since they come installed with documentation. Will show up in hover and (non-local) completions. Also fixes extra markdown horizontal rules being inserted with no content in between them.
Currently this only searches local documentation (generated with
cabal haddock --haddock-hyperlink-source
or equivalent) but could beextended to support searching via Hoogle in the future. And it works for
any of the core libraries since they come installed with documentation.
Will show up in hover and completions.
Also fixes extra markdown horizontal rules being inserted with no
content in between them.
https://streamable.com/59l6zo
The above example needs a patched version of the vscode plugin to open the url inside vscode, but hopefully other clients will be able to handle the link fine