on master help sign in
Make sure `elm-doc` actually parses out the comments.
6c0dc8eevancz
compiler/Docs.hs+11−11
@@ -34,24 +34,24 @@ toValue (name, tipe, desc) =
34docParse :: String -> Either String (String, [(String, String, String)])
34docParse :: String -> Either String (String, [(String, String, String)])
35docParse = setupParser $ do
35docParse = setupParser $ do
36 optional freshLine
36 optional freshLine
37− (names, exports) <- option (["Main"],[]) (moduleDef `followedBy` freshLine)
37+ (names, exports) <- option (["Main"],[]) moduleDef
38− info <- many (docs exports <|> try skip <|> end)
38+ info <- many (annotation exports <|> try skip <|> end)
39 return (intercalate "." names, catMaybes info)
39 return (intercalate "." names, catMaybes info)
40 where
40 where
41 skip = manyTill anyChar simpleNewline >> return Nothing
41 skip = manyTill anyChar simpleNewline >> return Nothing
42 end = many1 anyChar >> return Nothing
42 end = many1 anyChar >> return Nothing
43
43
44−docs :: [String] -> IParser (Maybe (String, String, String))
44+annotation :: [String] -> IParser (Maybe (String, String, String))
45−docs exports = export <$> try annotation
45+annotation exports =
46+ try ((\c n t -> export (n,t,c)) <$> comment <*> name <*> tipe)
46 where
47 where
47− tipe comment = tuple <$> name <*> tipe
48+ comment = concatMap clip <$> many lineComment
48− where name = do v <- lowVar <|> parens symOp
49+ clip str = case str of { ' ':rest -> rest ; _ -> str } ++ "\n"
49− whitespace ; hasType ; whitespace ; return v
50− tipe = manyTill anyChar (try (freshLine >> notFollowedBy (string " ")))
51− tuple n t = (n,t,comment)
52
50
53− annotation = tipe =<< option "" (concatMap clip <$> many1 lineComment)
51+ name = do v <- lowVar <|> parens symOp
54− where clip str = case str of { ' ':rest -> rest ; _ -> str } ++ "\n"
52+ whitespace ; hasType ; whitespace ; return v
53+
54+ tipe = manyTill anyChar (try (simpleNewline >> notFollowedBy (string " ")))
55
55
56 export info@(name,_,_) =
56 export info@(name,_,_) =
57 if null exports || name `elem` exports then Just info else Nothing
57 if null exports || name `elem` exports then Just info else Nothing