Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haddock, Cabal: How to include source code examples?

I am the author of the operational package, which includes example code. I would like this example code to be hscolored and installed together with the API documentation, which is generated by Haddock.

I probably have to use a custom Cabal build type and create a user hook for the Haddock phase. However, I never managed to make this work. Hence, my question is:

How to include full modules as example code in Haddock?

Could you give an example of a Cabal user hook that applies hscolor to an additional source code file example.hs and joins the result with the generated Haddock documentation?

like image 335
Heinrich Apfelmus Avatar asked Apr 09 '11 08:04

Heinrich Apfelmus


1 Answers

I'm a total Haskell nube and this is a shot in the dark, but couldn't you use hscolour to output the code as HTML and then do something along the lines of cabal haddock --executables --hyperlink-source to include the colorized HTML?

like image 60
Marc Avatar answered Dec 08 '22 00:12

Marc