@@ -31,20 +31,24 @@ data Flags = Flags
3131 { files :: [FilePath] }
3232 deriving (Data,Typeable,Show,Eq)
3333
34+defaultFlags :: Flags
3435defaultFlags = Flags
3536 { files = def &= args &= typ "FILES"
3637 } &= help "Generate documentation for Elm"
3738 &= summary ("Generate documentation for Elm, (c) Evan Czaplicki")
3839
40+main :: IO ()
3941main = do
4042 flags <- cmdArgs defaultFlags
41− mapM parseFile (files flags)
43+ mapM_ parseFile (files flags)
4244
45+config :: Config
4346config = Config { confIndent = 2, confCompare = keyOrder keys }
4447 where
4548 keys = ["tag","name","document","comment","raw","aliases","datatypes"
4649 ,"values","typeVariables","type","constructors"]
4750
51+parseFile :: FilePath -> IO ()
4852parseFile path = do
4953 source <- readFile path
5054 case iParse docs source of
@@ -70,6 +74,7 @@ docComment = do
7074 let reversed = dropWhile (`elem` " \n\r") . drop 2 $ reverse contents
7175 return $ dropWhile (==' ') (reverse reversed)
7276
77+moduleDocs :: IParser (String, [String], String)
7378moduleDocs = do
7479 optional freshLine
7580 (names,exports) <- moduleDef
@@ -152,7 +157,7 @@ instance ToJSON T.Type where
152157 toJSON tipe =
153158 object $
154159 case tipe of
155− T.Lambda t1 t2 ->
160+ T.Lambda _ _ ->
156161 let tipes = T.collectLambdas tipe in
157162 [ "tag" .= ("function" :: Text.Text)
158163 , "args" .= toJSON (init tipes)
@@ -176,6 +181,7 @@ instance ToJSON T.Type where
176181 , "extension" .= toJSON ext
177182 ]
178183
184+ctorToJson :: T.Type -> (String, [T.Type]) -> Value
179185ctorToJson tipe (ctor, tipes) =
180186 object [ "name" .= ctor
181187 , "type" .= foldr T.Lambda tipe tipes ]