26

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?

Heinrich Apfelmus
  • 11,034
  • 1
  • 39
  • 67
  • I think this functionally needs to be added to Cabal. – Theo Belaire Apr 11 '11 at 11:37
  • It is ugly, but maybe you can try adding the examples to your Library. In that case Haddock should automatically be run on them. The overall support of Haddock/Cabal/Hackage for anything but the most basic documentation needs is still lacking at the moment. – Alessandro Vermeulen Apr 13 '11 at 19:02
  • Ah, I don't want to run Haddock on the examples, I just want to run hscolour on them, but install them whenever the user types `cabal haddock`. – Heinrich Apfelmus Apr 14 '11 at 07:34

1 Answers1

2

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?

Marc
  • 4,546
  • 2
  • 29
  • 45
  • Nice idea, it gets me something, at least. Is there a way to bake the flags into the `.cabal` file? I don't want the user to fiddle with flags. – Heinrich Apfelmus Apr 20 '11 at 08:13
  • Not sure, but ask around on the cabal-devel discussion board. Someone's bound to have solved this and can get you up and running with this: http://www.haskell.org/mailman/listinfo/cabal-devel – Marc Apr 20 '11 at 13:58
  • Hackage runs --hyperlink-source by itself nowadays, I think. – Mateusz Kowalczyk Jan 13 '14 at 10:06