`stack haddock` generates incorrect relative links

未关闭
#6,863 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
haskell

调研方向

首先使用简单项目和 stack haddock --verbose 重现该问题,然后跟踪为生成的 all 文档组装 Haddock 的 -i 参数的代码。通过确认重新导出的 base 模块链接指向现有的软件包目录而不是带后缀的路径,验证修复结果。

由索引模型根据 Issue 内容生成。

描述

Overview

When running stack haddock in a project, the generated documentation uses incorrect relative links for re-exported packages in the index file. This seems to be caused by the wrong argument being given to the -i option when invoking Haddock.

Steps to reproduce

Create a trivial project, like so:

# stack.yaml
snapshot:
  url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/34.yaml
packages:
  - .

# package.yaml
dependencies:
  - base

library:
  source-dirs: lib

Then run stack haddock. Then open the documentation at file:///<project>/.stack-work/install/<platform>/<hash>/<ghc>/doc/all/index.html.

In it, all links to modules in base are incorrect. For instance, the link for Data.Eq points to doc/base-4.20.2.0-127e/Data-Eq.html. The base-4.20.2.0-127e folder does not exist, but base-4.20.2.0 does.

Running stack haddock --verbose reveals that the all documentation was generated with the following call to haddock (i have replaced parts of the path with $HOME and $PROJECT to try to make it a tiny bit less verbose, but it's still a lot, sorry):

$HOME/.ghcup/ghc/9.10.3/bin/haddock-ghc-9.10.3 \
  --optghc=-package-db=$HOME/.stack/snapshots/x86_64-linux/8a23ab0f4c447aa1863c20e527e4f2aeeec2f0c3c2ab9fbe859c65d4c711ecc7/9.10.3/pkgdb \
  --optghc=-package-db=$HOME/$PROJECT/.stack-work/install/x86_64-linux/8a23ab0f4c447aa1863c20e527e4f2aeeec2f0c3c2ab9fbe859c65d4c711ecc7/9.10.3/pkgdb \
  --gen-contents \
  --gen-index \
  -i ../ghc-internal-9.1003.0-a65c,$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/ghc-internal-9.1003.0-a65c/ghc-internal.haddock \
  -i ../haddock-issue-0.0.0,$HOME/$PROJECT/.stack-work/install/x86_64-linux/8a23ab0f4c447aa1863c20e527e4f2aeeec2f0c3c2ab9fbe859c65d4c711ecc7/9.10.3/doc/haddock-issue-0.0.0/haddock-issue.haddock \
  -i ../ghc-bignum-1.3-9ca9,$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/ghc-bignum-1.3-9ca9/ghc-bignum.haddock \
  -i ../base-4.20.2.0-127e,$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/base-4.20.2.0-127e/base.haddock \
  -i ../ghc-prim-0.12.0-d0f9,$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/ghc-prim-0.12.0-d0f9/ghc-prim.haddock

The key element is that the argument to -i is incorrect. Note, for instance, that for base, the argument is as follows: -i ../base-4.20.2.0-127e,path/to/base.haddock. Re-running the command, but will the argument to -i changed to not include the prefix fixes all relative links in the generated documentation.

Stack version
$ stack --version
Version 3.9.3, Git revision c7eb8487a82d5c3e0b88d56f8b8a98be23223eb5 x86_64 hpack-0.39.1
主要语言
Haskell
星标
4.1k
派生
857
平均合并
17 小时 32 分钟
30 天内合并 PR
5

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

commercialhaskell/stack 的其他 Issue

查看 commercialhaskell/stack 的全部 Issue

相似的 Issue

更多 Haskell Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。