haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.61k stars 691 forks source link

Reexporting from private library components discards documentation of all but one component #10368

Open sgraf812 opened 1 week ago

sgraf812 commented 1 week ago

(Originally reported as a haddock bug here.)

Summary

cabal haddock does not appear to merge the reexported documentation from multiple private library components and instead arbitrarily picks exactly one component to reexport.

Steps to reproduce

Paste the following into your shell:

git clone https://github.com/haskell/happy
cd happy/lib
git checkout ddfb7bb933a0c2d61333fe5851e7dbf8136f0818
cabal haddock --builddir="$(pwd)/docs-dist" --haddock-for-hackage
cd docs-dist
tar xvf happy-lib-2.0-docs.tar.gz
cd happy-lib-2.0-docs
ls -l

Now realise that it only packaged up the documentation for one private library component (either the LALR or the GLR backend).

Expected behavior

It should have documentation for all reexported modules

System information

Ericson2314 commented 1 week ago

It does look like a cabal bug. See the same build path occurring again and again in the following (truncated) log:

$ cabal haddock --builddir="$(pwd)/docs-dist" --haddock-for-hackage
Resolving dependencies...
Build profile: -w ghc-9.6.5 -O1
In order, the following will be built (use -v for more details):
 - happy-lib-2.0 (lib:grammar) (first run)
 - happy-lib-2.0 (lib:tabular) (first run)
 - happy-lib-2.0 (lib:frontend) (first run)
 - happy-lib-2.0 (lib:backend-lalr) (first run)
 - happy-lib-2.0 (lib:backend-glr) (first run)
 - happy-lib-2.0 (lib) (first run)
Configuring library 'grammar' for happy-lib-2.0..
Preprocessing library 'grammar' for happy-lib-2.0..
Building library 'grammar' for happy-lib-2.0..
...
Documentation created:
/home/jcericson/src/happy/lib/docs-dist/build/x86_64-linux/ghc-9.6.5/happy-lib-2.0/l/grammar/doc/html/happy-lib-2.0-docs/,
/home/jcericson/src/happy/lib/docs-dist/build/x86_64-linux/ghc-9.6.5/happy-lib-2.0/l/grammar/doc/html/happy-lib-2.0-docs/happy-lib.txt
Documentation tarball created:
/home/jcericson/src/happy/lib/docs-dist/happy-lib-2.0-docs.tar.gz
...
Documentation created:
/home/jcericson/src/happy/lib/docs-dist/build/x86_64-linux/ghc-9.6.5/happy-lib-2.0/l/tabular/doc/html/happy-lib-2.0-docs/,
/home/jcericson/src/happy/lib/docs-dist/build/x86_64-linux/ghc-9.6.5/happy-lib-2.0/l/tabular/doc/html/happy-lib-2.0-docs/happy-lib.txt
Documentation tarball created:
/home/jcericson/src/happy/lib/docs-dist/happy-lib-2.0-docs.tar.gz
...
Documentation created:
/home/jcericson/src/happy/lib/docs-dist/build/x86_64-linux/ghc-9.6.5/happy-lib-2.0/l/frontend/doc/html/happy-lib-2.0-docs/,
/home/jcericson/src/happy/lib/docs-dist/build/x86_64-linux/ghc-9.6.5/happy-lib-2.0/l/frontend/doc/html/happy-lib-2.0-docs/happy-lib.txt
...
Documentation tarball created:
...
Documentation created:
/home/jcericson/src/happy/lib/docs-dist/build/x86_64-linux/ghc-9.6.5/happy-lib-2.0/l/backend-glr/doc/html/happy-lib-2.0-docs/,
/home/jcericson/src/happy/lib/docs-dist/build/x86_64-linux/ghc-9.6.5/happy-lib-2.0/l/backend-glr/doc/html/happy-lib-2.0-docs/happy-lib.txt
Documentation tarball created:
/home/jcericson/src/happy/lib/docs-dist/happy-lib-2.0-docs.tar.gz
Documentation created:
/home/jcericson/src/happy/lib/docs-dist/build/x86_64-linux/ghc-9.6.5/happy-lib-2.0/l/backend-lalr/doc/html/happy-lib-2.0-docs/,
/home/jcericson/src/happy/lib/docs-dist/build/x86_64-linux/ghc-9.6.5/happy-lib-2.0/l/backend-lalr/doc/html/happy-lib-2.0-docs/happy-lib.txt
Documentation tarball created:
/home/jcericson/src/happy/lib/docs-dist/happy-lib-2.0-docs.tar.gz

This is Cabal 3.10, however.

geekosaur commented 1 week ago

Can you test with cabal-head (https://github.com/haskell/cabal/releases/tag/cabal-head)? We've made a number of changes to how cabal deals with sub-library haddocks in the past few months, and I don't think any of them has been released yet.

geekosaur commented 1 week ago

And there are a few more changes coming (which sadly won't be in 3.14), if my understanding of our currently-open tickets is correct, specifically dealing with temporary files.

sgraf812 commented 1 week ago

It appears to reproduce with Cabal 3.15.0.0 as well (as installed through ghcup).