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

Clicking "Source" to open haddock source on hackage opens invalid URL #520

Open
jhrcek opened this issue Dec 19, 2021 · 5 comments
Open

Comments

@jhrcek
Copy link

jhrcek commented Dec 19, 2021

Your environment

Which OS do you use:
Linux, fedora 34

Which lsp-client do you use:
Vscode
Describe your project (alternative: link to the project):
stack based project

Steps to reproduce

See steps gif:
open-source-incorrect

Expected behaviour

Correct page is opened on hackage
https://hackage.haskell.org/package/base-4.14.3.0/docs/src/Data-Foldable.html#concatMap

Actual behaviour

Invalid URL is opened on hackage
https://hackage.haskell.org/package/base-4.14.3.0/docs/src/Data.Foldable.html#concatMap
` ^ It should be Data-Foldable, not Data.Foldable

Include debug information

Execute in the root of your project the command haskell-language-server-wrapper --debug . and paste the logs here:
(if you are using the vscode extension check the executable location here)

Debug output:
<paste your logs here>

Paste the logs from the lsp-client, you can check instructions about for VS Code here

LSP logs:
<paste your logs here>
@jhrcek
Copy link
Author

jhrcek commented Dec 19, 2021

This seems to be problem in vscode-haskell, which is replacing -s with .s here:

hackageUri = `https://hackage.haskell.org/package/${packageName}/docs/src/${fileAndAnchor.replace(
/-/gi,
'.'
)}`;

The logic replacing -s with .s was introduced in this PR: #452

@jneira
Copy link
Member

jneira commented Dec 19, 2021

Yeah, thanks for the report and the further investigation, moving to the extension repo

@jneira jneira transferred this issue from haskell/haskell-language-server Dec 19, 2021
@jhrcek
Copy link
Author

jhrcek commented May 28, 2022

For reference here's a related upstream issue in haddock : haskell/haddock#1447
My understanding of why the source links are broken: some time ago there was a change in haddock in how the html files with hyperlinked source are named.

In more recent versions of haddock, the hyperlinked source code files contain - as module separator(e.g. Control-Monad.html), in older version of haddock they contain . as module separator (Control.Monad.html). The code linked above always assumes . is used as module name separator which is where you get "Page Not Found" error when you click on Source link in vscode, but if you fix the URL manually by replacing . with - you'll see the hyperlinked source code.

I'm not sure what's the best way to fix this - someone COULD go and fix the haddock logic upstream so it always uses '.' as separator. But then you'd still have tons of haddocks generated on hackage which still use '-' as separator, for which the link would still be broken.

Another option would be to fix the typescript logic in vscode-haskell - but since it doesn't know what version of haddock was used to generate the docs, it doesn't know whether it should use '-' or '.'. Not sure how this could be improved :(

@mjrussell
Copy link

mjrussell commented Jun 1, 2022

Thanks for the investigation here @jhrcek. My recommendation would be the extension should either:

  1. Prefer the most recent format. Sounds like the -, this is because HLS and thereby the extension really only work with the 3 most recent GHC versions and will continue to leave older GHC/Stackage LTS/etc behind. It would certainly be better I think to continue supporting the latest especially since it doesn't sound like it will be reverted.

  2. Another option would be to support both, and add a config parameter to the extension so people can tweak it to their needs. Seems like a good bit more work without a clear benefit

@alexfmpe
Copy link

Might be worthwhile instead grabbing the URLs that HLS already produces: haskell/haskell-language-server#3475 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants