2015-10-16 29 views
4

假設我有一個模塊從內部模塊再出口值:更改爲再出口類型的文檔和值

module My.Cool.Module (SomeType, someValue) where 
import My.Cool.Module.Internal (SomeType, someValue) 

我想,以示對SomeTypeMy-Cool-Module.html不同文檔someValueMy-Cool-Module-Internal.html,因此前者可以討論公共API,後者可以討論它們與其他內部組件的關係。

有沒有辦法用haddock做到這一點?

我想:

module My.Cool.Module (SomeType, someValue) where 
import My.Cool.Module.Internal 
    (SomeType --^a serious type for serious people 
    , someValue --^a serious value for serious people 
) 

但是鱈魚給了我一個解析錯誤:

parse error on input ‘--^a serious type for serious people’ 
+1

難道你不能重新導出函數,只需重新定義它?我的意思是導入'內部'限定並定義'someType = Internal.someType'。這應該允許你添加你自己的文檔。 – mb14

+0

mb14:看起來不錯。重新定義類型似乎有問題。 – rampion

+0

你是對的,我沒有意識到你也在問類型。 – mb14

回答

3

好吧,這裏我可以忍受一劈。

Haddock允許您插入named chunks of documentation,它們按照它們定義的順序顯示。這些命名塊只顯示它們所在的模塊,而不顯示從該模塊重新導出值或類型的任何文件。

所以內部模塊中,我可以公開API文檔之後插入包含內部文件命名塊:

-- | Have you welcomed internal modules into your life? 
module Public.Private where 

-- | Here's the public API information for 'SomeType' 
type SomeType =() 
-- $ 
-- Here's the internal information about 'SomeType': it's really just a stand-in 
-- for San Francisco 

-- | Here's the public API information for 'someValue' 
someValue :: SomeType 
-- $ Here's the internal information about 'someValue': it loves cheese. 
someValue =() 

,然後導出類型和值正常

-- | This is a very serious public API 
module Public (SomeType, someValue) where 
import Public.Private (SomeType , someValue) 

現在生成的文檔Public.Private顯示公共文檔後的內部文檔:

Generated HTML documentation for Public.Private

雖然Public文檔導出的項目不顯示內部文件:

Generated HTML documentation for Public

這隻讓我追加私人文檔,但總比沒有好。