From 19ccbf215db30d126684b83ca14c09c1184bc73c Mon Sep 17 00:00:00 2001 From: Ahn Kiwook Date: Sun, 12 Mar 2017 02:43:31 +0900 Subject: [PATCH] Add type list for each module --- src/Nirum/Targets/Docs.hs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Nirum/Targets/Docs.hs b/src/Nirum/Targets/Docs.hs index a571209..91707a1 100644 --- a/src/Nirum/Targets/Docs.hs +++ b/src/Nirum/Targets/Docs.hs @@ -15,10 +15,17 @@ import Text.Blaze.Html.Renderer.Utf8 (renderHtml) import Text.Hamlet (Html, shamlet) import Nirum.Constructs (Construct (toCode)) +import qualified Nirum.Constructs.Declaration as DE +import qualified Nirum.Constructs.DeclarationSet as DES import qualified Nirum.Constructs.Docs as D -import Nirum.Constructs.Identifier (toNormalizedString) +import Nirum.Constructs.Identifier ( Identifier + , toNormalizedString + , toNormalizedText + ) import Nirum.Constructs.Module (Module (Module, docs)) import Nirum.Constructs.ModulePath (ModulePath) +import Nirum.Constructs.Name (Name (facialName)) +import qualified Nirum.Constructs.TypeDeclaration as TD import Nirum.Docs ( Block (Heading) , filterReferences ) @@ -26,6 +33,7 @@ import Nirum.Docs.Html (renderInlines) import Nirum.Package ( BoundModule (boundPackage, modulePath) , Package (Package, metadata, modules) , resolveBoundModule + , types ) import Nirum.Package.Metadata ( Author (Author, email, name, uri) , Metadata (authors) @@ -68,12 +76,31 @@ $doctype 5

#{path} + $forall (ident, decl) <- types' +

#{showKind decl} #{toNormalizedText ident} |] where md :: Metadata Docs md = metadata $ boundPackage docsModule path :: T.Text path = toCode $ modulePath docsModule + showKind :: TD.TypeDeclaration -> T.Text + showKind TD.ServiceDeclaration {} = "service" + showKind TD.TypeDeclaration { TD.type' = type'' } = case type'' of + TD.Alias {} -> "alias" + TD.UnboxedType {} -> "unboxed" + TD.EnumType {} -> "enum" + TD.RecordType {} -> "record" + TD.UnionType {} -> "union" + TD.PrimitiveType {} -> "primitive" + showKind TD.Import {} = "import" + types' :: [(Identifier, TD.TypeDeclaration)] + types' = [ (facialName $ DE.name decl, decl) + | decl <- DES.toList $ types docsModule + , case decl of + TD.Import {} -> False + _ -> True + ] contents :: Package Docs -> Html contents Package { metadata = md, modules = ms } = [shamlet|