Enable --hyperlink-source for “cabal install”

随声附和 提交于 2019-12-18 12:49:56

问题


The command cabal haddock has very useful --hyperlink-source option. I would like to have the source hyperlinked when building documentation with cabal install.

The ticket #517 seems to be just about it: http://hackage.haskell.org/trac/hackage/ticket/517

However, perhaps it is possible to set this flag via ~/.cabal/config file?

If not, how can I get working cabal-install build with the patch from #517 without installing Cabal-1.9, which is currently mandatory (due to one patch from December)?


回答1:


Currently you cannot get the equivalent of the --hyperlink-source option when using the "all in one" cabal install command. The ticket you cite is exactly about this issue.




回答2:


For me this worked:

cabal update
cabal install haddock

Edit config file ~/.cabal/config

Enable Documentation: True (removing "-- " at the beginning of the line is fine)


Cabal Library:

cd ...someNicePlace...    

cabal unpack Cabal

Edit file Distribution/Simple/Setup.hs, therein find defaultHaddockFlags = ...

I switched some of them from False to True:

... 
haddockHoogle       = Flag True,
...
haddockHtml         = Flag True,
...
haddockExecutables  = Flag True,
...
haddockHscolour     = Flag True,
...

having haddockHscolour the only important one (don't have to change the others if not want to).

Install updated Cabal Library:

sudo cabal install --global

cabal-install (cabal shell command)

To get the updated Cabal Libary working within cabal shell command, I reinstalled cabal-install also:

cd ...someNicePlace...    

cabal unpack cabal-install

sudo cabal install --global

Since then the shell command cabal --version says to me:

cabal-install version 1.16.0.2 
using version 1.16.0.3 of the Cabal library 

And, as wanted, any new cabal install is now installing full haddock html documentation with source codes hyperlinked as default.




回答3:


Ticket #517 is about passing haddock options via cabal, like if you have special needs like building a hoogle database or usa a different CSS

Most users will be happy with standard haddock and hyperlinked sources though, which is possible with Cabal-1.8. Ticket #517 is if you have bigger needs.

Simply calling cabal haddock --hyperlink-source should do the trick.

If you want this as the default, you can edit ~/.cabal/config as you mentioned.



来源:https://stackoverflow.com/questions/2472630/enable-hyperlink-source-for-cabal-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!