definition:
|
generateHtmlDocs :: DocOptions -> AnaInfo -> String -> String
-> [(SourceLine,String)] -> IO String
generateHtmlDocs opts anainfo modname modcmts progcmts = do
acyname <- getLoadPathForModule modname >>=
getFileWithSuffix (abstractCurryFileName modname) [""]
putStrLn $ "Reading AbstractCurry program \""++acyname++"\"..."
(CurryProg _ imports _ _ _ types functions ops) <-
readAbstractCurryFile acyname
let
exptypes = filter isExportedType types
expfuns = filter isExportedFun functions
propspecs = map cmtFunc2Func
(filter (\fd -> isProperty fd || isSpecFunc fd) functions)
{-
sidenav =
[ulistWithClass "list-group" "list-group-item"
(map (\ (t,c) -> (h5 [htxt t] : c))
(packageInfoAsHTML allpkgversions pkg mbdocurl ++
[("Further infos:",
[ulistWithClass "nav flex-column" "nav-item"
(map addNavLink infomenu)])]))] ++
(maybe [] (\s -> [blockstyle "badge badge-success" [htxt s]]) mbtested)
-}
navigation =
[ ulistWithClass "list-group" "list-group-item"
[[h5 [htxt "Exported names:"],
genHtmlExportIndex (map tName exptypes)
(getExportedCons types)
(getExportedFields types)
(map fName expfuns)],
[anchored "imported_modules" [h5 [htxt "Imported modules:"]],
ulistWithClass "nav flex-column" "nav-item"
(map (\i -> [href (docURL opts i ++ ".html") [htxt i]])
(nub (if modname /= "Prelude" then "Prelude" : imports
else imports)))]]
]
content =
genHtmlModule opts modcmts ++
[ h2 [htxt "Summary of exported operations:"]
, borderedTable (map (genHtmlFuncShort opts progcmts anainfo) expfuns)
] ++
ifNotNull exptypes (\tys ->
[anchoredSection "exported_datatypes"
(h2 [htxt "Exported datatypes:"] : hrule :
concatMap (genHtmlType opts progcmts) tys)]) ++
[anchoredSection "exported_operations"
(h2 [htxt "Exported operations:"] :
map (genHtmlFunc opts modname progcmts
(attachProperties2Funcs propspecs progcmts) anainfo ops)
expfuns)
]
mainPage ("?", [htxt title]) title [htmltitle]
(lefttopmenu types functions) rightTopMenu
navigation content
where
title = "Module " ++ modname
htmltitle = h1 [ htxt "Module "
, href (modname ++ "_curry.html") [htxt modname]
]
lefttopmenu :: [CTypeDecl] -> [CFuncDecl] -> [[BaseHtml]]
lefttopmenu ts fs =
[[hrefNav "#imported_modules" [htxt "Imports"]]] ++
ifNotNull ts
(const [[hrefNav "#exported_datatypes" [htxt "Datatypes" ]]]) ++
ifNotNull fs
(const [[hrefNav "#exported_operations" [htxt "Operations"]]])
cmtFunc2Func fdecl = case fdecl of
CmtFunc _ qn a v tExp rs -> CFunc qn a v tExp rs
_ -> fdecl
|