Skip to content

Commit

Permalink
Show default tags as well on docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Hong Minhee authored and dahlia committed Apr 12, 2018
1 parent 0b08904 commit f0c3e30
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Nirum/Targets/Docs.hs
Expand Up @@ -234,12 +234,20 @@ typeDecl mod' ident
<dd>#{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|
<h2>union <code>#{toNormalizedText ident}</code>
$maybe d <- docsBlock tc
#{blockToHtml d}
$forall tagDecl@(TD.Tag _ fields _) <- DES.toList tags
<h3 class="tag"><code>#{nameText $ DE.name tagDecl}</code>
$forall (default_, tagDecl@(TD.Tag _ fields _)) <- tagList
<h3 .tag :default_:.default-tag>
$if default_
default&#32;
<code>#{nameText $ DE.name tagDecl}</code>
$maybe d <- docsBlock tagDecl
#{blockToHtml d}
$forall fieldDecl@(TD.Field _ fieldType _) <- DES.toList fields
Expand All @@ -248,7 +256,13 @@ typeDecl mod' ident
<code>#{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|
<h2>primitive <code>#{toNormalizedText ident}</code>
Expand Down

0 comments on commit f0c3e30

Please sign in to comment.