Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve document for statistics #223

Merged
merged 2 commits into from
Feb 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 44 additions & 47 deletions src/Nirum/Targets/Docs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,50 +143,43 @@ blockToHtml b = preEscapedToMarkup $ render b
typeDecl :: BoundModule Docs -> Identifier -> TD.TypeDeclaration -> Html
typeDecl mod' ident
tc@TD.TypeDeclaration { TD.type' = TD.Alias cname } = [shamlet|
<h2>
<span.type>type
<code>#{toNormalizedText ident}</code>
=
<h2><code>type</code> #{toNormalizedText ident} = #
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 #은 없어도되는거아닌가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

라인 끝에 공백 유지해주기 위한 코드입니당

<code>#{typeExpression mod' cname}</code>
$maybe d <- docsBlock tc
#{blockToHtml d}
|]
typeDecl mod' ident
tc@TD.TypeDeclaration { TD.type' = TD.UnboxedType innerType } =
[shamlet|
<h2>
<span.type>unboxed
<code>#{toNormalizedText ident} (#{typeExpression mod' innerType})
<h2><code>unboxed</code> #{toNormalizedText ident}
(<code>#{typeExpression mod' innerType}</code>)
$maybe d <- docsBlock tc
#{blockToHtml d}
|]
typeDecl _ ident
tc@TD.TypeDeclaration { TD.type' = TD.EnumType members } = [shamlet|
<h2>
<span.type>enum
<code>#{toNormalizedText ident}
<h2><code>enum</code> #{toNormalizedText ident}
$maybe d <- docsBlock tc
#{blockToHtml d}
<dl class="members">
$forall decl <- DES.toList members
<dt class="member-name"><code>#{nameText $ DE.name decl}</code>
<dd class="member-doc">
$maybe d <- docsBlock decl
#{blockToHtml d}
<dt class="member-name">#{nameText $ DE.name decl}
<dd class="member-doc">
$maybe d <- docsBlock decl
#{blockToHtml d}
|]
typeDecl mod' ident
tc@TD.TypeDeclaration { TD.type' = TD.RecordType fields } = [shamlet|
<h2>
<span.type>record
<code>#{toNormalizedText ident}
<h2><code>record</code> #{toNormalizedText ident}
$maybe d <- docsBlock tc
#{blockToHtml d}
$forall fieldDecl@(TD.Field _ fieldType _) <- DES.toList fields
<h3>
<span.type>#{typeExpression mod' fieldType}
<code>#{nameText $ DE.name fieldDecl}
$maybe d <- docsBlock fieldDecl
#{blockToHtml d}
<dl.fields>
$forall fieldDecl@(TD.Field _ fieldType _) <- DES.toList fields
<dt>
<code>#{typeExpression mod' fieldType}
#{nameText $ DE.name fieldDecl}
$maybe d <- docsBlock fieldDecl
<dd>#{blockToHtml d}
|]
typeDecl mod' ident
tc@TD.TypeDeclaration { TD.type' = TD.UnionType tags } = [shamlet|
Expand All @@ -211,33 +204,33 @@ typeDecl _ ident
typeDecl mod' ident
tc@TD.ServiceDeclaration { TD.service = S.Service methods } =
[shamlet|
<h2>service <code>#{toNormalizedText ident}</code>
<h2><code>service</code> #{toNormalizedText ident}
$maybe d <- docsBlock tc
#{blockToHtml d}
$forall md@(S.Method _ ps ret err _) <- DES.toList methods
<h3 class="method">
<code class="method-name">#{nameText $ DE.name md}</code>(
$forall (i, pd@(S.Parameter _ pt _)) <- enumerateParams ps
$if i > 0
, #
<code class="type">#{typeExpression mod' pt}</code> #
<var>#{nameText $ DE.name pd}</var>#
)
<h3.method>#{nameText $ DE.name md} (
$forall (i, pd@(S.Parameter _ pt _)) <- enumerateParams ps
$if i > 0
, #
<code.type>#{typeExpression mod' pt}</code> #
<var>#{nameText $ DE.name pd}</var>#
)
$maybe d <- docsBlock md
#{blockToHtml d}
<dl class="result">
<dl.parameters>
$forall paramDecl@(S.Parameter _ paramType _) <- DES.toList ps
$maybe d <- docsBlock paramDecl
<dt>
<code.type>#{typeExpression mod' paramType}
<var>#{nameText $ DE.name paramDecl}</var>:
<dd>#{blockToHtml d}
<dl.result>
$maybe retType <- ret
<dt class="return-label">returns:
<dd class="return-type">#{typeExpression mod' retType}
<dt.return-label>returns:
<dd.return-type><code>#{typeExpression mod' retType}</code>
$maybe errType <- err
<dt class="raise-label">raises:
<dd class="raise-type">#{typeExpression mod' errType}
$forall paramDecl@(S.Parameter _ paramType _) <- DES.toList ps
$maybe d <- docsBlock paramDecl
<h4>
<span.type>#{typeExpression mod' paramType}
<code>#{nameText $ DE.name paramDecl}</code>:
#{blockToHtml d}
<dt.raise-label>raises:
<dd.raise-type><code>#{typeExpression mod' errType}</code>
|]
where
enumerate :: [a] -> [(Int, a)]
Expand Down Expand Up @@ -307,9 +300,7 @@ moduleTitle Module { docs = docs' } = do

stylesheet :: TL.Text
stylesheet = renderCss ([cassius|
@import url(
https://fonts.googleapis.com/css?family=Source+Code+Pro:300,400|Source+Sans+Pro
)
@import url("https://fonts.googleapis.com/css?family=Source+Code+Pro:300,400|Source+Sans+Pro")
body
font-family: Source Sans Pro
color: #{gray8}
Expand All @@ -326,8 +317,11 @@ div
border-top: 1px solid #{gray3}
h1, h2, h3, h4, h5, h6
code
font-weight: 400
background-color: #{gray3}
h1, h2, h3, h4, h5, h6, dt
font-weight: bold
code
font-weight: 400
a
text-decoration: none
a:link
Expand All @@ -336,6 +330,9 @@ a:visited
color: #{graph8}
a:hover
text-decoration: underline
dd
p
margin-top: 0
|] undefined)
where
-- from Open Color https://yeun.github.io/open-color/
Expand Down