Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed images in Haddock documentation

How can I embed images within local Haddock documentation?

I see for example the lens package just uses external links to images, but I'd like to store the images locally.

(This question is very similar to an (unanswered) question on the mailing list).

like image 832
amindfv Avatar asked Dec 24 '12 04:12

amindfv


3 Answers

If you want to store your image locally you can:

-- A longer description of the package.
description: Some haskell package description.

    <<file:///home/user/your_image.png>>

Result:

Enter image description here

If you don't want or can't add image by relative path, just put image name without full path:

<<your_image.png>>

In this case, your image must be in the project/docs directory.

like image 58
0xAX Avatar answered Oct 29 '22 06:10

0xAX


As explained in that mailing list thread you reference, one option is to use a data URL to inline images into your documentation. It makes the source itself somewhat unpleasant to read (since it is interspersed with large blobs of base64-encoded data), though using Haddock's named chunks can help, by putting all the images in named chunks at the end of the file. For a real-world example of this approach, see the Haddock documentation for the circle-packing package.

like image 10
Brent Yorgey Avatar answered Oct 29 '22 06:10

Brent Yorgey


As explained in a blog post by Ian Ross you could use extra-doc-files cabal option to bundle extra files into the documentation.

like image 9
phadej Avatar answered Oct 29 '22 06:10

phadej