diff options
author | simonmar <unknown> | 2002-07-15 10:14:31 +0000 |
---|---|---|
committer | simonmar <unknown> | 2002-07-15 10:14:31 +0000 |
commit | bd7eb8c45d4d03af5f3bb80538e6dd00353e075b (patch) | |
tree | 6738503e3ff196fb89f551d5124470284c4ffc04 /src/HaddockUtil.hs | |
parent | dde65bb94b04752bcdc5b16d6cd0944e21b4b6d0 (diff) |
[haddock @ 2002-07-15 10:14:30 by simonmar]
Be a bit more liberal in the kind of commenting styles we allow, as
suggested by Malcolm Wallace. Mostly this consists of allowing doc
comments either side of a separator token.
In an export list, a section heading is now allowed before the comma,
as well as after it. eg.
module M where (
T(..)
-- * a section heading
, f
-- * another section heading
, g
)
In record fields, doc comments are allowed anywhere (previously a
doc-next was allowed only after the comma, and a doc-before was
allowed only before the comma). eg.
data R = C {
-- | describes 'f'
f :: Int
-- | describes 'g'
, g :: Int
}
Diffstat (limited to 'src/HaddockUtil.hs')
-rw-r--r-- | src/HaddockUtil.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/HaddockUtil.hs b/src/HaddockUtil.hs index 3e7660bb..80800559 100644 --- a/src/HaddockUtil.hs +++ b/src/HaddockUtil.hs @@ -10,6 +10,7 @@ module HaddockUtil ( -- * Misc utilities nameOfQName, collectNames, declBinders, declMainBinder, declSubBinders, splitTyConApp, restrictTo, declDoc, parseModuleHeader, freeTyCons, unbang, + addFieldDoc, addFieldDocs, addConDoc, addConDocs, -- * Filename utilities basename, dirname, splitFilename3, @@ -33,6 +34,7 @@ import System import RegexString import Binary import IOExts +import Monad -- ----------------------------------------------------------------------------- -- Some Utilities @@ -95,6 +97,23 @@ freeTyCons ty = go ty [] go (HsTyVar v) r = r go (HsTyDoc t _) r = go t r +-- ----------------------------------------------------------------------------- +-- Adding documentation to record fields (used in parsing). + +addFieldDoc (HsFieldDecl ns ty doc1) doc2 = + HsFieldDecl ns ty (doc1 `mplus` doc2) + +addFieldDocs [] doc = [] +addFieldDocs (x:xs) doc = addFieldDoc x doc : xs + +addConDoc (HsConDecl pos nm tvs ctxt typeList doc1) doc2 = + HsConDecl pos nm tvs ctxt typeList (doc1 `mplus` doc2) +addConDoc (HsRecDecl pos nm tvs ctxt fields doc1) doc2= + HsRecDecl pos nm tvs ctxt fields (doc1 `mplus` doc2) + +addConDocs [] doc = [] +addConDocs (x:xs) doc = addConDoc x doc : xs + -- --------------------------------------------------------------------------- -- Making abstract declarations |