Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haddock - link to function in external module (whole module imported)

Suppose I have a Haskell module named MyModule that imports an external module like this:

import ModuleA hiding (a, b, c)

And I cannot modify this import statement, because the program is not exactly mine.

I wish to link to ModuleA.external_function in the documentation for ModuleA, in the comments above a function called my_function. So the code looks something like this:

-- | my_function makes use of 'ModuleA.external_function'
my_function :: Int -> Int

Using haddock 2.10.0, and running cabal haddock, the link to ModuleA.external_function is generated as dist/doc/html/MyModule/ModuleA.html#v:external_function . However, the problem is that the dist/doc/html/MyModule/ModuleA.html file does not exist.

How can I generate a link to the docs for ModuleA instead, like module-A-package/docs/ModuleA.html#v:external_function. In other words, something similar to what http://hackage.haskell.org/package/text-0.11.2.0/docs/Data-Text.html has for its links to the String type (they link to http://hackage.haskell.org/package/base-4.5.0.0/docs/Data-String.html#t:String)? Bear in mind that I cannot modify the import statement.

Thank you.

like image 331
yanhan Avatar asked Jan 05 '14 04:01

yanhan


1 Answers

To make links to external packages in the Haddock documentation, you need to instruct it where to find the documentation for those packages.

It is done by using the --read-interface Haddock command-line option.

Using your example, it will be :

haddock --read-interface module-A-package/docs/,module-A-package/docs/module-A-package.haddock

The .haddock file is made when generating documentation for the package module-A-package using ----dump-interface Haddock command-line option.

More information can be found on the Haddock documentation or this HaskellWiki page.

like image 150
Damien Flament Avatar answered Nov 04 '22 11:11

Damien Flament