@@ -18,6 +18,10 @@ import qualified Elm.Package as Pkg
1818import qualified Reporting.Annotation as A
1919
2020
21+
22+-- DATA STRUCTURES
23+
24+
2125data Documentation = Documentation
2226 { moduleName :: Module.Name
2327 , comment :: String
@@ -55,8 +59,10 @@ data Value = Value
5559data Version = NonCanonicalTypes | Version String
5660
5761
62+
5863-- FROM CHECKED DOCS
5964
65+
6066fromCheckedDocs :: Module.Name -> Docs.Checked -> Documentation
6167fromCheckedDocs name (Docs.Docs comment aliases unions values) =
6268 let
@@ -79,8 +85,10 @@ fromCheckedDocs name (Docs.Docs comment aliases unions values) =
7985 (Version $ (Pkg.versionToString Version.version))
8086
8187
88+
8289-- PRETTY JSON
8390
91+
8492prettyJson :: (Json.ToJSON a) => a -> BS.ByteString
8593prettyJson value =
8694 Json.encodePretty' config value
@@ -99,8 +107,10 @@ config =
99107 ]
100108
101109
110+
102111-- JSON for DOCUMENTATION
103112
113+
104114instance Json.ToJSON Documentation where
105115 toJSON (Documentation name comment aliases types values version) =
106116 Json.object
@@ -127,8 +137,10 @@ instance Json.FromJSON Documentation where
127137 fail $ "Cannot decode Documentation from: " ++ BS.unpack (Json.encode value)
128138
129139
140+
130141-- JSON for VERSION
131142
143+
132144instance Json.ToJSON Version where
133145 toJSON version =
134146 case version of
@@ -149,8 +161,10 @@ instance Json.FromJSON Version where
149161 fail $ "Cannot decode version of documentation from: " ++ BS.unpack (Json.encode value)
150162
151163
164+
152165-- JSON for ALIAS
153166
167+
154168instance Json.ToJSON Alias where
155169 toJSON (Alias name comment args tipe) =
156170 Json.object
@@ -172,8 +186,10 @@ instance Json.FromJSON Alias where
172186 fail $ "Cannot decode Alias from: " ++ BS.unpack (Json.encode value)
173187
174188
189+
175190-- JSON for UNION
176191
192+
177193instance Json.ToJSON Union where
178194 toJSON (Union name comment args cases) =
179195 Json.object
@@ -195,8 +211,10 @@ instance Json.FromJSON Union where
195211 fail $ "Cannot decode Union from: " ++ BS.unpack (Json.encode value)
196212
197213
214+
198215-- JSON for VALUE
199216
217+
200218instance Json.ToJSON Value where
201219 toJSON (Value name comment tipe assocPrec) =
202220 Json.object (fields ++ possibleFields)