-
Notifications
You must be signed in to change notification settings - Fork 90
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
Fix showDocumentation command. #452
Conversation
- Instead of using an iframe to render the content, we read and pass the html content to the webview.
- Refactor showDocumentation and openDocumentationOnHackage functions.
Forgot to mention, but there also doesn't seem to be a way to support navigation inside webview so links like ( Probably better to always open the documentation on hackage |
many thanks for trying to fix it, as you commented the limitations makes more reliable open docs in hackage, so I would set the config option to true by default |
Pushed two commits to set the config option to true by default and fix the source file urls. |
- Changed the regex so it only matches the last /*.html. - Hard code the src directory in the hackage url.
This should now also fix #360. Please let me know if this change breaks any other working links. |
c8f7039
to
b85ec43
Compare
Lets merge this, many thanks! |
It is not a perfect solution but I think it's a bit better than having an empty webview
Fix showDocumentation command
I removed the iframe and instead pass the html directly to the webview.
I had to set
base
url to the documentation directory so that the css files can be fetched properly.The links in the opened documentation are broken and they can't be opened in the webview (at least I couldn't figure out how to do that), when you click on a link it opens it it the users browser but because we have base url set, the opened link points to something like
https://file+.vscode-resource.vscode-webview.net/nix/store/n104dcsv7gc8l7c2mc2lixp220il8lk8-ghc-8.10.4-doc/share/doc/ghc/html/libraries/base-4.14.1.0/Control-Monad.html#t:Monad
.An alternative is to have the css files required for correct haddocks rendering in the extension itself, this can be done if the css file (
linuwial.css
) is the same for every library. This way we can set the base url to hackage docs and the external links should work fine.New config option
Added a new configuration option
openDocumentationInHackage
which if set to true will always open documentation in user's browser on hackage and not in the webview.Future work
Noticed that the
source
urls on my filesystem are different from the ones on hackage. For example,on my system:
file:///nix/store/n104dcsv7gc8l7c2mc2lixp220il8lk8-ghc-8.10.4-doc/share/doc/ghc/html/libraries/mtl-2.2.2/src/Control-Monad-Reader-Class.html#t:MonadReader
vs on hackage:
https://hackage.haskell.org/package/mtl-2.2.2/docs/src/Control.Monad.Reader.Class.html#MonadReader
(notice the.
s vs the-
s).This can be fixed in the
processLink
function. (Fixed in c59ae94)It'll also be nice to have a separate command for
showSource
and a corresponding configuration option to either always view it in vscode vs hackage. (AddedopenSourceInHackage
setting in c8f7039)