git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1826 from hdgarrood/relax-documentation-comments

Relax rules for docs comments, fixes #1820

commit14b8aa13caefca7d9fd4b4cbf958029d1b4f2d3b authorGary Burgess <gary.burgess@gmail.com> dateSat 16 Jan 2016, 23:41 (11 years ago) parent20ecf43761106e
1 file changed+13−11
src/Language/PureScript/Docs/Convert/Single.hs+13−11
src/Language/PureScript/Docs/Convert/Single.hs+13−11
@@ -11,6 +11,7 @@ module Language.PureScript.Docs.Convert.Single
1111
1212import Prelude ()
1313import Prelude.Compat
14+import Data.Maybe (catMaybes)
1415
1516import Control.Monad
1617import Control.Category ((>>>))
@@ -200,21 +201,22 @@ convertDeclaration _ _ = Nothing
200201convertComments :: [P.Comment] -> Maybe String
201202convertComments cs = do
202203 let raw = concatMap toLines cs
203− guard (all hasPipe raw && not (null raw))
204− return (go raw)
205− where
206− go = unlines . map stripPipes
204+ let docs = catMaybes (map stripPipe raw)
205+ guard (not (null docs))
206+ pure (unlines docs)
207207
208+ where
208209 toLines (P.LineComment s) = [s]
209210 toLines (P.BlockComment s) = lines s
210211
211− hasPipe s = case dropWhile (== ' ') s of { ('|':_) -> True; _ -> False }
212−
213− stripPipes = dropPipe . dropWhile (== ' ')
214−
215− dropPipe ('|':' ':s) = s
216− dropPipe ('|':s) = s
217− dropPipe s = s
212+ stripPipe s' =
213+ case dropWhile (== ' ') s' of
214+ ('|':' ':s) ->
215+ Just s
216+ ('|':s) ->
217+ Just s
218+ _ ->
219+ Nothing
218220
219221-- | Go through a PureScript module and extract a list of Bookmarks; references
220222-- to data types or values, to be used as a kind of index. These are used for