diff --git a/src/Nirum/Targets/Docs.hs b/src/Nirum/Targets/Docs.hs index 0c956b9..4a59abb 100644 --- a/src/Nirum/Targets/Docs.hs +++ b/src/Nirum/Targets/Docs.hs @@ -234,12 +234,20 @@ typeDecl mod' ident
#{blockToHtml d} |] typeDecl mod' ident - tc@TD.TypeDeclaration { TD.type' = TD.UnionType tags _} = [shamlet| + tc@TD.TypeDeclaration + { TD.type' = unionType@TD.UnionType + { TD.defaultTag = defaultTag + } + } = + [shamlet|

union #{toNormalizedText ident} $maybe d <- docsBlock tc #{blockToHtml d} - $forall tagDecl@(TD.Tag _ fields _) <- DES.toList tags -

#{nameText $ DE.name tagDecl} + $forall (default_, tagDecl@(TD.Tag _ fields _)) <- tagList +

+ $if default_ + default + #{nameText $ DE.name tagDecl} $maybe d <- docsBlock tagDecl #{blockToHtml d} $forall fieldDecl@(TD.Field _ fieldType _) <- DES.toList fields @@ -248,7 +256,13 @@ typeDecl mod' ident #{nameText $ DE.name fieldDecl} $maybe d <- docsBlock fieldDecl #{blockToHtml d} -|] + |] + where + tagList :: [(Bool, TD.Tag)] + tagList = + [ (defaultTag == Just tag, tag) + | tag <- DES.toList (TD.tags unionType) + ] typeDecl _ ident TD.TypeDeclaration { TD.type' = TD.PrimitiveType {} } = [shamlet|

primitive #{toNormalizedText ident}