Skip to content

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

Open

Description

@jhrcek

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>

Activity

  1. jhrcek commented on Dec 19, 2021

    @jhrcek
    Author

    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

  2. jneira commented on Dec 19, 2021

    @jneira
    Member

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

  3. jhrcek commented on May 28, 2022

    @jhrcek
    Author

    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 :(

  4. mjrussell commented on Jun 1, 2022

    @mjrussell

    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

  5. alexfmpe commented on May 27, 2024

    @alexfmpe

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions