git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Relax rules for docs comments, fixes #1820
761106eHarry Garrood
src/Language/PureScript/Docs/Convert/Single.hs+13−11
@@ -11,6 +11,7 @@ module Language.PureScript.Docs.Convert.Single
11
11
12import Prelude ()
12import Prelude ()
13import Prelude.Compat
13import Prelude.Compat
14+import Data.Maybe (catMaybes)
14
15
15import Control.Monad
16import Control.Monad
16import Control.Category ((>>>))
17import Control.Category ((>>>))
@@ -200,21 +201,22 @@ convertDeclaration _ _ = Nothing
200convertComments :: [P.Comment] -> Maybe String
201convertComments :: [P.Comment] -> Maybe String
201convertComments cs = do
202convertComments cs = do
202 let raw = concatMap toLines cs
203 let raw = concatMap toLines cs
204+ let docs = catMaybes (map stripPipe raw)
203− guard (all hasPipe raw && not (null raw))
205+ guard (not (null docs))
204− return (go raw)
206+ pure (unlines docs)
205− where
206− go = unlines . map stripPipes
207
207
208+ where
208 toLines (P.LineComment s) = [s]
209 toLines (P.LineComment s) = [s]
209 toLines (P.BlockComment s) = lines s
210 toLines (P.BlockComment s) = lines s
210
211
212+ stripPipe s' =
211− hasPipe s = case dropWhile (== ' ') s of { ('|':_) -> True; _ -> False }
213+ case dropWhile (== ' ') s' of
212−
214+ ('|':' ':s) ->
213− stripPipes = dropPipe . dropWhile (== ' ')
215+ Just s
214−
216+ ('|':s) ->
215− dropPipe ('|':' ':s) = s
217+ Just s
216− dropPipe ('|':s) = s
218+ _ ->
217− dropPipe s = s
219+ Nothing
218
220
219-- | Go through a PureScript module and extract a list of Bookmarks; references
221-- | Go through a PureScript module and extract a list of Bookmarks; references
220-- to data types or values, to be used as a kind of index. These are used for
222-- to data types or values, to be used as a kind of index. These are used for