1

Aim: document a repo with plutus code using haddock.

Problem: Naively running cabal haddock has a problem that seems to be caused by plutus (on-chain) code.

For example, plutus-pioneer-program week03 runs in the repl with cabal repl, but cabal haddock errors as follows.

Haddock coverage:
GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable Ledger.Typed.Scripts.Validators.wrapValidator
            No unfolding
Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
                           @ Week03.Homework1.VestingDatum
Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
                           @ Week03.Homework1.VestingDatum @ ()
Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
                           @ Week03.Homework1.VestingDatum
                           @ ()
                           Week03.Homework1.$fUnsafeFromDataVestingDatum
Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
                           @ Week03.Homework1.VestingDatum
                           @ ()
                           Week03.Homework1.$fUnsafeFromDataVestingDatum
                           PlutusTx.IsData.Instances.$fUnsafeFromData()
Context: Compiling expr at "plutus-pioneer-program-week03-0.1.0.0-inplace:Week03.Homework1:(60,8)-(60,37)"
cabal: Failed to build documentation for
plutus-pioneer-program-week03-0.1.0.0.

Is there a straightforward way to build haddock docs for repos with plutus code?

1 Answer 1

3

Yes! Try cabal haddock -fplugin-opt Plutus.Tx.Plugin:defer-errors.

(From https://plutus-apps.readthedocs.io/en/latest/plutus/troubleshooting.html#plugin-errors)

1
  • Editing the cabal.project file as the link suggests gets cabal haddock working so I'm good. Passing cli arguments as suggested above or in the docs linked gives an error: cabal: Unrecognised target 'PlutusTx.Plugin:defer-errors'. Expected a module name, rather than 'defer-errors'. I tried various perturbations such as Plutus.Tx...
    – waalge
    Jan 31, 2022 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.