首页 > 解决方案 > 如何在 emacs 中对齐函数参数的 Haddock 注释?

问题描述

似乎记录函数参数的唯一方法是使用-- ^ docs herestyle。不幸的是,当函数参数的长度不同时,这会变得非常笨拙。例如:

myFunc :: (Int -> String -> Bool -> IO ())   -- ^ documentation string #1
       -> Int    -- ^ documentation string #2
       -> String    -- ^ documentation string #3                         
       -> Bool   -- ^ documentation string #4
       -> IO ()   -- ^ documentation string #5

将上述转换为以下,需要大量的手动工作:

myFunc :: (Int -> String -> Bool -> IO ())   -- ^ documentation string #1
       -> Int                                -- ^ documentation string #2
       -> String                             -- ^ documentation string #3                         
       -> Bool                               -- ^ documentation string #4
       -> IO ()                              -- ^ documentation string #5

在 Emacs 中是否有任何自动执行此操作的方法?或者还有其他更易于管理的方式来编写此文档吗?

标签: haskellemacscommentshaddock

解决方案


它没有回答有关如何自动对齐注释的问题,但是当类型变长时,我通常依赖于不同的格式样式:

myFunc
    :: (Int -> String -> Bool -> IO ())
    -- ^ documentation string #1
    -> Int
    -- ^ documentation string #2
    -> String
    -- ^ documentation string #3                         
    -> Bool
    -- ^ documentation string #4
    -> IO ()
    -- ^ documentation string #5

推荐阅读