definition:
|
packageInfoAsHTML :: [[Package]] -> Package -> Maybe String
-> [(String,[BaseHtml])]
packageInfoAsHTML allpkgversions pkg mbdocurl =
[ ("Synopsis", [ htxt (synopsis pkg) ]) ] ++
cats ++
[ ("Versions", hitems $ map (showPkgVersion pkg) pkgversions)
, ("Dependencies", hitems $ map dep2html $ dependencies pkg)
, ("Author", auth) ] ++
maintnr ++
compilers ++
expmods ++
executables ++
showParaField description "Description" ++
showLicense ++
showParaField copyright "Copyright" ++
showUrlField homepage "Homepage" ++
showUrlField repository "Repository" ++
showUrlField bugReports "Bug reports"
where
pkgversions = maybe []
(map version)
(find (\pg -> not (null pg) && name (head pg) == name pkg)
allpkgversions)
auth = vitems $ map (htxt . strip) (concatMap (splitOn ",") $ author pkg)
maintnr = case maintainer pkg of
[] -> []
xs -> [("Maintainer", vitems $ map htxt (concatMap (splitOn ",") xs))]
cats =
let pcats = category pkg
in if null pcats
then []
else [("Categor" ++ if length pcats == 1 then "y" else "ies",
hitems $
map (\c -> hrefPrimBadge ("../indexc.html#" ++ c) [htxt c])
pcats)]
dep2html dep@(Dependency dp vcs) =
maybe (htxt $ showDependency dep)
(\_ -> hrefPrimBadge (dp ++ ".html")
[htxt dp, nbsp,
showConstraintBadge (showVersionConstraints vcs)])
(find (\pgs -> not (null pgs) && name (head pgs) == dp)
allpkgversions)
compilers =
if null (compilerCompatibility pkg)
then []
else [("Compiler requirements",
hitems $ map showCompilerReq $ compilerCompatibility pkg)]
expmods =
if null (exportedModules pkg)
then []
else [("Exported modules",
hitems $
map (\m -> code [maybe (htxt m)
(\u -> ehrefPrimBadge (u </> m ++ ".html")
[htxt m])
mbdocurl])
(exportedModules pkg))]
executables = case executableSpec pkg of
[] -> []
[ex] -> [("Executable installed by package", getExName ex)]
exs -> [("Executables installed by package",
intercalate [nbsp] (map getExName exs))]
where
getExName (PackageExecutable n _ _) = [kbdInput [htxt n]]
showLicense =
let lkind = case license pkg of
Nothing -> []
Just s -> [htxt s]
lfile = case licenseFile pkg of
Nothing -> []
Just f -> [ehref (".." </> "PACKAGES" </> packageId pkg </> f)
[htxt "License file"]]
in [("License", intersperse (htxt " / ") (lkind ++ lfile))]
showUrlField fgetter fname = case fgetter pkg of
Nothing -> []
Just s -> [(fname, [showURL s])]
showParaField fgetter fname = case fgetter pkg of
Nothing -> []
Just s -> [(fname, [htxt s])]
|