From 1554c09a07c32be5f506a51f06ef5f3fdc41443b Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 15 May 2002 13:03:02 +0000 Subject: [haddock @ 2002-05-15 13:03:01 by simonmar] Reworking of the internals to support documenting function arguments (the Most Wanted new feature by the punters). The old method of keeping parsed documentation in a Name -> Doc mapping wasn't going to cut it for anntations on type components, where there's no name to attach the documentation to, so I've moved to storing all the documentation in the abstract syntax. Previously some of the documentation was left in the abstract syntax by the parser, but was later extracted into the mapping. In order to avoid having to parameterise the abstract syntax over the type of documentation stored in it, we have to parse the documentation at the same time as we parse the Haskell source (well, I suppose we could store 'Either String Doc' in the HsSyn, but that's clunky). One upshot is that documentation is now parsed eagerly, and documentation parse errors are fatal (but have better line numbers in the error message). The new story simplifies matters for the code that processes the source modules, because we don't have to maintain the extra Name->Doc mapping, and it should improve efficiency a little too. New features: - Function arguments and return values can now have doc annotations. - If you refer to a qualified name in a doc string, eg. 'IO.putStr', then Haddock will emit a hyperlink even if the identifier is not in scope, so you don't have to make sure everything referred to from the documentation is imported. - several bugs & minor infelicities fixed. --- src/HaddockDB.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/HaddockDB.hs') diff --git a/src/HaddockDB.hs b/src/HaddockDB.hs index a2a4a8e7..ebd0ccb2 100644 --- a/src/HaddockDB.hs +++ b/src/HaddockDB.hs @@ -6,7 +6,7 @@ module HaddockDB (ppDocBook) where -import HaddockTypes hiding (Doc) +import HaddockTypes import HaddockUtil import HsSyn @@ -16,6 +16,8 @@ import FiniteMap ----------------------------------------------------------------------------- -- Printing the results in DocBook format +ppDocBook = error "not working" +{- ppDocBook :: FilePath -> [(Module, Interface)] -> String ppDocBook odir mods = render (ppIfaces mods) @@ -55,22 +57,22 @@ ppIfaces mods $$ text "" do_export _ _ = empty - do_decl (HsTypeSig _ [nm] ty) + do_decl (HsTypeSig _ [nm] ty _) = ppHsName nm <> text " :: " <> ppHsType ty - do_decl (HsTypeDecl _ nm args ty) + do_decl (HsTypeDecl _ nm args ty _) = hsep ([text "type", ppHsName nm ] ++ map ppHsName args ++ [equals, ppHsType ty]) - do_decl (HsNewTypeDecl loc ctx nm args con drv) + do_decl (HsNewTypeDecl loc ctx nm args con drv _) = hsep ([text "data", ppHsName nm] -- data, not newtype ++ map ppHsName args ) <+> equals <+> ppHsConstr con -- ToDo: derivings - do_decl (HsDataDecl loc ctx nm args cons drv) + do_decl (HsDataDecl loc ctx nm args cons drv _) = hsep ([text "data", {-ToDo: context-}ppHsName nm] ++ map ppHsName args) <+> vcat (zipWith (<+>) (equals : repeat (char '|')) (map ppHsConstr cons)) - do_decl (HsClassDecl loc ty fds decl) + do_decl (HsClassDecl loc ty fds decl _) = hsep [text "class", ppHsType ty] do_decl decl = empty @@ -158,3 +160,4 @@ ubxParenList :: [Doc] -> Doc ubxParenList = ubxparens . fsep . punctuate comma ubxparens p = text "(#" <> p <> text "#)" +-} -- cgit v1.2.3