@@ -18,6 +18,10 @@ import qualified Elm.Package as Pkg
18import qualified Reporting.Annotation as A
18import qualified Reporting.Annotation as A
21data Documentation = Documentation
25data Documentation = Documentation
22 { moduleName :: Module.Name
26 { moduleName :: Module.Name
23 , comment :: String
27 , comment :: String
@@ -55,8 +59,10 @@ data Value = Value
55data Version = NonCanonicalTypes | Version String
59data Version = NonCanonicalTypes | Version String
58-- FROM CHECKED DOCS
63-- FROM CHECKED DOCS
60fromCheckedDocs :: Module.Name -> Docs.Checked -> Documentation
66fromCheckedDocs :: Module.Name -> Docs.Checked -> Documentation
61fromCheckedDocs name (Docs.Docs comment aliases unions values) =
67fromCheckedDocs name (Docs.Docs comment aliases unions values) =
@@ -79,8 +85,10 @@ fromCheckedDocs name (Docs.Docs comment aliases unions values) =
79 (Version $ (Pkg.versionToString Version.version))
85 (Version $ (Pkg.versionToString Version.version))
82-- PRETTY JSON
89-- PRETTY JSON
84prettyJson :: (Json.ToJSON a) => a -> BS.ByteString
92prettyJson :: (Json.ToJSON a) => a -> BS.ByteString
85prettyJson value =
93prettyJson value =
86 Json.encodePretty' config value
94 Json.encodePretty' config value
@@ -99,8 +107,10 @@ config =
102-- JSON for DOCUMENTATION
111-- JSON for DOCUMENTATION
104instance Json.ToJSON Documentation where
114instance Json.ToJSON Documentation where
105 toJSON (Documentation name comment aliases types values version) =
115 toJSON (Documentation name comment aliases types values version) =
106 Json.object
116 Json.object
@@ -127,8 +137,10 @@ instance Json.FromJSON Documentation where
127 fail $ "Cannot decode Documentation from: " ++ BS.unpack (Json.encode value)
137 fail $ "Cannot decode Documentation from: " ++ BS.unpack (Json.encode value)
130-- JSON for VERSION
141-- JSON for VERSION
132instance Json.ToJSON Version where
144instance Json.ToJSON Version where
133 toJSON version =
145 toJSON version =
134 case version of
146 case version of
@@ -149,8 +161,10 @@ instance Json.FromJSON Version where
149 fail $ "Cannot decode version of documentation from: " ++ BS.unpack (Json.encode value)
161 fail $ "Cannot decode version of documentation from: " ++ BS.unpack (Json.encode value)
152-- JSON for ALIAS
165-- JSON for ALIAS
154instance Json.ToJSON Alias where
168instance Json.ToJSON Alias where
155 toJSON (Alias name comment args tipe) =
169 toJSON (Alias name comment args tipe) =
156 Json.object
170 Json.object
@@ -172,8 +186,10 @@ instance Json.FromJSON Alias where
172 fail $ "Cannot decode Alias from: " ++ BS.unpack (Json.encode value)
186 fail $ "Cannot decode Alias from: " ++ BS.unpack (Json.encode value)
175-- JSON for UNION
190-- JSON for UNION
177instance Json.ToJSON Union where
193instance Json.ToJSON Union where
178 toJSON (Union name comment args cases) =
194 toJSON (Union name comment args cases) =
179 Json.object
195 Json.object
@@ -195,8 +211,10 @@ instance Json.FromJSON Union where
195 fail $ "Cannot decode Union from: " ++ BS.unpack (Json.encode value)
211 fail $ "Cannot decode Union from: " ++ BS.unpack (Json.encode value)
198-- JSON for VALUE
215-- JSON for VALUE
200instance Json.ToJSON Value where
218instance Json.ToJSON Value where
201 toJSON (Value name comment tipe assocPrec) =
219 toJSON (Value name comment tipe assocPrec) =
202 Json.object (fields ++ possibleFields)
220 Json.object (fields ++ possibleFields)