File tree Expand file tree Collapse file tree 5 files changed +34
-13
lines changed Expand file tree Collapse file tree 5 files changed +34
-13
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,9 @@ To be released.
126
126
127
127
- Docs now have a sidebar which contains table of contents. [[#257]]
128
128
129
+ - Fixed a bug that a module-level docs hadn't been rendered.
130
+ Now it's shown in the right below the module name. [[#259]]
131
+
129
132
### Python target
130
133
131
134
- Generated Python packages became to have two [entry points] (a feature
@@ -178,6 +181,7 @@ To be released.
178
181
[#254]: https://github.com/spoqa/nirum/pull/254
179
182
[#255]: https://github.com/spoqa/nirum/pull/255
180
183
[#257]: https://github.com/spoqa/nirum/pull/257
184
+ [#259]: https://github.com/spoqa/nirum/pull/259
181
185
[entry points]: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points
182
186
[python2-numbers-integral]: https://docs.python.org/2/library/numbers.html#numbers.Integral
183
187
[python2-int]: https://docs.python.org/2/library/functions.html#int
Original file line number Diff line number Diff line change 1
1
# Introducing built-in types
2
2
# ==========================
3
+ #
4
+ # This example module introduces the built-in types Nirum provides.
3
5
4
6
record number-types (
5
7
bigint a,
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ module Nirum.Docs ( Block ( BlockQuote
37
37
, headingLevelFromInt
38
38
, headingLevelInt
39
39
, parse
40
+ , trimTitle
40
41
) where
41
42
42
43
import Data.String (IsString (fromString ))
@@ -112,6 +113,13 @@ data Inline
112
113
| Image { imageUrl :: Url , imageTitle :: Title }
113
114
deriving (Eq , Ord , Show )
114
115
116
+ -- | Trim the top-level first heading from the block, if it exists.
117
+ trimTitle :: Block -> Block
118
+ trimTitle block =
119
+ case block of
120
+ Document (Heading {} : rest) -> Document rest
121
+ b -> b
122
+
115
123
parse :: T. Text -> Block
116
124
parse =
117
125
transBlock . M. commonmarkToNode [M. optNormalize, M. optSmart]
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ import qualified Nirum.Constructs.TypeDeclaration as TD
39
39
import qualified Nirum.Constructs.TypeExpression as TE
40
40
import Nirum.Docs ( Block (Heading )
41
41
, filterReferences
42
+ , trimTitle
42
43
)
43
44
import Nirum.Docs.Html (render , renderInlines )
44
45
import Nirum.Package
@@ -161,6 +162,9 @@ $maybe tit <- headingTitle
161
162
 — #{tit}
162
163
$nothing
163
164
<h1><code>#{path}</code>
165
+ $maybe m <- mod'
166
+ $maybe d <- docsBlock m
167
+ #{blockToHtml (trimTitle d)}
164
168
$forall (ident, decl) <- types'
165
169
<div class="#{showKind decl}" id="#{toNormalizedText ident}">
166
170
#{typeDecl docsModule ident decl}
Original file line number Diff line number Diff line change @@ -5,16 +5,7 @@ import Data.Text (Text)
5
5
import Test.Hspec.Meta
6
6
import Text.InterpolatedString.Perl6 (q )
7
7
8
- import Nirum.Docs ( Block (.. )
9
- , HeadingLevel (.. )
10
- , Inline (.. )
11
- , ItemList (.. )
12
- , ListDelimiter (.. )
13
- , ListType (.. )
14
- , filterReferences
15
- , headingLevelFromInt
16
- , parse
17
- )
8
+ import Nirum.Docs
18
9
19
10
sampleSource :: Text
20
11
sampleSource = [q |
@@ -38,11 +29,18 @@ A [complex *link*][1].
38
29
39
30
|]
40
31
32
+ sampleHeading :: Block
33
+ sampleHeading =
34
+ Heading H1 [" Hello" ]
35
+
41
36
sampleDocument :: Block
42
37
sampleDocument =
43
- Document
44
- [ Heading H1 [" Hello" ]
45
- , Paragraph [" Tight list:" ]
38
+ sampleDocument' (sampleHeading : )
39
+
40
+ sampleDocument' :: ([Block ] -> [Block ]) -> Block
41
+ sampleDocument' adjust =
42
+ (Document . adjust)
43
+ [ Paragraph [" Tight list:" ]
46
44
, List BulletList $ TightItemList [ [" List test" ]
47
45
, [" test2" ]
48
46
]
@@ -91,3 +89,8 @@ spec = do
91
89
, " image"
92
90
, " ."
93
91
]
92
+ specify " trimTitle" $ do
93
+ -- Remove the top-level heading if it exists:
94
+ trimTitle sampleDocument `shouldBe` sampleDocument' id
95
+ -- No-op if there is no top-level heading:
96
+ trimTitle (sampleDocument' id ) `shouldBe` sampleDocument' id
You can’t perform that action at this time.
0 commit comments