Skip to content

cabal does not build documentation for repl #7305

Open

Description

@oivulf

cabal (3.4.0) does not build documentation for ghci, even when
cabal build --enable-documentation

To Reproduce
cabal v2-build --enable-documentation
cabal v2-repl
Prelude Test.Util> import qualified Data.Vector as V
Prelude V Test.Util> :doc V.partition
ghc: Can't find any documentation for Data.Vector.
This is probably because the module was compiled without '-haddock',
but it's also possible that the module contains no documentation.

Expected behavior
obtain documentation, this used to work in previous versions?

System information
Build profile: -w ghc-8.8.4 -O1
linux debian
ghc, cabal from ghcup

Activity

  1. fgaz commented on Feb 26, 2021

    @fgaz
    Member

    All v2 commands except for configure are stateless, so you should either do cabal v2-repl --enable-documentation, or you can first do cabal v2-configure --enable-documentation, then cabal v2-repl

  2. oivulf commented on Feb 26, 2021

    @oivulf
    Author

    I tried cabal v2-repl --enable-documentation,
    but the effect is the same, no documentation in the repl

  3. sjakobi commented on Mar 1, 2021

    @sjakobi
    Member

    I can reproduce this or a similar issue like this:

    $ cabal repl -b vector --enable-documentation
    Resolving dependencies...
    Build profile: -w ghc-9.0.1 -O1
    In order, the following will be built (use -v for more details):
     - primitive-0.7.1.0 (lib) (requires build)
     - vector-0.12.2.0 (lib) (requires build)
     - fake-package-0 (lib) (first run)
    Starting     primitive-0.7.1.0 (lib)
    Building     primitive-0.7.1.0 (lib)
    Haddock      primitive-0.7.1.0 (lib)
    Installing   primitive-0.7.1.0 (lib)
    Completed    primitive-0.7.1.0 (lib)
    Starting     vector-0.12.2.0 (lib)
    Building     vector-0.12.2.0 (lib)
    Haddock      vector-0.12.2.0 (lib)
    Installing   vector-0.12.2.0 (lib)
    Completed    vector-0.12.2.0 (lib)
    Configuring library for fake-package-0..
    Preprocessing library for fake-package-0..
    Warning: No exposed modules
    GHCi, version 9.0.1: https://www.haskell.org/ghc/  :? for help
    Loaded GHCi configuration from /tmp/cabal-repl.-59300/setcwd.ghci
    ghci>  import qualified Data.Vector as V
    ghci> :doc V.partition
    ghc: Can't find any documentation for Data.Vector.
    This is probably because the module was compiled without '-haddock',
    but it's also possible that the module contains no documentation.
    
    Try re-compiling with '-haddock'.
    

    It's weird that the documentation can't be found, because it was apparently built.

  4. added this to the Considered for 3.10 milestone on Jun 30, 2022
  5. dmwit commented on Apr 21, 2023

    @dmwit
    Collaborator

    Thought I'd quickly mention a workaround for this. For packages that you are currently developing, you can request docs at repl time:

    cabal repl --ghc-options -haddock
    *Test> :doc test
     Hello, world!
    

    If you want docs available for dependencies, too, then as far as I can tell you must use a cabal.project (or .local), but it is still possible:

    package *
        ghc-options: -haddock
    

    This is a full rebuild, so beware of adding or removing this chunk if you've already got the project built!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions