CurryInfo: cpm-manage-3.0.0 / CPM.Package.HTML.packageToHTML

definition:
packageToHTML :: [[Package]] -> Package -> IO String
packageToHTML allpkgversions pkg = do
  hasapidir  <- doesDirectoryExist apiDir
  hasaindex  <- doesFileExist $ apiDir </> indexhtml
  hasreadme  <- doesFileExist readmefile
  hasreadmei <- doesFileExist readmeifile
  readmei    <- if hasreadmei then readFile readmeifile else return ""
  let cidir  = "packages" </> pname </> "versions" </> pversion
  hascinfo   <- doesDirectoryExist $ curryInfoHtmlBase </> cidir
  mbpkgtime  <- getUploadTime pkg
  mbtested   <- getTestResults pkgid
  let apilinks = (if hasaindex
                    then [ehref (curryPackagesDocURL ++ pkgid </> indexhtml)
                                [htxt "API documentation"]]
                    else []) ++
                 (if hasapidir
                    then maybe []
                               (\mref -> [href mref [htxt "Manual (PDF)"]])
                               (manualURL pkg)
                    else [])
      cilink   = if hascinfo then [ehref (curryInfoHtmlURL </> cidir) 
                                         [htxt "Analysis information"]]
                             else []
      infomenu = (if hasreadme
                    then [ehref ("../" ++ readmefile) [htxt "README"]]
                    else []) ++
                 [ehref (pkgid ++ ".txt") [htxt "Package specification"]] ++
                 apilinks ++
                 [href (pname ++ "-deps.html") [htxt "Package dependencies"]] ++
                 cilink
      mbdocurl = if hasapidir then Just $ curryPackagesDocURL ++ pkgid
                              else Nothing
      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 [] (\t -> [blockstyle "badge badge-secondary"
                            [htxt $ "Uploaded at " ++
                                    calendarTimeToString t ++ " (UTC)"]])
                  mbpkgtime) ++
        (maybe [] (\s -> [blockstyle "badge badge-success" [htxt s]])
                  mbtested)
  let pkgdesc =  (if hasreadmei then [htmlText readmei] else []) ++
                 [hrule,
                  h2 [htxt "Download"],
                  dlist (map (\ (l,hs) -> ([htxt (l++": ")],hs))
                             (pkgtarref ++ showPkgSource pkg))]
  cpmPackagePage pname sidenav (map addNavLink apilinks) pkgdesc
 where
  addNavLink h = [h `addClass` "nav-link"]

  pname       = name pkg
  pkgid       = packageId pkg
  pversion    = showVersion (version pkg)
  apiDir      = "DOC" </> pkgid
  indexhtml   = "index.html"
  readmefile  = apiDir </> "README.html"
  readmeifile = apiDir </> "README_I.html"
  pkgtar      = pkgid ++ ".tar.gz"
  pkgtarref   = [("Checkout with CPM",
                  [kbdInput
                    [htxt $ "cypm checkout " ++ pname ++ " " ++ pversion]]),
                 ("Package source", 
                  [ehref (".." </> "PACKAGES" </> pkgtar) [htxt pkgtar],
                   htxt " [", href (pkgid ++ "-src.html") [htxt "browse"],
                   htxt "]"])]
demand:
no demanded arguments
deterministic:
deterministic operation
documentation:
------------------------------------------------------------------------------
--- Generate HTML page string for a given package.
failfree:
<FAILING>
indeterministic:
referentially transparent operation
infix:
no fixity defined
iotype:
{(_,_) |-> _}
name:
packageToHTML
precedence:
no precedence defined
result-values:
_
signature:
[[CPM.Package.Package]] -> CPM.Package.Package -> Prelude.IO String
solution-complete:
operation might suspend on free variables
terminating:
possibly non-terminating
totally-defined:
possibly non-reducible on same data term