Skip to content

Commit 8004dd6

Browse files
authored
Merge pull request #223 from AiOO/improve-document-for-statistics
Improve document for statistics
2 parents 0ca309f + 6424e1a commit 8004dd6

File tree

1 file changed

+44
-47
lines changed

1 file changed

+44
-47
lines changed

src/Nirum/Targets/Docs.hs

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -143,50 +143,43 @@ blockToHtml b = preEscapedToMarkup $ render b
143143
typeDecl :: BoundModule Docs -> Identifier -> TD.TypeDeclaration -> Html
144144
typeDecl mod' ident
145145
tc@TD.TypeDeclaration { TD.type' = TD.Alias cname } = [shamlet|
146-
<h2>
147-
<span.type>type
148-
<code>#{toNormalizedText ident}</code>
149-
=
146+
<h2><code>type</code> #{toNormalizedText ident} = #
150147
<code>#{typeExpression mod' cname}</code>
151148
$maybe d <- docsBlock tc
152149
#{blockToHtml d}
153150
|]
154151
typeDecl mod' ident
155152
tc@TD.TypeDeclaration { TD.type' = TD.UnboxedType innerType } =
156153
[shamlet|
157-
<h2>
158-
<span.type>unboxed
159-
<code>#{toNormalizedText ident} (#{typeExpression mod' innerType})
154+
<h2><code>unboxed</code> #{toNormalizedText ident}
155+
(<code>#{typeExpression mod' innerType}</code>)
160156
$maybe d <- docsBlock tc
161157
#{blockToHtml d}
162158
|]
163159
typeDecl _ ident
164160
tc@TD.TypeDeclaration { TD.type' = TD.EnumType members } = [shamlet|
165-
<h2>
166-
<span.type>enum
167-
<code>#{toNormalizedText ident}
161+
<h2><code>enum</code> #{toNormalizedText ident}
168162
$maybe d <- docsBlock tc
169163
#{blockToHtml d}
170164
<dl class="members">
171165
$forall decl <- DES.toList members
172-
<dt class="member-name"><code>#{nameText $ DE.name decl}</code>
173-
<dd class="member-doc">
174-
$maybe d <- docsBlock decl
175-
#{blockToHtml d}
166+
<dt class="member-name">#{nameText $ DE.name decl}
167+
<dd class="member-doc">
168+
$maybe d <- docsBlock decl
169+
#{blockToHtml d}
176170
|]
177171
typeDecl mod' ident
178172
tc@TD.TypeDeclaration { TD.type' = TD.RecordType fields } = [shamlet|
179-
<h2>
180-
<span.type>record
181-
<code>#{toNormalizedText ident}
173+
<h2><code>record</code> #{toNormalizedText ident}
182174
$maybe d <- docsBlock tc
183175
#{blockToHtml d}
184-
$forall fieldDecl@(TD.Field _ fieldType _) <- DES.toList fields
185-
<h3>
186-
<span.type>#{typeExpression mod' fieldType}
187-
<code>#{nameText $ DE.name fieldDecl}
188-
$maybe d <- docsBlock fieldDecl
189-
#{blockToHtml d}
176+
<dl.fields>
177+
$forall fieldDecl@(TD.Field _ fieldType _) <- DES.toList fields
178+
<dt>
179+
<code>#{typeExpression mod' fieldType}
180+
#{nameText $ DE.name fieldDecl}
181+
$maybe d <- docsBlock fieldDecl
182+
<dd>#{blockToHtml d}
190183
|]
191184
typeDecl mod' ident
192185
tc@TD.TypeDeclaration { TD.type' = TD.UnionType tags } = [shamlet|
@@ -211,33 +204,33 @@ typeDecl _ ident
211204
typeDecl mod' ident
212205
tc@TD.ServiceDeclaration { TD.service = S.Service methods } =
213206
[shamlet|
214-
<h2>service <code>#{toNormalizedText ident}</code>
207+
<h2><code>service</code> #{toNormalizedText ident}
215208
$maybe d <- docsBlock tc
216209
#{blockToHtml d}
217210
$forall md@(S.Method _ ps ret err _) <- DES.toList methods
218-
<h3 class="method">
219-
<code class="method-name">#{nameText $ DE.name md}</code>(
220-
$forall (i, pd@(S.Parameter _ pt _)) <- enumerateParams ps
221-
$if i > 0
222-
, #
223-
<code class="type">#{typeExpression mod' pt}</code> #
224-
<var>#{nameText $ DE.name pd}</var>#
225-
)
211+
<h3.method>#{nameText $ DE.name md} (
212+
$forall (i, pd@(S.Parameter _ pt _)) <- enumerateParams ps
213+
$if i > 0
214+
, #
215+
<code.type>#{typeExpression mod' pt}</code> #
216+
<var>#{nameText $ DE.name pd}</var>#
217+
)
226218
$maybe d <- docsBlock md
227219
#{blockToHtml d}
228-
<dl class="result">
220+
<dl.parameters>
221+
$forall paramDecl@(S.Parameter _ paramType _) <- DES.toList ps
222+
$maybe d <- docsBlock paramDecl
223+
<dt>
224+
<code.type>#{typeExpression mod' paramType}
225+
<var>#{nameText $ DE.name paramDecl}</var>:
226+
<dd>#{blockToHtml d}
227+
<dl.result>
229228
$maybe retType <- ret
230-
<dt class="return-label">returns:
231-
<dd class="return-type">#{typeExpression mod' retType}
229+
<dt.return-label>returns:
230+
<dd.return-type><code>#{typeExpression mod' retType}</code>
232231
$maybe errType <- err
233-
<dt class="raise-label">raises:
234-
<dd class="raise-type">#{typeExpression mod' errType}
235-
$forall paramDecl@(S.Parameter _ paramType _) <- DES.toList ps
236-
$maybe d <- docsBlock paramDecl
237-
<h4>
238-
<span.type>#{typeExpression mod' paramType}
239-
<code>#{nameText $ DE.name paramDecl}</code>:
240-
#{blockToHtml d}
232+
<dt.raise-label>raises:
233+
<dd.raise-type><code>#{typeExpression mod' errType}</code>
241234
|]
242235
where
243236
enumerate :: [a] -> [(Int, a)]
@@ -307,9 +300,7 @@ moduleTitle Module { docs = docs' } = do
307300

308301
stylesheet :: TL.Text
309302
stylesheet = renderCss ([cassius|
310-
@import url(
311-
https://fonts.googleapis.com/css?family=Source+Code+Pro:300,400|Source+Sans+Pro
312-
)
303+
@import url("https://fonts.googleapis.com/css?family=Source+Code+Pro:300,400|Source+Sans+Pro")
313304
body
314305
font-family: Source Sans Pro
315306
color: #{gray8}
@@ -326,8 +317,11 @@ div
326317
border-top: 1px solid #{gray3}
327318
h1, h2, h3, h4, h5, h6
328319
code
329-
font-weight: 400
330320
background-color: #{gray3}
321+
h1, h2, h3, h4, h5, h6, dt
322+
font-weight: bold
323+
code
324+
font-weight: 400
331325
a
332326
text-decoration: none
333327
a:link
@@ -336,6 +330,9 @@ a:visited
336330
color: #{graph8}
337331
a:hover
338332
text-decoration: underline
333+
dd
334+
p
335+
margin-top: 0
339336
|] undefined)
340337
where
341338
-- from Open Color https://yeun.github.io/open-color/

0 commit comments

Comments
 (0)