是否可以使用Haddock记录类方法并在实例声明代码中查询文档片段?
例如,我希望课程记录如下:
class ModifMATH a where
-- | Explanations of simpMath method.
--
--
-- $part1
-- $part2
-- $part3
simpMath :: a -> a
并且实例记录如下:
instance ModifMATH MathExpress where
-- $part1 a piece of explanation
simpMath (MathDouble n) = ...
-- $part2 another explanation
simpMath (MathMult a b) = ...
-- $part3 end of explanations
simpMath (MathAdd a b) = ...
并获取html Haddock文档看起来像这样(对不起,我没有图像):
class ModifMATH a where
Methods
simpMath :: a -> a
Explanations of simpMath method.
a piece of explanation
another explanation
end of explanations
在实例中添加模式同时将整个方法文档保存在独立段落中时,此文档组织将更具可读性和可扩展性。有可能吗?
我正在使用Haddock版本2.10.0。在Debian 7.0上。
感谢您的帮助。
答案 0 :(得分:2)
不,不可能像这样拆分文档。
唯一可以或多或少地执行此操作的地方是case of some questionable use of record fields,但不适用于此处,我们在2.14.x中更改了此行为。
也许您可以使用a definition list尝试在文档中进行自然分割。例如,像
class ModifMATH a where
-- | Explanations of simpMath method.
--
-- [MathDouble case] $part1
--
-- [MathMult case] $part2
--
-- [MathAdd case] $part3
simpMath :: a -> a
请注意,文档引用的是2.14.x版本,它比您正在使用的版本更新一些,例如每个定义列表之间的换行符是必要的。
看起来应该或多或少:
deflist http://fuuzetsu.co.uk/images/1399715808.png
如果需要,您可以多行,请参阅文档。