{-# LANGUAGE OverloadedStrings #-}
module Futhark.Doc.Generator (renderFiles) where
import qualified CMarkGFM as GFM
import Control.Arrow ((***))
import Control.Monad
import Control.Monad.Reader
import Control.Monad.Writer hiding (Sum)
import Data.Char (isAlpha, isSpace, toUpper)
import Data.List (find, groupBy, inits, intersperse, isPrefixOf, partition, sort, sortOn, tails)
import qualified Data.Map as M
import Data.Maybe
import Data.Ord
import qualified Data.Set as S
import Data.String (fromString)
import qualified Data.Text as T
import Data.Version
import Futhark.Util.Pretty (Doc, ppr)
import Futhark.Version
import Language.Futhark
import Language.Futhark.Semantic
import Language.Futhark.TypeChecker.Monad hiding (warn)
import System.FilePath (makeRelative, splitPath, (-<.>), (<.>), (</>))
import Text.Blaze.Html5 (AttributeValue, Html, toHtml, (!))
import qualified Text.Blaze.Html5 as H
import qualified Text.Blaze.Html5.Attributes as A
import Prelude hiding (abs)
docToHtml :: Doc -> Html
docToHtml :: Doc -> Html
docToHtml = FilePath -> Html
forall a. ToMarkup a => a -> Html
toHtml (FilePath -> Html) -> (Doc -> FilePath) -> Doc -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> FilePath
forall a. Pretty a => a -> FilePath
pretty
primTypeHtml :: PrimType -> Html
primTypeHtml :: PrimType -> Html
primTypeHtml = Doc -> Html
docToHtml (Doc -> Html) -> (PrimType -> Doc) -> PrimType -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrimType -> Doc
forall a. Pretty a => a -> Doc
ppr
prettyU :: Uniqueness -> Html
prettyU :: Uniqueness -> Html
prettyU = Doc -> Html
docToHtml (Doc -> Html) -> (Uniqueness -> Doc) -> Uniqueness -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Uniqueness -> Doc
forall a. Pretty a => a -> Doc
ppr
renderName :: Name -> Html
renderName :: Name -> Html
renderName Name
name = Doc -> Html
docToHtml (Name -> Doc
forall a. Pretty a => a -> Doc
ppr Name
name)
joinBy :: Html -> [Html] -> Html
joinBy :: Html -> [Html] -> Html
joinBy Html
_ [] = Html
forall a. Monoid a => a
mempty
joinBy Html
_ [Html
x] = Html
x
joinBy Html
sep (Html
x : [Html]
xs) = Html
x Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html) -> [Html] -> Html
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Html
sep Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) [Html]
xs
commas :: [Html] -> Html
commas :: [Html] -> Html
commas = Html -> [Html] -> Html
joinBy Html
", "
parens :: Html -> Html
parens :: Html -> Html
parens Html
x = Html
"(" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
x Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
")"
braces :: Html -> Html
braces :: Html -> Html
braces Html
x = Html
"{" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
x Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
"}"
brackets :: Html -> Html
brackets :: Html -> Html
brackets Html
x = Html
"[" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
x Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
"]"
pipes :: [Html] -> Html
pipes :: [Html] -> Html
pipes = Html -> [Html] -> Html
joinBy Html
" | "
type NoLink = S.Set VName
data Context = Context
{ Context -> FilePath
ctxCurrent :: String,
Context -> FileModule
ctxFileMod :: FileModule,
Context -> Imports
ctxImports :: Imports,
Context -> NoLink
ctxNoLink :: NoLink,
Context -> Map VName (FilePath, Namespace)
ctxFileMap :: FileMap,
Context -> NoLink
ctxVisibleMTys :: S.Set VName
}
type FileMap = M.Map VName (String, Namespace)
type DocM = ReaderT Context (WriterT Documented (Writer Warnings))
data IndexWhat = IndexValue | IxFun | IndexModule | IndexModuleType | IndexType
type Documented = M.Map VName IndexWhat
warn :: SrcLoc -> Doc -> DocM ()
warn :: SrcLoc -> Doc -> DocM ()
warn SrcLoc
loc Doc
s = WriterT Documented (Writer Warnings) () -> DocM ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (WriterT Documented (Writer Warnings) () -> DocM ())
-> WriterT Documented (Writer Warnings) () -> DocM ()
forall a b. (a -> b) -> a -> b
$ Writer Warnings () -> WriterT Documented (Writer Warnings) ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Writer Warnings () -> WriterT Documented (Writer Warnings) ())
-> Writer Warnings () -> WriterT Documented (Writer Warnings) ()
forall a b. (a -> b) -> a -> b
$ Warnings -> Writer Warnings ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Warnings -> Writer Warnings ()) -> Warnings -> Writer Warnings ()
forall a b. (a -> b) -> a -> b
$ SrcLoc -> Doc -> Warnings
singleWarning SrcLoc
loc Doc
s
document :: VName -> IndexWhat -> DocM ()
document :: VName -> IndexWhat -> DocM ()
document VName
v IndexWhat
what = Documented -> DocM ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Documented -> DocM ()) -> Documented -> DocM ()
forall a b. (a -> b) -> a -> b
$ VName -> IndexWhat -> Documented
forall k a. k -> a -> Map k a
M.singleton VName
v IndexWhat
what
noLink :: [VName] -> DocM a -> DocM a
noLink :: forall a. [VName] -> DocM a -> DocM a
noLink [VName]
names = (Context -> Context)
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local ((Context -> Context)
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
-> ReaderT Context (WriterT Documented (Writer Warnings)) a)
-> (Context -> Context)
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall a b. (a -> b) -> a -> b
$ \Context
ctx ->
Context
ctx {ctxNoLink :: NoLink
ctxNoLink = [VName] -> NoLink
forall a. Ord a => [a] -> Set a
S.fromList [VName]
names NoLink -> NoLink -> NoLink
forall a. Semigroup a => a -> a -> a
<> Context -> NoLink
ctxNoLink Context
ctx}
selfLink :: AttributeValue -> Html -> Html
selfLink :: AttributeValue -> Html -> Html
selfLink AttributeValue
s = Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
s (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (AttributeValue
"#" AttributeValue -> AttributeValue -> AttributeValue
forall a. Semigroup a => a -> a -> a
<> AttributeValue
s) (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"self_link"
fullRow :: Html -> Html
fullRow :: Html -> Html
fullRow = Html -> Html
H.tr (Html -> Html) -> (Html -> Html) -> Html -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.colspan AttributeValue
"3")
emptyRow :: Html
emptyRow :: Html
emptyRow = Html -> Html
H.tr (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.td Html
forall a. Monoid a => a
mempty Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.td Html
forall a. Monoid a => a
mempty Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.td Html
forall a. Monoid a => a
mempty
specRow :: Html -> Html -> Html -> Html
specRow :: Html -> Html -> Html -> Html
specRow Html
a Html
b Html
c =
Html -> Html
H.tr (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"spec_lhs") Html
a
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"spec_eql") Html
b
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"spec_rhs") Html
c
vnameToFileMap :: Imports -> FileMap
vnameToFileMap :: Imports -> Map VName (FilePath, Namespace)
vnameToFileMap = [Map VName (FilePath, Namespace)]
-> Map VName (FilePath, Namespace)
forall a. Monoid a => [a] -> a
mconcat ([Map VName (FilePath, Namespace)]
-> Map VName (FilePath, Namespace))
-> (Imports -> [Map VName (FilePath, Namespace)])
-> Imports
-> Map VName (FilePath, Namespace)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((FilePath, FileModule) -> Map VName (FilePath, Namespace))
-> Imports -> [Map VName (FilePath, Namespace)]
forall a b. (a -> b) -> [a] -> [b]
map (FilePath, FileModule) -> Map VName (FilePath, Namespace)
forall {a}. (a, FileModule) -> Map VName (a, Namespace)
forFile
where
forFile :: (a, FileModule) -> Map VName (a, Namespace)
forFile (a
file, FileModule TySet
abs Env
file_env Prog
_prog) =
[Map VName (a, Namespace)] -> Map VName (a, Namespace)
forall a. Monoid a => [a] -> a
mconcat ((QualName VName -> Map VName (a, Namespace))
-> [QualName VName] -> [Map VName (a, Namespace)]
forall a b. (a -> b) -> [a] -> [b]
map (Namespace -> QualName VName -> Map VName (a, Namespace)
forall {b} {k}. b -> QualName k -> Map k (a, b)
vname Namespace
Type) (TySet -> [QualName VName]
forall k a. Map k a -> [k]
M.keys TySet
abs))
Map VName (a, Namespace)
-> Map VName (a, Namespace) -> Map VName (a, Namespace)
forall a. Semigroup a => a -> a -> a
<> Env -> Map VName (a, Namespace)
forEnv Env
file_env
where
vname :: b -> QualName k -> Map k (a, b)
vname b
ns QualName k
v = k -> (a, b) -> Map k (a, b)
forall k a. k -> a -> Map k a
M.singleton (QualName k -> k
forall vn. QualName vn -> vn
qualLeaf QualName k
v) (a
file, b
ns)
vname' :: ((b, b), QualName k) -> Map k (a, b)
vname' ((b
ns, b
_), QualName k
v) = b -> QualName k -> Map k (a, b)
forall {b} {k}. b -> QualName k -> Map k (a, b)
vname b
ns QualName k
v
forEnv :: Env -> Map VName (a, Namespace)
forEnv Env
env =
[Map VName (a, Namespace)] -> Map VName (a, Namespace)
forall a. Monoid a => [a] -> a
mconcat ((((Namespace, Name), QualName VName) -> Map VName (a, Namespace))
-> [((Namespace, Name), QualName VName)]
-> [Map VName (a, Namespace)]
forall a b. (a -> b) -> [a] -> [b]
map ((Namespace, Name), QualName VName) -> Map VName (a, Namespace)
forall {b} {b} {k}. ((b, b), QualName k) -> Map k (a, b)
vname' ([((Namespace, Name), QualName VName)]
-> [Map VName (a, Namespace)])
-> [((Namespace, Name), QualName VName)]
-> [Map VName (a, Namespace)]
forall a b. (a -> b) -> a -> b
$ Map (Namespace, Name) (QualName VName)
-> [((Namespace, Name), QualName VName)]
forall k a. Map k a -> [(k, a)]
M.toList (Map (Namespace, Name) (QualName VName)
-> [((Namespace, Name), QualName VName)])
-> Map (Namespace, Name) (QualName VName)
-> [((Namespace, Name), QualName VName)]
forall a b. (a -> b) -> a -> b
$ Env -> Map (Namespace, Name) (QualName VName)
envNameMap Env
env)
Map VName (a, Namespace)
-> Map VName (a, Namespace) -> Map VName (a, Namespace)
forall a. Semigroup a => a -> a -> a
<> [Map VName (a, Namespace)] -> Map VName (a, Namespace)
forall a. Monoid a => [a] -> a
mconcat ((MTy -> Map VName (a, Namespace))
-> [MTy] -> [Map VName (a, Namespace)]
forall a b. (a -> b) -> [a] -> [b]
map MTy -> Map VName (a, Namespace)
forMty ([MTy] -> [Map VName (a, Namespace)])
-> [MTy] -> [Map VName (a, Namespace)]
forall a b. (a -> b) -> a -> b
$ Map VName MTy -> [MTy]
forall k a. Map k a -> [a]
M.elems (Map VName MTy -> [MTy]) -> Map VName MTy -> [MTy]
forall a b. (a -> b) -> a -> b
$ Env -> Map VName MTy
envSigTable Env
env)
forMod :: Mod -> Map VName (a, Namespace)
forMod (ModEnv Env
env) = Env -> Map VName (a, Namespace)
forEnv Env
env
forMod ModFun {} = Map VName (a, Namespace)
forall a. Monoid a => a
mempty
forMty :: MTy -> Map VName (a, Namespace)
forMty = Mod -> Map VName (a, Namespace)
forMod (Mod -> Map VName (a, Namespace))
-> (MTy -> Mod) -> MTy -> Map VName (a, Namespace)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MTy -> Mod
mtyMod
renderFiles :: [FilePath] -> Imports -> ([(FilePath, Html)], Warnings)
renderFiles :: [FilePath] -> Imports -> ([(FilePath, Html)], Warnings)
renderFiles [FilePath]
important_imports Imports
imports = Writer Warnings [(FilePath, Html)]
-> ([(FilePath, Html)], Warnings)
forall w a. Writer w a -> (a, w)
runWriter (Writer Warnings [(FilePath, Html)]
-> ([(FilePath, Html)], Warnings))
-> Writer Warnings [(FilePath, Html)]
-> ([(FilePath, Html)], Warnings)
forall a b. (a -> b) -> a -> b
$ do
([(FilePath, (Html, Html))]
import_pages, Documented
documented) <- WriterT Documented (Writer Warnings) [(FilePath, (Html, Html))]
-> Writer Warnings ([(FilePath, (Html, Html))], Documented)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
runWriterT (WriterT Documented (Writer Warnings) [(FilePath, (Html, Html))]
-> Writer Warnings ([(FilePath, (Html, Html))], Documented))
-> WriterT Documented (Writer Warnings) [(FilePath, (Html, Html))]
-> Writer Warnings ([(FilePath, (Html, Html))], Documented)
forall a b. (a -> b) -> a -> b
$
Imports
-> ((FilePath, FileModule)
-> WriterT Documented (Writer Warnings) (FilePath, (Html, Html)))
-> WriterT Documented (Writer Warnings) [(FilePath, (Html, Html))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM Imports
imports (((FilePath, FileModule)
-> WriterT Documented (Writer Warnings) (FilePath, (Html, Html)))
-> WriterT Documented (Writer Warnings) [(FilePath, (Html, Html))])
-> ((FilePath, FileModule)
-> WriterT Documented (Writer Warnings) (FilePath, (Html, Html)))
-> WriterT Documented (Writer Warnings) [(FilePath, (Html, Html))]
forall a b. (a -> b) -> a -> b
$ \(FilePath
current, FileModule
fm) ->
let ctx :: Context
ctx =
FilePath
-> FileModule
-> Imports
-> NoLink
-> Map VName (FilePath, Namespace)
-> NoLink
-> Context
Context
FilePath
current
FileModule
fm
Imports
imports
NoLink
forall a. Monoid a => a
mempty
Map VName (FilePath, Namespace)
file_map
(Prog -> NoLink
forall vn (f :: * -> *). Ord vn => ProgBase f vn -> Set vn
progModuleTypes (Prog -> NoLink) -> Prog -> NoLink
forall a b. (a -> b) -> a -> b
$ FileModule -> Prog
fileProg FileModule
fm)
in (ReaderT
Context
(WriterT Documented (Writer Warnings))
(FilePath, (Html, Html))
-> Context
-> WriterT Documented (Writer Warnings) (FilePath, (Html, Html)))
-> Context
-> ReaderT
Context
(WriterT Documented (Writer Warnings))
(FilePath, (Html, Html))
-> WriterT Documented (Writer Warnings) (FilePath, (Html, Html))
forall a b c. (a -> b -> c) -> b -> a -> c
flip ReaderT
Context
(WriterT Documented (Writer Warnings))
(FilePath, (Html, Html))
-> Context
-> WriterT Documented (Writer Warnings) (FilePath, (Html, Html))
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT Context
ctx (ReaderT
Context
(WriterT Documented (Writer Warnings))
(FilePath, (Html, Html))
-> WriterT Documented (Writer Warnings) (FilePath, (Html, Html)))
-> ReaderT
Context
(WriterT Documented (Writer Warnings))
(FilePath, (Html, Html))
-> WriterT Documented (Writer Warnings) (FilePath, (Html, Html))
forall a b. (a -> b) -> a -> b
$ do
(Html
first_paragraph, Html
maybe_abstract, Html
maybe_sections) <- Prog -> DocM (Html, Html, Html)
headerDoc (Prog -> DocM (Html, Html, Html))
-> Prog -> DocM (Html, Html, Html)
forall a b. (a -> b) -> a -> b
$ FileModule -> Prog
fileProg FileModule
fm
Html
synopsis <- (Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"module") (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisDecs (Prog -> [Dec]
forall (f :: * -> *) vn. ProgBase f vn -> [DecBase f vn]
progDecs (Prog -> [Dec]) -> Prog -> [Dec]
forall a b. (a -> b) -> a -> b
$ FileModule -> Prog
fileProg FileModule
fm)
Html
description <- [Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeDecs ([Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Prog -> [Dec]
forall (f :: * -> *) vn. ProgBase f vn -> [DecBase f vn]
progDecs (Prog -> [Dec]) -> Prog -> [Dec]
forall a b. (a -> b) -> a -> b
$ FileModule -> Prog
fileProg FileModule
fm
(FilePath, (Html, Html))
-> ReaderT
Context
(WriterT Documented (Writer Warnings))
(FilePath, (Html, Html))
forall (m :: * -> *) a. Monad m => a -> m a
return
( FilePath
current,
( Html -> Html
H.docTypeHtml (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.lang AttributeValue
"en" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
[FilePath] -> Imports -> FilePath -> FilePath -> Html -> Html
addBoilerplateWithNav [FilePath]
important_imports Imports
imports (FilePath
"doc" FilePath -> FilePath -> FilePath
</> FilePath
current) FilePath
current (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.main (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html
maybe_abstract
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> AttributeValue -> Html -> Html
selfLink AttributeValue
"synopsis" (Html -> Html
H.h2 Html
"Synopsis")
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"overview") Html
synopsis
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> AttributeValue -> Html -> Html
selfLink AttributeValue
"description" (Html -> Html
H.h2 Html
"Description")
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
description
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
maybe_sections,
Html
first_paragraph
)
)
[(FilePath, Html)] -> Writer Warnings [(FilePath, Html)]
forall (m :: * -> *) a. Monad m => a -> m a
return ([(FilePath, Html)] -> Writer Warnings [(FilePath, Html)])
-> [(FilePath, Html)] -> Writer Warnings [(FilePath, Html)]
forall a b. (a -> b) -> a -> b
$
[ (FilePath
"index.html", [FilePath] -> [(FilePath, Html)] -> Html
contentsPage [FilePath]
important_imports ([(FilePath, Html)] -> Html) -> [(FilePath, Html)] -> Html
forall a b. (a -> b) -> a -> b
$ ((FilePath, (Html, Html)) -> (FilePath, Html))
-> [(FilePath, (Html, Html))] -> [(FilePath, Html)]
forall a b. (a -> b) -> [a] -> [b]
map (((Html, Html) -> Html)
-> (FilePath, (Html, Html)) -> (FilePath, Html)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Html, Html) -> Html
forall a b. (a, b) -> b
snd) [(FilePath, (Html, Html))]
import_pages),
(FilePath
"doc-index.html", [FilePath]
-> Imports -> Documented -> Map VName (FilePath, Namespace) -> Html
indexPage [FilePath]
important_imports Imports
imports Documented
documented Map VName (FilePath, Namespace)
file_map)
]
[(FilePath, Html)] -> [(FilePath, Html)] -> [(FilePath, Html)]
forall a. [a] -> [a] -> [a]
++ ((FilePath, (Html, Html)) -> (FilePath, Html))
-> [(FilePath, (Html, Html))] -> [(FilePath, Html)]
forall a b. (a -> b) -> [a] -> [b]
map (FilePath -> FilePath
importHtml (FilePath -> FilePath)
-> ((Html, Html) -> Html)
-> (FilePath, (Html, Html))
-> (FilePath, Html)
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** (Html, Html) -> Html
forall a b. (a, b) -> a
fst) [(FilePath, (Html, Html))]
import_pages
where
file_map :: Map VName (FilePath, Namespace)
file_map = Imports -> Map VName (FilePath, Namespace)
vnameToFileMap Imports
imports
importHtml :: FilePath -> FilePath
importHtml FilePath
import_name = FilePath
"doc" FilePath -> FilePath -> FilePath
</> FilePath
import_name FilePath -> FilePath -> FilePath
<.> FilePath
"html"
headerDoc :: Prog -> DocM (Html, Html, Html)
Prog
prog =
case Prog -> Maybe DocComment
forall (f :: * -> *) vn. ProgBase f vn -> Maybe DocComment
progDoc Prog
prog of
Just (DocComment FilePath
doc SrcLoc
loc) -> do
let (FilePath
abstract, FilePath
more_sections) = FilePath -> (FilePath, FilePath)
splitHeaderDoc FilePath
doc
Html
first_paragraph <- Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml (Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ DocComment -> Maybe DocComment
forall a. a -> Maybe a
Just (DocComment -> Maybe DocComment) -> DocComment -> Maybe DocComment
forall a b. (a -> b) -> a -> b
$ FilePath -> SrcLoc -> DocComment
DocComment (FilePath -> FilePath
firstParagraph FilePath
abstract) SrcLoc
loc
Html
abstract' <- Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml (Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ DocComment -> Maybe DocComment
forall a. a -> Maybe a
Just (DocComment -> Maybe DocComment) -> DocComment -> Maybe DocComment
forall a b. (a -> b) -> a -> b
$ FilePath -> SrcLoc -> DocComment
DocComment FilePath
abstract SrcLoc
loc
Html
more_sections' <- Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml (Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ DocComment -> Maybe DocComment
forall a. a -> Maybe a
Just (DocComment -> Maybe DocComment) -> DocComment -> Maybe DocComment
forall a b. (a -> b) -> a -> b
$ FilePath -> SrcLoc -> DocComment
DocComment FilePath
more_sections SrcLoc
loc
(Html, Html, Html) -> DocM (Html, Html, Html)
forall (m :: * -> *) a. Monad m => a -> m a
return
( Html
first_paragraph,
AttributeValue -> Html -> Html
selfLink AttributeValue
"abstract" (Html -> Html
H.h2 Html
"Abstract") Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
abstract',
Html
more_sections'
)
Maybe DocComment
_ -> (Html, Html, Html) -> DocM (Html, Html, Html)
forall (m :: * -> *) a. Monad m => a -> m a
return (Html, Html, Html)
forall a. Monoid a => a
mempty
where
splitHeaderDoc :: FilePath -> (FilePath, FilePath)
splitHeaderDoc FilePath
s =
(FilePath, FilePath)
-> Maybe (FilePath, FilePath) -> (FilePath, FilePath)
forall a. a -> Maybe a -> a
fromMaybe (FilePath
s, FilePath
forall a. Monoid a => a
mempty) (Maybe (FilePath, FilePath) -> (FilePath, FilePath))
-> Maybe (FilePath, FilePath) -> (FilePath, FilePath)
forall a b. (a -> b) -> a -> b
$
((FilePath, FilePath) -> Bool)
-> [(FilePath, FilePath)] -> Maybe (FilePath, FilePath)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find ((FilePath
"\n##" FilePath -> FilePath -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isPrefixOf`) (FilePath -> Bool)
-> ((FilePath, FilePath) -> FilePath)
-> (FilePath, FilePath)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FilePath, FilePath) -> FilePath
forall a b. (a, b) -> b
snd) ([(FilePath, FilePath)] -> Maybe (FilePath, FilePath))
-> [(FilePath, FilePath)] -> Maybe (FilePath, FilePath)
forall a b. (a -> b) -> a -> b
$
[FilePath] -> [FilePath] -> [(FilePath, FilePath)]
forall a b. [a] -> [b] -> [(a, b)]
zip (FilePath -> [FilePath]
forall a. [a] -> [[a]]
inits FilePath
s) (FilePath -> [FilePath]
forall a. [a] -> [[a]]
tails FilePath
s)
firstParagraph :: FilePath -> FilePath
firstParagraph = [FilePath] -> FilePath
unlines ([FilePath] -> FilePath)
-> (FilePath -> [FilePath]) -> FilePath -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FilePath -> Bool) -> [FilePath] -> [FilePath]
forall a. (a -> Bool) -> [a] -> [a]
takeWhile (Bool -> Bool
not (Bool -> Bool) -> (FilePath -> Bool) -> FilePath -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Bool
paragraphSeparator) ([FilePath] -> [FilePath])
-> (FilePath -> [FilePath]) -> FilePath -> [FilePath]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> [FilePath]
lines
paragraphSeparator :: FilePath -> Bool
paragraphSeparator = (Char -> Bool) -> FilePath -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
isSpace
contentsPage :: [FilePath] -> [(String, Html)] -> Html
contentsPage :: [FilePath] -> [(FilePath, Html)] -> Html
contentsPage [FilePath]
important_imports [(FilePath, Html)]
pages =
Html -> Html
H.docTypeHtml (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
FilePath -> FilePath -> Html -> Html
addBoilerplate FilePath
"index.html" FilePath
"Futhark Library Documentation" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.main (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.h2 Html
"Main libraries"
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [(FilePath, Html)] -> Html
fileList [(FilePath, Html)]
important_pages
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> if [(FilePath, Html)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(FilePath, Html)]
unimportant_pages
then Html
forall a. Monoid a => a
mempty
else
Html -> Html
H.h2 Html
"Supporting libraries"
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [(FilePath, Html)] -> Html
fileList [(FilePath, Html)]
unimportant_pages
where
([(FilePath, Html)]
important_pages, [(FilePath, Html)]
unimportant_pages) =
((FilePath, Html) -> Bool)
-> [(FilePath, Html)] -> ([(FilePath, Html)], [(FilePath, Html)])
forall a. (a -> Bool) -> [a] -> ([a], [a])
partition ((FilePath -> [FilePath] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [FilePath]
important_imports) (FilePath -> Bool)
-> ((FilePath, Html) -> FilePath) -> (FilePath, Html) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FilePath, Html) -> FilePath
forall a b. (a, b) -> a
fst) [(FilePath, Html)]
pages
fileList :: [(FilePath, Html)] -> Html
fileList [(FilePath, Html)]
pages' =
Html -> Html
H.dl (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"file_list" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
[Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ ((FilePath, Html) -> Html) -> [(FilePath, Html)] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (FilePath, Html) -> Html
linkTo ([(FilePath, Html)] -> [Html]) -> [(FilePath, Html)] -> [Html]
forall a b. (a -> b) -> a -> b
$ ((FilePath, Html) -> FilePath)
-> [(FilePath, Html)] -> [(FilePath, Html)]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn (FilePath, Html) -> FilePath
forall a b. (a, b) -> a
fst [(FilePath, Html)]
pages'
linkTo :: (FilePath, Html) -> Html
linkTo (FilePath
name, Html
maybe_abstract) =
Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"file_desc" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.dt (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_header") (FilePath -> FilePath -> Html
importLink FilePath
"index.html" FilePath
name)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.dd (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_doc") Html
maybe_abstract
importLink :: FilePath -> String -> Html
importLink :: FilePath -> FilePath -> Html
importLink FilePath
current FilePath
name =
let file :: FilePath
file = FilePath -> FilePath -> FilePath
relativise (FilePath -> FilePath -> FilePath
makeRelative FilePath
"/" (FilePath -> FilePath) -> FilePath -> FilePath
forall a b. (a -> b) -> a -> b
$ FilePath
"doc" FilePath -> FilePath -> FilePath
</> FilePath
name FilePath -> FilePath -> FilePath
-<.> FilePath
"html") FilePath
current
in (Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString FilePath
file) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
forall a. IsString a => FilePath -> a
fromString FilePath
name)
indexPage :: [FilePath] -> Imports -> Documented -> FileMap -> Html
indexPage :: [FilePath]
-> Imports -> Documented -> Map VName (FilePath, Namespace) -> Html
indexPage [FilePath]
important_imports Imports
imports Documented
documented Map VName (FilePath, Namespace)
fm =
Html -> Html
H.docTypeHtml (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
[FilePath] -> Imports -> FilePath -> FilePath -> Html -> Html
addBoilerplateWithNav [FilePath]
important_imports Imports
imports FilePath
"doc-index.html" FilePath
"Index" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.main (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
( Html -> Html
H.ul (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"doc_index_list" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
[Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$
(FilePath -> Html) -> [FilePath] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map FilePath -> Html
initialListEntry ([FilePath] -> [Html]) -> [FilePath] -> [Html]
forall a b. (a -> b) -> a -> b
$
[FilePath]
letter_group_links [FilePath] -> [FilePath] -> [FilePath]
forall a. [a] -> [a] -> [a]
++ [FilePath
symbol_group_link]
)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> ( Html -> Html
H.table (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"doc_index" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.thead (Html -> Html
H.tr (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.td Html
"Who" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.td Html
"What" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.td Html
"Where")
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html]
letter_groups [Html] -> [Html] -> [Html]
forall a. [a] -> [a] -> [a]
++ [Html
symbol_group])
)
where
([(VName, (FilePath, IndexWhat))]
letter_names, [(VName, (FilePath, IndexWhat))]
sym_names) =
((VName, (FilePath, IndexWhat)) -> Bool)
-> [(VName, (FilePath, IndexWhat))]
-> ([(VName, (FilePath, IndexWhat))],
[(VName, (FilePath, IndexWhat))])
forall a. (a -> Bool) -> [a] -> ([a], [a])
partition (FilePath -> Bool
isLetterName (FilePath -> Bool)
-> ((VName, (FilePath, IndexWhat)) -> FilePath)
-> (VName, (FilePath, IndexWhat))
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VName -> FilePath
baseString (VName -> FilePath)
-> ((VName, (FilePath, IndexWhat)) -> VName)
-> (VName, (FilePath, IndexWhat))
-> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VName, (FilePath, IndexWhat)) -> VName
forall a b. (a, b) -> a
fst) ([(VName, (FilePath, IndexWhat))]
-> ([(VName, (FilePath, IndexWhat))],
[(VName, (FilePath, IndexWhat))]))
-> [(VName, (FilePath, IndexWhat))]
-> ([(VName, (FilePath, IndexWhat))],
[(VName, (FilePath, IndexWhat))])
forall a b. (a -> b) -> a -> b
$
((VName, (FilePath, IndexWhat)) -> FilePath)
-> [(VName, (FilePath, IndexWhat))]
-> [(VName, (FilePath, IndexWhat))]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn ((Char -> Char) -> FilePath -> FilePath
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper (FilePath -> FilePath)
-> ((VName, (FilePath, IndexWhat)) -> FilePath)
-> (VName, (FilePath, IndexWhat))
-> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VName -> FilePath
baseString (VName -> FilePath)
-> ((VName, (FilePath, IndexWhat)) -> VName)
-> (VName, (FilePath, IndexWhat))
-> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VName, (FilePath, IndexWhat)) -> VName
forall a b. (a, b) -> a
fst) ([(VName, (FilePath, IndexWhat))]
-> [(VName, (FilePath, IndexWhat))])
-> [(VName, (FilePath, IndexWhat))]
-> [(VName, (FilePath, IndexWhat))]
forall a b. (a -> b) -> a -> b
$
((VName, (FilePath, Namespace))
-> Maybe (VName, (FilePath, IndexWhat)))
-> [(VName, (FilePath, Namespace))]
-> [(VName, (FilePath, IndexWhat))]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (VName, (FilePath, Namespace))
-> Maybe (VName, (FilePath, IndexWhat))
forall {a} {b}. (VName, (a, b)) -> Maybe (VName, (a, IndexWhat))
isDocumented ([(VName, (FilePath, Namespace))]
-> [(VName, (FilePath, IndexWhat))])
-> [(VName, (FilePath, Namespace))]
-> [(VName, (FilePath, IndexWhat))]
forall a b. (a -> b) -> a -> b
$ Map VName (FilePath, Namespace) -> [(VName, (FilePath, Namespace))]
forall k a. Map k a -> [(k, a)]
M.toList Map VName (FilePath, Namespace)
fm
isDocumented :: (VName, (a, b)) -> Maybe (VName, (a, IndexWhat))
isDocumented (VName
k, (a
file, b
_)) = do
IndexWhat
what <- VName -> Documented -> Maybe IndexWhat
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup VName
k Documented
documented
(VName, (a, IndexWhat)) -> Maybe (VName, (a, IndexWhat))
forall a. a -> Maybe a
Just (VName
k, (a
file, IndexWhat
what))
([Html]
letter_groups, [FilePath]
letter_group_links) =
[(Html, FilePath)] -> ([Html], [FilePath])
forall a b. [(a, b)] -> ([a], [b])
unzip ([(Html, FilePath)] -> ([Html], [FilePath]))
-> [(Html, FilePath)] -> ([Html], [FilePath])
forall a b. (a -> b) -> a -> b
$ ([(VName, (FilePath, IndexWhat))] -> (Html, FilePath))
-> [[(VName, (FilePath, IndexWhat))]] -> [(Html, FilePath)]
forall a b. (a -> b) -> [a] -> [b]
map [(VName, (FilePath, IndexWhat))] -> (Html, FilePath)
tbodyForNames ([[(VName, (FilePath, IndexWhat))]] -> [(Html, FilePath)])
-> [[(VName, (FilePath, IndexWhat))]] -> [(Html, FilePath)]
forall a b. (a -> b) -> a -> b
$ ((VName, (FilePath, IndexWhat))
-> (VName, (FilePath, IndexWhat)) -> Bool)
-> [(VName, (FilePath, IndexWhat))]
-> [[(VName, (FilePath, IndexWhat))]]
forall a. (a -> a -> Bool) -> [a] -> [[a]]
groupBy (VName, (FilePath, IndexWhat))
-> (VName, (FilePath, IndexWhat)) -> Bool
forall {b} {b}. (VName, b) -> (VName, b) -> Bool
sameInitial [(VName, (FilePath, IndexWhat))]
letter_names
(Html
symbol_group, FilePath
symbol_group_link) =
FilePath -> [(VName, (FilePath, IndexWhat))] -> (Html, FilePath)
tbodyForInitial FilePath
"Symbols" [(VName, (FilePath, IndexWhat))]
sym_names
isLetterName :: FilePath -> Bool
isLetterName [] = Bool
False
isLetterName (Char
c : FilePath
_) = Char -> Bool
isAlpha Char
c
sameInitial :: (VName, b) -> (VName, b) -> Bool
sameInitial (VName
x, b
_) (VName
y, b
_) =
case (VName -> FilePath
baseString VName
x, VName -> FilePath
baseString VName
y) of
(Char
x' : FilePath
_, Char
y' : FilePath
_) -> Char -> Char
toUpper Char
x' Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char -> Char
toUpper Char
y'
(FilePath, FilePath)
_ -> Bool
False
tbodyForNames :: [(VName, (FilePath, IndexWhat))] -> (Html, FilePath)
tbodyForNames names :: [(VName, (FilePath, IndexWhat))]
names@((VName
s, (FilePath, IndexWhat)
_) : [(VName, (FilePath, IndexWhat))]
_) =
FilePath -> [(VName, (FilePath, IndexWhat))] -> (Html, FilePath)
tbodyForInitial ((Char -> Char) -> FilePath -> FilePath
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper (FilePath -> FilePath) -> FilePath -> FilePath
forall a b. (a -> b) -> a -> b
$ Int -> FilePath -> FilePath
forall a. Int -> [a] -> [a]
take Int
1 (FilePath -> FilePath) -> FilePath -> FilePath
forall a b. (a -> b) -> a -> b
$ VName -> FilePath
baseString VName
s) [(VName, (FilePath, IndexWhat))]
names
tbodyForNames [(VName, (FilePath, IndexWhat))]
_ = (Html, FilePath)
forall a. Monoid a => a
mempty
tbodyForInitial :: FilePath -> [(VName, (FilePath, IndexWhat))] -> (Html, FilePath)
tbodyForInitial FilePath
initial [(VName, (FilePath, IndexWhat))]
names =
( Html -> Html
H.tbody (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ Html
initial' Html -> [Html] -> [Html]
forall a. a -> [a] -> [a]
: ((VName, (FilePath, IndexWhat)) -> Html)
-> [(VName, (FilePath, IndexWhat))] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (VName, (FilePath, IndexWhat)) -> Html
linkTo [(VName, (FilePath, IndexWhat))]
names,
FilePath
initial
)
where
initial' :: Html
initial' =
Html -> Html
H.tr (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.colspan AttributeValue
"2" (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"doc_index_initial" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString FilePath
initial)
(Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (FilePath -> AttributeValue) -> FilePath -> AttributeValue
forall a b. (a -> b) -> a -> b
$ Char
'#' Char -> FilePath -> FilePath
forall a. a -> [a] -> [a]
: FilePath
initial)
(Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
forall a. IsString a => FilePath -> a
fromString FilePath
initial
initialListEntry :: FilePath -> Html
initialListEntry FilePath
initial =
Html -> Html
H.li (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (FilePath -> AttributeValue) -> FilePath -> AttributeValue
forall a b. (a -> b) -> a -> b
$ Char
'#' Char -> FilePath -> FilePath
forall a. a -> [a] -> [a]
: FilePath
initial) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
forall a. IsString a => FilePath -> a
fromString FilePath
initial
linkTo :: (VName, (FilePath, IndexWhat)) -> Html
linkTo (VName
name, (FilePath
file, IndexWhat
what)) =
let link :: Html
link =
(Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (FilePath -> FilePath -> FilePath
makeRelative FilePath
"/" (FilePath -> FilePath) -> FilePath -> FilePath
forall a b. (a -> b) -> a -> b
$ FilePath
"doc" FilePath -> FilePath -> FilePath
</> VName -> FilePath -> FilePath -> FilePath
vnameLink' VName
name FilePath
"" FilePath
file))) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
FilePath -> Html
forall a. IsString a => FilePath -> a
fromString (FilePath -> Html) -> FilePath -> Html
forall a b. (a -> b) -> a -> b
$ VName -> FilePath
baseString VName
name
what' :: Html
what' = case IndexWhat
what of
IndexWhat
IndexValue -> Html
"value"
IndexWhat
IxFun -> Html
"function"
IndexWhat
IndexType -> Html
"type"
IndexWhat
IndexModuleType -> Html
"module type"
IndexWhat
IndexModule -> Html
"module"
html_file :: FilePath
html_file = FilePath -> FilePath -> FilePath
makeRelative FilePath
"/" (FilePath -> FilePath) -> FilePath -> FilePath
forall a b. (a -> b) -> a -> b
$ FilePath
"doc" FilePath -> FilePath -> FilePath
</> FilePath
file FilePath -> FilePath -> FilePath
-<.> FilePath
"html"
in Html -> Html
H.tr (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"doc_index_name" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
link)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"doc_index_namespace" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
what')
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> ( Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"doc_index_file" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString FilePath
html_file) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
forall a. IsString a => FilePath -> a
fromString FilePath
file)
)
addBoilerplate :: String -> String -> Html -> Html
addBoilerplate :: FilePath -> FilePath -> Html -> Html
addBoilerplate FilePath
current FilePath
titleText Html
content =
let headHtml :: Html
headHtml =
Html -> Html
H.head (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html
H.meta
Html -> Attribute -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.charset AttributeValue
"utf-8"
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.title (FilePath -> Html
forall a. IsString a => FilePath -> a
fromString FilePath
titleText)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
H.link
Html -> Attribute -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (FilePath -> AttributeValue) -> FilePath -> AttributeValue
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> FilePath
relativise FilePath
"style.css" FilePath
current)
Html -> Attribute -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.rel AttributeValue
"stylesheet"
Html -> Attribute -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.type_ AttributeValue
"text/css"
navigation :: Html
navigation =
Html -> Html
H.ul (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"navigation" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.li (Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (FilePath -> AttributeValue) -> FilePath -> AttributeValue
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> FilePath
relativise FilePath
"index.html" FilePath
current) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
"Contents")
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.li (Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (FilePath -> AttributeValue) -> FilePath -> AttributeValue
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> FilePath
relativise FilePath
"doc-index.html" FilePath
current) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
"Index")
madeByHtml :: Html
madeByHtml =
Html
"Generated by " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href AttributeValue
futhark_doc_url) Html
"futhark-doc"
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> FilePath -> Html
forall a. IsString a => FilePath -> a
fromString (Version -> FilePath
showVersion Version
version)
in Html
headHtml
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.body
( (Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"header") (Html -> Html
H.h1 (FilePath -> Html
forall a. ToMarkup a => a -> Html
toHtml FilePath
titleText) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
navigation)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"content") Html
content
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"footer") Html
madeByHtml
)
where
futhark_doc_url :: AttributeValue
futhark_doc_url =
AttributeValue
"https://futhark.readthedocs.io/en/latest/man/futhark-doc.html"
addBoilerplateWithNav :: [FilePath] -> Imports -> String -> String -> Html -> Html
addBoilerplateWithNav :: [FilePath] -> Imports -> FilePath -> FilePath -> Html -> Html
addBoilerplateWithNav [FilePath]
important_imports Imports
imports FilePath
current FilePath
titleText Html
content =
FilePath -> FilePath -> Html -> Html
addBoilerplate FilePath
current FilePath
titleText (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.nav (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"filenav" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
files) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
content
where
files :: Html
files = Html -> Html
H.ul (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ (FilePath -> Html) -> [FilePath] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map FilePath -> Html
pp ([FilePath] -> [Html]) -> [FilePath] -> [Html]
forall a b. (a -> b) -> a -> b
$ [FilePath] -> [FilePath]
forall a. Ord a => [a] -> [a]
sort ([FilePath] -> [FilePath]) -> [FilePath] -> [FilePath]
forall a b. (a -> b) -> a -> b
$ (FilePath -> Bool) -> [FilePath] -> [FilePath]
forall a. (a -> Bool) -> [a] -> [a]
filter FilePath -> Bool
visible [FilePath]
important_imports
pp :: FilePath -> Html
pp FilePath
name = Html -> Html
H.li (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> Html
importLink FilePath
current FilePath
name
visible :: FilePath -> Bool
visible = (FilePath -> [FilePath] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` ((FilePath, FileModule) -> FilePath) -> Imports -> [FilePath]
forall a b. (a -> b) -> [a] -> [b]
map (FilePath, FileModule) -> FilePath
forall a b. (a, b) -> a
fst Imports
imports)
synopsisDecs :: [Dec] -> DocM Html
synopsisDecs :: [Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisDecs [Dec]
decs = do
NoLink
visible <- (Context -> NoLink)
-> ReaderT Context (WriterT Documented (Writer Warnings)) NoLink
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> NoLink
ctxVisibleMTys
FileModule
fm <- (Context -> FileModule)
-> ReaderT
Context (WriterT Documented (Writer Warnings)) FileModule
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> FileModule
ctxFileMod
(Html -> Html
H.table (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"specs") (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Html
emptyRow Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat
([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ReaderT Context (WriterT Documented (Writer Warnings)) Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence ((Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> [Dec]
-> [ReaderT Context (WriterT Documented (Writer Warnings)) Html]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (NoLink
-> FileModule
-> Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisDec NoLink
visible FileModule
fm) [Dec]
decs)
synopsisDec :: S.Set VName -> FileModule -> Dec -> Maybe (DocM Html)
synopsisDec :: NoLink
-> FileModule
-> Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisDec NoLink
visible FileModule
fm Dec
dec = case Dec
dec of
SigDec SigBindBase Info VName
s -> Html
-> SigBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisModType Html
forall a. Monoid a => a
mempty SigBindBase Info VName
s
ModDec ModBindBase Info VName
m -> FileModule
-> ModBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisMod FileModule
fm ModBindBase Info VName
m
ValDec ValBindBase Info VName
v -> ValBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisValBind ValBindBase Info VName
v
TypeDec TypeBindBase Info VName
t -> TypeBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisType TypeBindBase Info VName
t
OpenDec ModExpBase Info VName
x SrcLoc
_
| Just ReaderT Context (WriterT Documented (Writer Warnings)) Html
opened <- ModExpBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisOpened ModExpBase Info VName
x -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
Html
opened' <- ReaderT Context (WriterT Documented (Writer Warnings)) Html
opened
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
fullRow (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
keyword FilePath
"open " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
opened'
| Bool
otherwise ->
ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
fullRow (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
FilePath -> Html
keyword FilePath
"open" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> FilePath -> Html
forall a. IsString a => FilePath -> a
fromString (FilePath
" <" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> ModExpBase Info VName -> FilePath
forall a. Pretty a => a -> FilePath
pretty ModExpBase Info VName
x FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
">")
LocalDec (SigDec SigBindBase Info VName
s) SrcLoc
_
| SigBindBase Info VName -> VName
forall (f :: * -> *) vn. SigBindBase f vn -> vn
sigName SigBindBase Info VName
s VName -> NoLink -> Bool
forall a. Ord a => a -> Set a -> Bool
`S.member` NoLink
visible ->
Html
-> SigBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisModType (FilePath -> Html
keyword FilePath
"local" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" ") SigBindBase Info VName
s
LocalDec {} -> Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
ImportDec {} -> Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
synopsisOpened :: ModExp -> Maybe (DocM Html)
synopsisOpened :: ModExpBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisOpened (ModVar QualName VName
qn SrcLoc
_) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
qn
synopsisOpened (ModParens ModExpBase Info VName
me SrcLoc
_) = do
ReaderT Context (WriterT Documented (Writer Warnings)) Html
me' <- ModExpBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisOpened ModExpBase Info VName
me
ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ Html -> Html
parens (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReaderT Context (WriterT Documented (Writer Warnings)) Html
me'
synopsisOpened (ModImport FilePath
_ (Info FilePath
file) SrcLoc
_) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
FilePath
current <- (Context -> FilePath)
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> FilePath
ctxCurrent
let dest :: AttributeValue
dest = FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (FilePath -> AttributeValue) -> FilePath -> AttributeValue
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> FilePath
relativise FilePath
file FilePath
current FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
".html"
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
keyword FilePath
"import " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href AttributeValue
dest) (FilePath -> Html
forall a. IsString a => FilePath -> a
fromString (FilePath -> Html) -> FilePath -> Html
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath
forall a. Show a => a -> FilePath
show FilePath
file)
synopsisOpened (ModAscript ModExpBase Info VName
_ SigExpBase Info VName
se Info (Map VName VName)
_ SrcLoc
_) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
Html
se' <- SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
se
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
"... : " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
se'
synopsisOpened ModExpBase Info VName
_ = Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
synopsisValBind :: ValBind -> Maybe (DocM Html)
synopsisValBind :: ValBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisValBind ValBindBase Info VName
vb = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
let name' :: Html
name' = VName -> Html
vnameSynopsisDef (VName -> Html) -> VName -> Html
forall a b. (a -> b) -> a -> b
$ ValBindBase Info VName -> VName
forall (f :: * -> *) vn. ValBindBase f vn -> vn
valBindName ValBindBase Info VName
vb
(Html
lhs, Html
mhs, Html
rhs) <- Html -> ValBindBase Info VName -> DocM (Html, Html, Html)
valBindHtml Html
name' ValBindBase Info VName
vb
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html -> Html -> Html
specRow Html
lhs (Html
mhs Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" : ") Html
rhs
valBindHtml :: Html -> ValBind -> DocM (Html, Html, Html)
valBindHtml :: Html -> ValBindBase Info VName -> DocM (Html, Html, Html)
valBindHtml Html
name (ValBind Maybe (Info EntryPoint)
_ VName
_ Maybe (TypeExp VName)
retdecl (Info (StructType
rettype, [VName]
_)) [TypeParamBase VName]
tparams [PatternBase Info VName]
params ExpBase Info VName
_ Maybe DocComment
_ [AttrInfo]
_ SrcLoc
_) = do
let tparams' :: Html
tparams' = [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ (TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ((Html
" " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) (Html -> Html)
-> (TypeParamBase VName -> Html) -> TypeParamBase VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeParamBase VName -> Html
typeParamHtml) [TypeParamBase VName]
tparams
noLink' :: DocM a -> DocM a
noLink' =
[VName] -> DocM a -> DocM a
forall a. [VName] -> DocM a -> DocM a
noLink ([VName] -> DocM a -> DocM a) -> [VName] -> DocM a -> DocM a
forall a b. (a -> b) -> a -> b
$
(TypeParamBase VName -> VName) -> [TypeParamBase VName] -> [VName]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> VName
forall vn. TypeParamBase vn -> vn
typeParamName [TypeParamBase VName]
tparams
[VName] -> [VName] -> [VName]
forall a. [a] -> [a] -> [a]
++ (IdentBase Info VName -> VName)
-> [IdentBase Info VName] -> [VName]
forall a b. (a -> b) -> [a] -> [b]
map IdentBase Info VName -> VName
forall (f :: * -> *) vn. IdentBase f vn -> vn
identName (Set (IdentBase Info VName) -> [IdentBase Info VName]
forall a. Set a -> [a]
S.toList (Set (IdentBase Info VName) -> [IdentBase Info VName])
-> Set (IdentBase Info VName) -> [IdentBase Info VName]
forall a b. (a -> b) -> a -> b
$ [Set (IdentBase Info VName)] -> Set (IdentBase Info VName)
forall a. Monoid a => [a] -> a
mconcat ([Set (IdentBase Info VName)] -> Set (IdentBase Info VName))
-> [Set (IdentBase Info VName)] -> Set (IdentBase Info VName)
forall a b. (a -> b) -> a -> b
$ (PatternBase Info VName -> Set (IdentBase Info VName))
-> [PatternBase Info VName] -> [Set (IdentBase Info VName)]
forall a b. (a -> b) -> [a] -> [b]
map PatternBase Info VName -> Set (IdentBase Info VName)
forall (f :: * -> *) vn.
(Functor f, Ord vn) =>
PatternBase f vn -> Set (IdentBase f vn)
patternIdents [PatternBase Info VName]
params)
Html
rettype' <- ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall {a}. DocM a -> DocM a
noLink' (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> (TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Maybe (TypeExp VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml StructType
rettype) TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml Maybe (TypeExp VName)
retdecl
[Html]
params' <- ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall {a}. DocM a -> DocM a
noLink' (ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall a b. (a -> b) -> a -> b
$ (PatternBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [PatternBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM PatternBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
patternHtml [PatternBase Info VName]
params
(Html, Html, Html) -> DocM (Html, Html, Html)
forall (m :: * -> *) a. Monad m => a -> m a
return
( FilePath -> Html
keyword FilePath
"val " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"decl_name") Html
name,
Html
tparams',
[Html] -> Html
forall a. Monoid a => [a] -> a
mconcat (Html -> [Html] -> [Html]
forall a. a -> [a] -> [a]
intersperse Html
" -> " ([Html] -> [Html]) -> [Html] -> [Html]
forall a b. (a -> b) -> a -> b
$ [Html]
params' [Html] -> [Html] -> [Html]
forall a. [a] -> [a] -> [a]
++ [Html
rettype'])
)
synopsisModType :: Html -> SigBind -> Maybe (DocM Html)
synopsisModType :: Html
-> SigBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisModType Html
prefix SigBindBase Info VName
sb = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
let name' :: Html
name' = VName -> Html
vnameSynopsisDef (VName -> Html) -> VName -> Html
forall a b. (a -> b) -> a -> b
$ SigBindBase Info VName -> VName
forall (f :: * -> *) vn. SigBindBase f vn -> vn
sigName SigBindBase Info VName
sb
Html -> Html
fullRow (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> do
Html
se' <- SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp (SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ SigBindBase Info VName -> SigExpBase Info VName
forall (f :: * -> *) vn. SigBindBase f vn -> SigExpBase f vn
sigExp SigBindBase Info VName
sb
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
prefix Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> FilePath -> Html
keyword FilePath
"module type " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" = " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
se'
synopsisMod :: FileModule -> ModBind -> Maybe (DocM Html)
synopsisMod :: FileModule
-> ModBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisMod FileModule
fm (ModBind VName
name [ModParamBase Info VName]
ps Maybe (SigExpBase Info VName, Info (Map VName VName))
sig ModExpBase Info VName
_ Maybe DocComment
_ SrcLoc
_) =
case Maybe (SigExpBase Info VName, Info (Map VName VName))
sig of
Maybe (SigExpBase Info VName, Info (Map VName VName))
Nothing -> (Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
proceed (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Mod
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Mod
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Mod -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
envSig) (Mod
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Maybe Mod
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> VName -> Map VName Mod -> Maybe Mod
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup VName
name Map VName Mod
modtable
Just (SigExpBase Info VName
s, Info (Map VName VName)
_) -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
proceed (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
s
where
proceed :: Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
proceed Html
sig' = do
let name' :: Html
name' = VName -> Html
vnameSynopsisDef VName
name
Html
ps' <- [ModParamBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
modParamHtml [ModParamBase Info VName]
ps
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html -> Html -> Html
specRow (FilePath -> Html
keyword FilePath
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name') Html
": " (Html
ps' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
sig')
FileModule TySet
_abs Env {envModTable :: Env -> Map VName Mod
envModTable = Map VName Mod
modtable} Prog
_ = FileModule
fm
envSig :: Mod -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
envSig (ModEnv Env
e) = Env -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderEnv Env
e
envSig (ModFun (FunSig TySet
_ Mod
_ (MTy TySet
_ Mod
m))) = Mod -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
envSig Mod
m
synopsisType :: TypeBind -> Maybe (DocM Html)
synopsisType :: TypeBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisType TypeBindBase Info VName
tb = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
let name' :: Html
name' = VName -> Html
vnameSynopsisDef (VName -> Html) -> VName -> Html
forall a b. (a -> b) -> a -> b
$ TypeBindBase Info VName -> VName
forall (f :: * -> *) vn. TypeBindBase f vn -> vn
typeAlias TypeBindBase Info VName
tb
Html -> Html
fullRow (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Html
-> TypeBindBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeBindHtml Html
name' TypeBindBase Info VName
tb
typeBindHtml :: Html -> TypeBind -> DocM Html
typeBindHtml :: Html
-> TypeBindBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeBindHtml Html
name' (TypeBind VName
_ Liftedness
l [TypeParamBase VName]
tparams TypeDeclBase Info VName
t Maybe DocComment
_ SrcLoc
_) = do
Html
t' <- [VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a. [VName] -> DocM a -> DocM a
noLink ((TypeParamBase VName -> VName) -> [TypeParamBase VName] -> [VName]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> VName
forall vn. TypeParamBase vn -> vn
typeParamName [TypeParamBase VName]
tparams) (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ TypeDeclBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *).
TypeDeclBase f VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeDeclHtml TypeDeclBase Info VName
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Liftedness -> Html -> [TypeParamBase VName] -> Html
typeAbbrevHtml Liftedness
l Html
name' [TypeParamBase VName]
tparams Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" = " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
renderEnv :: Env -> DocM Html
renderEnv :: Env -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderEnv (Env Map VName BoundV
vtable Map VName TypeBinding
ttable Map VName MTy
sigtable Map VName Mod
modtable Map (Namespace, Name) (QualName VName)
_) = do
[Html]
typeBinds <- ((VName, TypeBinding)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(VName, TypeBinding)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (VName, TypeBinding)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderTypeBind (Map VName TypeBinding -> [(VName, TypeBinding)]
forall k a. Map k a -> [(k, a)]
M.toList Map VName TypeBinding
ttable)
[Html]
valBinds <- ((VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(VName, BoundV)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderValBind (Map VName BoundV -> [(VName, BoundV)]
forall k a. Map k a -> [(k, a)]
M.toList Map VName BoundV
vtable)
[Html]
sigBinds <- ((VName, MTy)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(VName, MTy)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (VName, MTy)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderModType (Map VName MTy -> [(VName, MTy)]
forall k a. Map k a -> [(k, a)]
M.toList Map VName MTy
sigtable)
[Html]
modBinds <- ((VName, Mod)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(VName, Mod)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (VName, Mod)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderMod (Map VName Mod -> [(VName, Mod)]
forall k a. Map k a -> [(k, a)]
M.toList Map VName Mod
modtable)
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
braces (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ [Html]
typeBinds [Html] -> [Html] -> [Html]
forall a. [a] -> [a] -> [a]
++ [Html]
valBinds [Html] -> [Html] -> [Html]
forall a. [a] -> [a] -> [a]
++ [Html]
sigBinds [Html] -> [Html] -> [Html]
forall a. [a] -> [a] -> [a]
++ [Html]
modBinds
renderModType :: (VName, MTy) -> DocM Html
renderModType :: (VName, MTy)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderModType (VName
name, MTy
_sig) =
(FilePath -> Html
keyword FilePath
"module type " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml (VName -> QualName VName
forall v. v -> QualName v
qualName VName
name)
renderMod :: (VName, Mod) -> DocM Html
renderMod :: (VName, Mod)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderMod (VName
name, Mod
_mod) =
(FilePath -> Html
keyword FilePath
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml (VName -> QualName VName
forall v. v -> QualName v
qualName VName
name)
renderValBind :: (VName, BoundV) -> DocM Html
renderValBind :: (VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderValBind = (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Html -> Html
H.div (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ((VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisValBindBind
renderTypeBind :: (VName, TypeBinding) -> DocM Html
renderTypeBind :: (VName, TypeBinding)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderTypeBind (VName
name, TypeAbbr Liftedness
l [TypeParamBase VName]
tps StructType
tp) = do
Html
tp' <- StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml StructType
tp
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.div (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Liftedness -> Html -> [TypeParamBase VName] -> Html
typeAbbrevHtml Liftedness
l (VName -> Html
vnameHtml VName
name) [TypeParamBase VName]
tps Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" = " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
tp'
synopsisValBindBind :: (VName, BoundV) -> DocM Html
synopsisValBindBind :: (VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisValBindBind (VName
name, BoundV [TypeParamBase VName]
tps StructType
t) = do
let tps' :: [Html]
tps' = (TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> Html
typeParamHtml [TypeParamBase VName]
tps
Html
t' <- StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml StructType
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
FilePath -> Html
keyword FilePath
"val " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameHtml VName
name
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((Html -> Html) -> [Html] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (Html
" " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) [Html]
tps')
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
typeHtml :: StructType -> DocM Html
typeHtml :: StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml StructType
t = case StructType
t of
Array ()
_ Uniqueness
u ScalarTypeBase (DimDecl VName) ()
et ShapeDecl (DimDecl VName)
shape -> do
Html
shape' <- ShapeDecl (DimDecl VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
prettyShapeDecl ShapeDecl (DimDecl VName)
shape
Html
et' <- StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml (StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ ScalarTypeBase (DimDecl VName) () -> StructType
forall dim as. ScalarTypeBase dim as -> TypeBase dim as
Scalar ScalarTypeBase (DimDecl VName) ()
et
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Uniqueness -> Html
prettyU Uniqueness
u Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
shape' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
et'
Scalar (Prim PrimType
et) -> Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ PrimType -> Html
primTypeHtml PrimType
et
Scalar (Record Map Name StructType
fs)
| Just [StructType]
ts <- Map Name StructType -> Maybe [StructType]
forall a. Map Name a -> Maybe [a]
areTupleFields Map Name StructType
fs ->
Html -> Html
parens (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
commas ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [StructType]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml [StructType]
ts
| Bool
otherwise ->
Html -> Html
braces (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
commas ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, StructType)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(Name, StructType)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Name, StructType)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppField (Map Name StructType -> [(Name, StructType)]
forall k a. Map k a -> [(k, a)]
M.toList Map Name StructType
fs)
where
ppField :: (Name, StructType)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppField (Name
name, StructType
tp) = do
Html
tp' <- StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml StructType
tp
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
forall a. ToMarkup a => a -> Html
toHtml (Name -> FilePath
nameToString Name
name) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
tp'
Scalar (TypeVar ()
_ Uniqueness
u TypeName
et [TypeArg (DimDecl VName)]
targs) -> do
[Html]
targs' <- (TypeArg (DimDecl VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [TypeArg (DimDecl VName)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TypeArg (DimDecl VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeArgHtml [TypeArg (DimDecl VName)]
targs
Html
et' <- TypeName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeNameHtml TypeName
et
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Uniqueness -> Html
prettyU Uniqueness
u Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
et' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((Html -> Html) -> [Html] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (Html
" " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) [Html]
targs')
Scalar (Arrow ()
_ PName
pname StructType
t1 StructType
t2) -> do
Html
t1' <- StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml StructType
t1
Html
t2' <- StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml StructType
t2
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ case PName
pname of
Named VName
v ->
Html -> Html
parens (VName -> Html
vnameHtml VName
v Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t1') Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" -> " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t2'
PName
Unnamed ->
Html
t1' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" -> " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t2'
Scalar (Sum Map Name [StructType]
cs) -> [Html] -> Html
pipes ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, [StructType])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(Name, [StructType])]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Name, [StructType])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppClause (Map Name [StructType] -> [(Name, [StructType])]
forall a. Map Name a -> [(Name, a)]
sortConstrs Map Name [StructType]
cs)
where
ppClause :: (Name, [StructType])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppClause (Name
n, [StructType]
ts) = Html -> [Html] -> Html
joinBy Html
" " ([Html] -> Html) -> ([Html] -> [Html]) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Html
ppConstr Name
n Html -> [Html] -> [Html]
forall a. a -> [a] -> [a]
:) ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [StructType]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml [StructType]
ts
ppConstr :: Name -> Html
ppConstr Name
name = Html
"#" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> FilePath -> Html
forall a. ToMarkup a => a -> Html
toHtml (Name -> FilePath
nameToString Name
name)
prettyShapeDecl :: ShapeDecl (DimDecl VName) -> DocM Html
prettyShapeDecl :: ShapeDecl (DimDecl VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
prettyShapeDecl (ShapeDecl [DimDecl VName]
ds) =
[Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (DimDecl VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [DimDecl VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Html -> Html
brackets (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (DimDecl VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> DimDecl VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DimDecl VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimDeclHtml) [DimDecl VName]
ds
typeArgHtml :: TypeArg (DimDecl VName) -> DocM Html
typeArgHtml :: TypeArg (DimDecl VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeArgHtml (TypeArgDim DimDecl VName
d SrcLoc
_) = Html -> Html
brackets (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DimDecl VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimDeclHtml DimDecl VName
d
typeArgHtml (TypeArgType StructType
t SrcLoc
_) = StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml StructType
t
modParamHtml :: [ModParamBase Info VName] -> DocM Html
modParamHtml :: [ModParamBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
modParamHtml [] = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return Html
forall a. Monoid a => a
mempty
modParamHtml (ModParam VName
pname SigExpBase Info VName
psig Info [VName]
_ SrcLoc
_ : [ModParamBase Info VName]
mps) =
(Html -> Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Html -> Html -> Html
f (SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
psig) ([ModParamBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
modParamHtml [ModParamBase Info VName]
mps)
where
f :: Html -> Html -> Html
f Html
se Html
params =
Html
"(" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameHtml VName
pname
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
se
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
") -> "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
params
synopsisSigExp :: SigExpBase Info VName -> DocM Html
synopsisSigExp :: SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
e = case SigExpBase Info VName
e of
SigVar QualName VName
v Info (Map VName VName)
_ SrcLoc
_ -> QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
v
SigParens SigExpBase Info VName
e' SrcLoc
_ -> Html -> Html
parens (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
e'
SigSpecs [SpecBase Info VName]
ss SrcLoc
_ -> Html -> Html
braces (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Html -> Html
H.table (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"specs") (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [SpecBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSpec [SpecBase Info VName]
ss
SigWith SigExpBase Info VName
s (TypeRef QualName VName
v [TypeParamBase VName]
ps TypeDeclBase Info VName
t SrcLoc
_) SrcLoc
_ -> do
Html
s' <- SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
s
Html
t' <- TypeDeclBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *).
TypeDeclBase f VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeDeclHtml TypeDeclBase Info VName
t
Html
v' <- QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
v
let ps' :: Html
ps' = [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ (TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ((Html
" " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) (Html -> Html)
-> (TypeParamBase VName -> Html) -> TypeParamBase VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeParamBase VName -> Html
typeParamHtml) [TypeParamBase VName]
ps
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
s' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> FilePath -> Html
keyword FilePath
" with " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
v' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
ps' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" = " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
SigArrow Maybe VName
Nothing SigExpBase Info VName
e1 SigExpBase Info VName
e2 SrcLoc
_ ->
(Html -> Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Html -> Html -> Html
forall {a}. (Semigroup a, IsString a) => a -> a -> a
f (SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
e1) (SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
e2)
where
f :: a -> a -> a
f a
e1' a
e2' = a
e1' a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
" -> " a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
e2'
SigArrow (Just VName
v) SigExpBase Info VName
e1 SigExpBase Info VName
e2 SrcLoc
_ ->
do
let name :: Html
name = VName -> Html
vnameHtml VName
v
Html
e1' <- SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
e1
Html
e2' <- [VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a. [VName] -> DocM a -> DocM a
noLink [VName
v] (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
e2
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
"(" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
e1' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
") -> " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
e2'
keyword :: String -> Html
keyword :: FilePath -> Html
keyword = (Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"keyword") (Html -> Html) -> (FilePath -> Html) -> FilePath -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Html
forall a. IsString a => FilePath -> a
fromString
vnameHtml :: VName -> Html
vnameHtml :: VName -> Html
vnameHtml (VName Name
name Int
tag) =
Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (Int -> FilePath
forall a. Show a => a -> FilePath
show Int
tag)) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Name -> Html
renderName Name
name
vnameDescDef :: VName -> IndexWhat -> DocM Html
vnameDescDef :: VName
-> IndexWhat
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
vnameDescDef VName
v IndexWhat
what = do
VName -> IndexWhat -> DocM ()
document VName
v IndexWhat
what
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (Int -> FilePath
forall a. Show a => a -> FilePath
show (VName -> Int
baseTag VName
v))) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Name -> Html
renderName (VName -> Name
baseName VName
v)
vnameSynopsisDef :: VName -> Html
vnameSynopsisDef :: VName -> Html
vnameSynopsisDef (VName Name
name Int
tag) =
Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (Int -> FilePath
forall a. Show a => a -> FilePath
show Int
tag FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
"s")) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (FilePath
"#" FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ Int -> FilePath
forall a. Show a => a -> FilePath
show Int
tag)) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Name -> Html
renderName Name
name
vnameSynopsisRef :: VName -> Html
vnameSynopsisRef :: VName -> Html
vnameSynopsisRef VName
v =
Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"synopsis_link"
(Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString (FilePath
"#" FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ Int -> FilePath
forall a. Show a => a -> FilePath
show (VName -> Int
baseTag VName
v) FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
"s"))
(Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
"↑"
synopsisSpec :: SpecBase Info VName -> DocM Html
synopsisSpec :: SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSpec SpecBase Info VName
spec = case SpecBase Info VName
spec of
TypeAbbrSpec TypeBindBase Info VName
tpsig ->
Html -> Html
fullRow (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Html
-> TypeBindBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeBindHtml (VName -> Html
vnameSynopsisDef (VName -> Html) -> VName -> Html
forall a b. (a -> b) -> a -> b
$ TypeBindBase Info VName -> VName
forall (f :: * -> *) vn. TypeBindBase f vn -> vn
typeAlias TypeBindBase Info VName
tpsig) TypeBindBase Info VName
tpsig
TypeSpec Liftedness
l VName
name [TypeParamBase VName]
ps Maybe DocComment
_ SrcLoc
_ ->
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
fullRow (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
keyword FilePath
l' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameSynopsisDef VName
name Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ((Html
" " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) (Html -> Html)
-> (TypeParamBase VName -> Html) -> TypeParamBase VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeParamBase VName -> Html
typeParamHtml) [TypeParamBase VName]
ps)
where
l' :: FilePath
l' = case Liftedness
l of
Liftedness
Unlifted -> FilePath
"type "
Liftedness
SizeLifted -> FilePath
"type~ "
Liftedness
Lifted -> FilePath
"type^ "
ValSpec VName
name [TypeParamBase VName]
tparams TypeDeclBase Info VName
rettype Maybe DocComment
_ SrcLoc
_ -> do
let tparams' :: [Html]
tparams' = (TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> Html
typeParamHtml [TypeParamBase VName]
tparams
Html
rettype' <-
[VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a. [VName] -> DocM a -> DocM a
noLink ((TypeParamBase VName -> VName) -> [TypeParamBase VName] -> [VName]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> VName
forall vn. TypeParamBase vn -> vn
typeParamName [TypeParamBase VName]
tparams) (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
TypeDeclBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *).
TypeDeclBase f VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeDeclHtml TypeDeclBase Info VName
rettype
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
Html -> Html -> Html -> Html
specRow
(FilePath -> Html
keyword FilePath
"val " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameSynopsisDef VName
name)
([Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((Html -> Html) -> [Html] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (Html
" " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) [Html]
tparams') Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": ")
Html
rettype'
ModSpec VName
name SigExpBase Info VName
sig Maybe DocComment
_ SrcLoc
_ ->
Html -> Html -> Html -> Html
specRow (FilePath -> Html
keyword FilePath
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameSynopsisDef VName
name) Html
": " (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
sig
IncludeSpec SigExpBase Info VName
e SrcLoc
_ -> Html -> Html
fullRow (Html -> Html) -> (Html -> Html) -> Html -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FilePath -> Html
keyword FilePath
"include " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
e
typeDeclHtml :: TypeDeclBase f VName -> DocM Html
typeDeclHtml :: forall (f :: * -> *).
TypeDeclBase f VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeDeclHtml = TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml (TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (TypeDeclBase f VName -> TypeExp VName)
-> TypeDeclBase f VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeDeclBase f VName -> TypeExp VName
forall (f :: * -> *) vn. TypeDeclBase f vn -> TypeExp vn
declaredType
typeExpHtml :: TypeExp VName -> DocM Html
typeExpHtml :: TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp VName
e = case TypeExp VName
e of
TEUnique TypeExp VName
t SrcLoc
_ -> (Html
"*" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp VName
t
TEArray TypeExp VName
at DimExp VName
d SrcLoc
_ -> do
Html
at' <- TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp VName
at
Html
d' <- DimExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimExpHtml DimExp VName
d
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
brackets Html
d' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
at'
TETuple [TypeExp VName]
ts SrcLoc
_ -> Html -> Html
parens (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
commas ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [TypeExp VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml [TypeExp VName]
ts
TERecord [(Name, TypeExp VName)]
fs SrcLoc
_ -> Html -> Html
braces (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
commas ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, TypeExp VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(Name, TypeExp VName)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Name, TypeExp VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppField [(Name, TypeExp VName)]
fs
where
ppField :: (Name, TypeExp VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppField (Name
name, TypeExp VName
t) = do
Html
t' <- TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp VName
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
forall a. ToMarkup a => a -> Html
toHtml (Name -> FilePath
nameToString Name
name) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
TEVar QualName VName
name SrcLoc
_ -> QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
name
TEApply TypeExp VName
t TypeArgExp VName
arg SrcLoc
_ -> do
Html
t' <- TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp VName
t
Html
arg' <- TypeArgExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeArgExpHtml TypeArgExp VName
arg
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
t' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
arg'
TEArrow Maybe VName
pname TypeExp VName
t1 TypeExp VName
t2 SrcLoc
_ -> do
Html
t1' <- case TypeExp VName
t1 of
TEArrow {} -> Html -> Html
parens (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp VName
t1
TypeExp VName
_ -> TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp VName
t1
Html
t2' <- TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp VName
t2
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ case Maybe VName
pname of
Just VName
v ->
Html -> Html
parens (VName -> Html
vnameHtml VName
v Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t1') Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" -> " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t2'
Maybe VName
Nothing ->
Html
t1' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" -> " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t2'
TESum [(Name, [TypeExp VName])]
cs SrcLoc
_ -> [Html] -> Html
pipes ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, [TypeExp VName])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(Name, [TypeExp VName])]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Name, [TypeExp VName])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppClause [(Name, [TypeExp VName])]
cs
where
ppClause :: (Name, [TypeExp VName])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppClause (Name
n, [TypeExp VName]
ts) = Html -> [Html] -> Html
joinBy Html
" " ([Html] -> Html) -> ([Html] -> [Html]) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Html
ppConstr Name
n Html -> [Html] -> [Html]
forall a. a -> [a] -> [a]
:) ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [TypeExp VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml [TypeExp VName]
ts
ppConstr :: Name -> Html
ppConstr Name
name = Html
"#" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> FilePath -> Html
forall a. ToMarkup a => a -> Html
toHtml (Name -> FilePath
nameToString Name
name)
qualNameHtml :: QualName VName -> DocM Html
qualNameHtml :: QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml (QualName [VName]
names vname :: VName
vname@(VName Name
name Int
tag)) =
if Int
tag Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
maxIntrinsicTag
then Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Name -> Html
renderName Name
name
else Maybe FilePath -> Html
f (Maybe FilePath -> Html)
-> ReaderT
Context (WriterT Documented (Writer Warnings)) (Maybe FilePath)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReaderT
Context (WriterT Documented (Writer Warnings)) (Maybe FilePath)
ref
where
prefix :: Html
prefix :: Html
prefix = (VName -> Html) -> [VName] -> Html
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
".") (Html -> Html) -> (VName -> Html) -> VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Html
renderName (Name -> Html) -> (VName -> Name) -> VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VName -> Name
baseName) [VName]
names
f :: Maybe FilePath -> Html
f (Just FilePath
s) = Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (FilePath -> AttributeValue
forall a. IsString a => FilePath -> a
fromString FilePath
s) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
prefix Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Name -> Html
renderName Name
name
f Maybe FilePath
Nothing = Html
prefix Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Name -> Html
renderName Name
name
ref :: ReaderT
Context (WriterT Documented (Writer Warnings)) (Maybe FilePath)
ref = do
Bool
boring <- (Context -> Bool)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Context -> Bool)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Bool)
-> (Context -> Bool)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Bool
forall a b. (a -> b) -> a -> b
$ VName -> NoLink -> Bool
forall a. Ord a => a -> Set a -> Bool
S.member VName
vname (NoLink -> Bool) -> (Context -> NoLink) -> Context -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Context -> NoLink
ctxNoLink
if Bool
boring
then Maybe FilePath
-> ReaderT
Context (WriterT Documented (Writer Warnings)) (Maybe FilePath)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe FilePath
forall a. Maybe a
Nothing
else FilePath -> Maybe FilePath
forall a. a -> Maybe a
Just (FilePath -> Maybe FilePath)
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
-> ReaderT
Context (WriterT Documented (Writer Warnings)) (Maybe FilePath)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
vnameLink VName
vname
vnameLink' :: VName -> String -> String -> String
vnameLink :: VName -> DocM String
vnameLink :: VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
vnameLink VName
vname = do
FilePath
current <- (Context -> FilePath)
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> FilePath
ctxCurrent
FilePath
file <- (Context -> FilePath)
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Context -> FilePath)
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath)
-> (Context -> FilePath)
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall a b. (a -> b) -> a -> b
$ FilePath
-> ((FilePath, Namespace) -> FilePath)
-> Maybe (FilePath, Namespace)
-> FilePath
forall b a. b -> (a -> b) -> Maybe a -> b
maybe FilePath
current (FilePath, Namespace) -> FilePath
forall a b. (a, b) -> a
fst (Maybe (FilePath, Namespace) -> FilePath)
-> (Context -> Maybe (FilePath, Namespace)) -> Context -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VName
-> Map VName (FilePath, Namespace) -> Maybe (FilePath, Namespace)
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup VName
vname (Map VName (FilePath, Namespace) -> Maybe (FilePath, Namespace))
-> (Context -> Map VName (FilePath, Namespace))
-> Context
-> Maybe (FilePath, Namespace)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Context -> Map VName (FilePath, Namespace)
ctxFileMap
FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall (m :: * -> *) a. Monad m => a -> m a
return (FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath)
-> FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall a b. (a -> b) -> a -> b
$ VName -> FilePath -> FilePath -> FilePath
vnameLink' VName
vname FilePath
current FilePath
file
vnameLink' :: VName -> FilePath -> FilePath -> FilePath
vnameLink' (VName Name
_ Int
tag) FilePath
current FilePath
file =
if FilePath
file FilePath -> FilePath -> Bool
forall a. Eq a => a -> a -> Bool
== FilePath
current
then FilePath
"#" FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ Int -> FilePath
forall a. Show a => a -> FilePath
show Int
tag
else FilePath -> FilePath -> FilePath
relativise FilePath
file FilePath
current FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
".html#" FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ Int -> FilePath
forall a. Show a => a -> FilePath
show Int
tag
typeNameHtml :: TypeName -> DocM Html
typeNameHtml :: TypeName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeNameHtml = QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml (QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (TypeName -> QualName VName)
-> TypeName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeName -> QualName VName
qualNameFromTypeName
patternHtml :: Pattern -> DocM Html
patternHtml :: PatternBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
patternHtml PatternBase Info VName
pat = do
let (PName
pat_param, StructType
t) = PatternBase Info VName -> (PName, StructType)
patternParam PatternBase Info VName
pat
Html
t' <- StructType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml StructType
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ case PName
pat_param of
Named VName
v -> Html -> Html
parens (VName -> Html
vnameHtml VName
v Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t')
PName
Unnamed -> Html
t'
relativise :: FilePath -> FilePath -> FilePath
relativise :: FilePath -> FilePath -> FilePath
relativise FilePath
dest FilePath
src =
[FilePath] -> FilePath
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (Int -> FilePath -> [FilePath]
forall a. Int -> a -> [a]
replicate ([FilePath] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (FilePath -> [FilePath]
splitPath FilePath
src) Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) FilePath
"../") FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
dest
dimDeclHtml :: DimDecl VName -> DocM Html
dimDeclHtml :: DimDecl VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimDeclHtml DimDecl VName
AnyDim = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return Html
forall a. Monoid a => a
mempty
dimDeclHtml (NamedDim QualName VName
v) = QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
v
dimDeclHtml (ConstDim Int
n) = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
forall a. ToMarkup a => a -> Html
toHtml (Int -> FilePath
forall a. Show a => a -> FilePath
show Int
n)
dimExpHtml :: DimExp VName -> DocM Html
dimExpHtml :: DimExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimExpHtml DimExp VName
DimExpAny = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return Html
forall a. Monoid a => a
mempty
dimExpHtml (DimExpNamed QualName VName
v SrcLoc
_) = QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
v
dimExpHtml (DimExpConst Int
n SrcLoc
_) = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
forall a. ToMarkup a => a -> Html
toHtml (Int -> FilePath
forall a. Show a => a -> FilePath
show Int
n)
typeArgExpHtml :: TypeArgExp VName -> DocM Html
typeArgExpHtml :: TypeArgExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeArgExpHtml (TypeArgExpDim DimExp VName
d SrcLoc
_) = DimExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimExpHtml DimExp VName
d
typeArgExpHtml (TypeArgExpType TypeExp VName
d) = TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp VName
d
typeParamHtml :: TypeParam -> Html
typeParamHtml :: TypeParamBase VName -> Html
typeParamHtml (TypeParamDim VName
name SrcLoc
_) =
Html -> Html
brackets (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ VName -> Html
vnameHtml VName
name
typeParamHtml (TypeParamType Liftedness
l VName
name SrcLoc
_) =
Html
"'" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> FilePath -> Html
forall a. IsString a => FilePath -> a
fromString (Liftedness -> FilePath
forall a. Pretty a => a -> FilePath
pretty Liftedness
l) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameHtml VName
name
typeAbbrevHtml :: Liftedness -> Html -> [TypeParam] -> Html
typeAbbrevHtml :: Liftedness -> Html -> [TypeParamBase VName] -> Html
typeAbbrevHtml Liftedness
l Html
name [TypeParamBase VName]
params =
Html
what Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ((Html
" " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) (Html -> Html)
-> (TypeParamBase VName -> Html) -> TypeParamBase VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeParamBase VName -> Html
typeParamHtml) [TypeParamBase VName]
params)
where
what :: Html
what = FilePath -> Html
keyword (FilePath -> Html) -> FilePath -> Html
forall a b. (a -> b) -> a -> b
$ FilePath
"type" FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ Liftedness -> FilePath
forall a. Pretty a => a -> FilePath
pretty Liftedness
l FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
" "
docHtml :: Maybe DocComment -> DocM Html
docHtml :: Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml (Just (DocComment FilePath
doc SrcLoc
loc)) =
Text -> Html
H.preEscapedText
(Text -> Html) -> (FilePath -> Text) -> FilePath -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CMarkOption] -> [CMarkExtension] -> Text -> Text
GFM.commonmarkToHtml [] [CMarkExtension
GFM.extAutolink]
(Text -> Text) -> (FilePath -> Text) -> FilePath -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Text
T.pack
(FilePath -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SrcLoc
-> FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
identifierLinks SrcLoc
loc FilePath
doc
docHtml Maybe DocComment
Nothing = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return Html
forall a. Monoid a => a
mempty
identifierLinks :: SrcLoc -> String -> DocM String
identifierLinks :: SrcLoc
-> FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
identifierLinks SrcLoc
_ [] = FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall (m :: * -> *) a. Monad m => a -> m a
return []
identifierLinks SrcLoc
loc FilePath
s
| Just ((FilePath
name, FilePath
namespace, Maybe FilePath
file), FilePath
s') <- FilePath -> Maybe ((FilePath, FilePath, Maybe FilePath), FilePath)
identifierReference FilePath
s = do
let proceed :: FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
proceed FilePath
x = (FilePath
x FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<>) (FilePath -> FilePath)
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SrcLoc
-> FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
identifierLinks SrcLoc
loc FilePath
s'
unknown :: ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
unknown = FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
proceed (FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath)
-> FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall a b. (a -> b) -> a -> b
$ FilePath
"`" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
name FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"`"
case FilePath -> Maybe Namespace
forall {a}. (Eq a, IsString a) => a -> Maybe Namespace
knownNamespace FilePath
namespace of
Just Namespace
namespace' -> do
Maybe VName
maybe_v <- (Namespace, FilePath, Maybe FilePath) -> DocM (Maybe VName)
lookupName (Namespace
namespace', FilePath
name, Maybe FilePath
file)
case Maybe VName
maybe_v of
Maybe VName
Nothing -> do
SrcLoc -> Doc -> DocM ()
warn SrcLoc
loc (Doc -> DocM ()) -> Doc -> DocM ()
forall a b. (a -> b) -> a -> b
$
Doc
"Identifier '" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc
forall a. IsString a => FilePath -> a
fromString FilePath
name Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
"' not found in namespace '"
Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc
forall a. IsString a => FilePath -> a
fromString FilePath
namespace
Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
"'"
Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc
forall a. IsString a => FilePath -> a
fromString (FilePath -> (FilePath -> FilePath) -> Maybe FilePath -> FilePath
forall b a. b -> (a -> b) -> Maybe a -> b
maybe FilePath
"" (FilePath
" in file " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<>) Maybe FilePath
file)
Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
"."
ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
unknown
Just VName
v' -> do
FilePath
link <- VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
vnameLink VName
v'
FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
proceed (FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath)
-> FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall a b. (a -> b) -> a -> b
$ FilePath
"[`" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
name FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"`](" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
link FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
")"
Maybe Namespace
_ -> do
SrcLoc -> Doc -> DocM ()
warn SrcLoc
loc (Doc -> DocM ()) -> Doc -> DocM ()
forall a b. (a -> b) -> a -> b
$ Doc
"Unknown namespace '" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc
forall a. IsString a => FilePath -> a
fromString FilePath
namespace Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
"'."
ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
unknown
where
knownNamespace :: a -> Maybe Namespace
knownNamespace a
"term" = Namespace -> Maybe Namespace
forall a. a -> Maybe a
Just Namespace
Term
knownNamespace a
"mtype" = Namespace -> Maybe Namespace
forall a. a -> Maybe a
Just Namespace
Signature
knownNamespace a
"type" = Namespace -> Maybe Namespace
forall a. a -> Maybe a
Just Namespace
Type
knownNamespace a
_ = Maybe Namespace
forall a. Maybe a
Nothing
identifierLinks SrcLoc
loc (Char
c : FilePath
s') = (Char
c Char -> FilePath -> FilePath
forall a. a -> [a] -> [a]
:) (FilePath -> FilePath)
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SrcLoc
-> FilePath
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
identifierLinks SrcLoc
loc FilePath
s'
lookupName :: (Namespace, String, Maybe FilePath) -> DocM (Maybe VName)
lookupName :: (Namespace, FilePath, Maybe FilePath) -> DocM (Maybe VName)
lookupName (Namespace
namespace, FilePath
name, Maybe FilePath
file) = do
FilePath
current <- (Context -> FilePath)
-> ReaderT Context (WriterT Documented (Writer Warnings)) FilePath
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> FilePath
ctxCurrent
let file' :: Maybe FilePath
file' = ImportName -> FilePath
includeToString (ImportName -> FilePath)
-> (FilePath -> ImportName) -> FilePath -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FilePath -> SrcLoc -> ImportName)
-> SrcLoc -> FilePath -> ImportName
forall a b c. (a -> b -> c) -> b -> a -> c
flip (ImportName -> FilePath -> SrcLoc -> ImportName
mkImportFrom (FilePath -> ImportName
mkInitialImport FilePath
current)) SrcLoc
forall a. Monoid a => a
mempty (FilePath -> FilePath) -> Maybe FilePath -> Maybe FilePath
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe FilePath
file
Maybe Env
env <- Maybe FilePath -> DocM (Maybe Env)
lookupEnvForFile Maybe FilePath
file'
case (Namespace, Name)
-> Map (Namespace, Name) (QualName VName) -> Maybe (QualName VName)
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup (Namespace
namespace, FilePath -> Name
nameFromString FilePath
name) (Map (Namespace, Name) (QualName VName) -> Maybe (QualName VName))
-> (Env -> Map (Namespace, Name) (QualName VName))
-> Env
-> Maybe (QualName VName)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Env -> Map (Namespace, Name) (QualName VName)
envNameMap (Env -> Maybe (QualName VName))
-> Maybe Env -> Maybe (QualName VName)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Maybe Env
env of
Maybe (QualName VName)
Nothing -> Maybe VName -> DocM (Maybe VName)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe VName
forall a. Maybe a
Nothing
Just QualName VName
qn -> Maybe VName -> DocM (Maybe VName)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe VName -> DocM (Maybe VName))
-> Maybe VName -> DocM (Maybe VName)
forall a b. (a -> b) -> a -> b
$ VName -> Maybe VName
forall a. a -> Maybe a
Just (VName -> Maybe VName) -> VName -> Maybe VName
forall a b. (a -> b) -> a -> b
$ QualName VName -> VName
forall vn. QualName vn -> vn
qualLeaf QualName VName
qn
lookupEnvForFile :: Maybe FilePath -> DocM (Maybe Env)
lookupEnvForFile :: Maybe FilePath -> DocM (Maybe Env)
lookupEnvForFile Maybe FilePath
Nothing = (Context -> Maybe Env) -> DocM (Maybe Env)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Context -> Maybe Env) -> DocM (Maybe Env))
-> (Context -> Maybe Env) -> DocM (Maybe Env)
forall a b. (a -> b) -> a -> b
$ Env -> Maybe Env
forall a. a -> Maybe a
Just (Env -> Maybe Env) -> (Context -> Env) -> Context -> Maybe Env
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileModule -> Env
fileEnv (FileModule -> Env) -> (Context -> FileModule) -> Context -> Env
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Context -> FileModule
ctxFileMod
lookupEnvForFile (Just FilePath
file) = (Context -> Maybe Env) -> DocM (Maybe Env)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Context -> Maybe Env) -> DocM (Maybe Env))
-> (Context -> Maybe Env) -> DocM (Maybe Env)
forall a b. (a -> b) -> a -> b
$ (FileModule -> Env) -> Maybe FileModule -> Maybe Env
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap FileModule -> Env
fileEnv (Maybe FileModule -> Maybe Env)
-> (Context -> Maybe FileModule) -> Context -> Maybe Env
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Imports -> Maybe FileModule
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup FilePath
file (Imports -> Maybe FileModule)
-> (Context -> Imports) -> Context -> Maybe FileModule
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Context -> Imports
ctxImports
describeGeneric ::
VName ->
IndexWhat ->
Maybe DocComment ->
(Html -> DocM Html) ->
DocM Html
describeGeneric :: VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric VName
name IndexWhat
what Maybe DocComment
doc Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
f = do
Html
name' <- Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"decl_name" (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> VName
-> IndexWhat
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
vnameDescDef VName
name IndexWhat
what
Html
decl_type <- Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
f Html
name'
Html
doc' <- Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml Maybe DocComment
doc
let decl_doc :: Html
decl_doc = Html -> Html
H.dd (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_doc" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
doc'
decl_header :: Html
decl_header =
(Html -> Html
H.dt (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_header") (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
VName -> Html
vnameSynopsisRef VName
name Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
decl_type
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
decl_header Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
decl_doc
describeGenericMod ::
VName ->
IndexWhat ->
SigExp ->
Maybe DocComment ->
(Html -> DocM Html) ->
DocM Html
describeGenericMod :: VName
-> IndexWhat
-> SigExpBase Info VName
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGenericMod VName
name IndexWhat
what SigExpBase Info VName
se Maybe DocComment
doc Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
f = do
Html
name' <- Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"decl_name" (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> VName
-> IndexWhat
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
vnameDescDef VName
name IndexWhat
what
Html
decl_type <- Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
f Html
name'
Html
doc' <- case SigExpBase Info VName
se of
SigSpecs [SpecBase Info VName]
specs SrcLoc
_ -> Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
(<>) (Html -> Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT
Context (WriterT Documented (Writer Warnings)) (Html -> Html)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml Maybe DocComment
doc ReaderT
Context (WriterT Documented (Writer Warnings)) (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [SpecBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeSpecs [SpecBase Info VName]
specs
SigExpBase Info VName
_ -> Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml Maybe DocComment
doc
let decl_doc :: Html
decl_doc = Html -> Html
H.dd (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_doc" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
doc'
decl_header :: Html
decl_header =
(Html -> Html
H.dt (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_header") (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
VName -> Html
vnameSynopsisRef VName
name Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
decl_type
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
decl_header Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
decl_doc
describeDecs :: [Dec] -> DocM Html
describeDecs :: [Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeDecs [Dec]
decs = do
NoLink
visible <- (Context -> NoLink)
-> ReaderT Context (WriterT Documented (Writer Warnings)) NoLink
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> NoLink
ctxVisibleMTys
Html -> Html
H.dl (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat
([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [ReaderT Context (WriterT Documented (Writer Warnings)) Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM
((Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"decl_description")
((Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> [Dec]
-> [ReaderT Context (WriterT Documented (Writer Warnings)) Html]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (NoLink
-> Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
describeDec NoLink
visible) [Dec]
decs)
describeDec :: S.Set VName -> Dec -> Maybe (DocM Html)
describeDec :: NoLink
-> Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
describeDec NoLink
_ (ValDec ValBindBase Info VName
vb) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric (ValBindBase Info VName -> VName
forall (f :: * -> *) vn. ValBindBase f vn -> vn
valBindName ValBindBase Info VName
vb) (ValBindBase Info VName -> IndexWhat
valBindWhat ValBindBase Info VName
vb) (ValBindBase Info VName -> Maybe DocComment
forall (f :: * -> *) vn. ValBindBase f vn -> Maybe DocComment
valBindDoc ValBindBase Info VName
vb) ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name -> do
(Html
lhs, Html
mhs, Html
rhs) <- Html -> ValBindBase Info VName -> DocM (Html, Html, Html)
valBindHtml Html
name ValBindBase Info VName
vb
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
lhs Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
mhs Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
rhs
describeDec NoLink
_ (TypeDec TypeBindBase Info VName
vb) =
ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric (TypeBindBase Info VName -> VName
forall (f :: * -> *) vn. TypeBindBase f vn -> vn
typeAlias TypeBindBase Info VName
vb) IndexWhat
IndexType (TypeBindBase Info VName -> Maybe DocComment
forall (f :: * -> *) vn. TypeBindBase f vn -> Maybe DocComment
typeDoc TypeBindBase Info VName
vb) (Html
-> TypeBindBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
`typeBindHtml` TypeBindBase Info VName
vb)
describeDec NoLink
_ (SigDec (SigBind VName
name SigExpBase Info VName
se Maybe DocComment
doc SrcLoc
_)) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
VName
-> IndexWhat
-> SigExpBase Info VName
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGenericMod VName
name IndexWhat
IndexModuleType SigExpBase Info VName
se Maybe DocComment
doc ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name' ->
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
keyword FilePath
"module type " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name'
describeDec NoLink
_ (ModDec ModBindBase Info VName
mb) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric (ModBindBase Info VName -> VName
forall (f :: * -> *) vn. ModBindBase f vn -> vn
modName ModBindBase Info VName
mb) IndexWhat
IndexModule (ModBindBase Info VName -> Maybe DocComment
forall (f :: * -> *) vn. ModBindBase f vn -> Maybe DocComment
modDoc ModBindBase Info VName
mb) ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name' ->
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
keyword FilePath
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name'
describeDec NoLink
_ OpenDec {} = Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
describeDec NoLink
visible (LocalDec (SigDec (SigBind VName
name SigExpBase Info VName
se Maybe DocComment
doc SrcLoc
_)) SrcLoc
_)
| VName
name VName -> NoLink -> Bool
forall a. Ord a => a -> Set a -> Bool
`S.member` NoLink
visible = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
VName
-> IndexWhat
-> SigExpBase Info VName
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGenericMod VName
name IndexWhat
IndexModuleType SigExpBase Info VName
se Maybe DocComment
doc ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name' ->
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
keyword FilePath
"local module type " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name'
describeDec NoLink
_ LocalDec {} = Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
describeDec NoLink
_ ImportDec {} = Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
valBindWhat :: ValBind -> IndexWhat
valBindWhat :: ValBindBase Info VName -> IndexWhat
valBindWhat ValBindBase Info VName
vb
| [PatternBase Info VName] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (ValBindBase Info VName -> [PatternBase Info VName]
forall (f :: * -> *) vn. ValBindBase f vn -> [PatternBase f vn]
valBindParams ValBindBase Info VName
vb),
StructType -> Bool
forall dim as. TypeBase dim as -> Bool
orderZero ((StructType, [VName]) -> StructType
forall a b. (a, b) -> a
fst ((StructType, [VName]) -> StructType)
-> (StructType, [VName]) -> StructType
forall a b. (a -> b) -> a -> b
$ Info (StructType, [VName]) -> (StructType, [VName])
forall a. Info a -> a
unInfo (Info (StructType, [VName]) -> (StructType, [VName]))
-> Info (StructType, [VName]) -> (StructType, [VName])
forall a b. (a -> b) -> a -> b
$ ValBindBase Info VName -> Info (StructType, [VName])
forall (f :: * -> *) vn.
ValBindBase f vn -> f (StructType, [VName])
valBindRetType ValBindBase Info VName
vb) =
IndexWhat
IndexValue
| Bool
otherwise =
IndexWhat
IxFun
describeSpecs :: [Spec] -> DocM Html
describeSpecs :: [SpecBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeSpecs [SpecBase Info VName]
specs =
Html -> Html
H.dl (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [SpecBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeSpec [SpecBase Info VName]
specs
describeSpec :: Spec -> DocM Html
describeSpec :: SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeSpec (ValSpec VName
name [TypeParamBase VName]
tparams TypeDeclBase Info VName
t Maybe DocComment
doc SrcLoc
_) =
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric VName
name IndexWhat
what Maybe DocComment
doc ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name' -> do
let tparams' :: Html
tparams' = [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ (TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ((Html
" " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<>) (Html -> Html)
-> (TypeParamBase VName -> Html) -> TypeParamBase VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeParamBase VName -> Html
typeParamHtml) [TypeParamBase VName]
tparams
Html
t' <-
[VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a. [VName] -> DocM a -> DocM a
noLink ((TypeParamBase VName -> VName) -> [TypeParamBase VName] -> [VName]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> VName
forall vn. TypeParamBase vn -> vn
typeParamName [TypeParamBase VName]
tparams) (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml (TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> TypeExp VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ TypeDeclBase Info VName -> TypeExp VName
forall (f :: * -> *) vn. TypeDeclBase f vn -> TypeExp vn
declaredType TypeDeclBase Info VName
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
keyword FilePath
"val " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
tparams' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
where
what :: IndexWhat
what =
if StructType -> Bool
forall dim as. TypeBase dim as -> Bool
orderZero (Info StructType -> StructType
forall a. Info a -> a
unInfo (Info StructType -> StructType) -> Info StructType -> StructType
forall a b. (a -> b) -> a -> b
$ TypeDeclBase Info VName -> Info StructType
forall (f :: * -> *) vn. TypeDeclBase f vn -> f StructType
expandedType TypeDeclBase Info VName
t)
then IndexWhat
IndexValue
else IndexWhat
IxFun
describeSpec (TypeAbbrSpec TypeBindBase Info VName
vb) =
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric (TypeBindBase Info VName -> VName
forall (f :: * -> *) vn. TypeBindBase f vn -> vn
typeAlias TypeBindBase Info VName
vb) IndexWhat
IndexType (TypeBindBase Info VName -> Maybe DocComment
forall (f :: * -> *) vn. TypeBindBase f vn -> Maybe DocComment
typeDoc TypeBindBase Info VName
vb) (Html
-> TypeBindBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
`typeBindHtml` TypeBindBase Info VName
vb)
describeSpec (TypeSpec Liftedness
l VName
name [TypeParamBase VName]
tparams Maybe DocComment
doc SrcLoc
_) =
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric VName
name IndexWhat
IndexType Maybe DocComment
doc ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html -> Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\Html
name' -> Liftedness -> Html -> [TypeParamBase VName] -> Html
typeAbbrevHtml Liftedness
l Html
name' [TypeParamBase VName]
tparams)
describeSpec (ModSpec VName
name SigExpBase Info VName
se Maybe DocComment
doc SrcLoc
_) =
VName
-> IndexWhat
-> SigExpBase Info VName
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGenericMod VName
name IndexWhat
IndexModule SigExpBase Info VName
se Maybe DocComment
doc ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name' ->
case SigExpBase Info VName
se of
SigSpecs {} -> Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
keyword FilePath
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name'
SigExpBase Info VName
_ -> do
Html
se' <- SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
se
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ FilePath -> Html
keyword FilePath
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
se'
describeSpec (IncludeSpec SigExpBase Info VName
sig SrcLoc
_) = do
Html
sig' <- SigExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSigExp SigExpBase Info VName
sig
Html
doc' <- Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml Maybe DocComment
forall a. Maybe a
Nothing
let decl_header :: Html
decl_header =
(Html -> Html
H.dt (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_header") (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"synopsis_link") Html
forall a. Monoid a => a
mempty
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> FilePath -> Html
keyword FilePath
"include "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
sig'
decl_doc :: Html
decl_doc = Html -> Html
H.dd (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_doc" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
doc'
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
decl_header Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
decl_doc