on master help sign in
cosmetic: add more vertical whitespace
8476fc9Evan Czaplicki
src/Elm/Docs.hs+18
@@ -18,6 +18,10 @@ import qualified Elm.Package as Pkg
18import qualified Reporting.Annotation as A
18import qualified Reporting.Annotation as A
19
19
20
20
21+
22+-- DATA STRUCTURES
23+
24+
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
56
60
57
61
62+
58-- FROM CHECKED DOCS
63-- FROM CHECKED DOCS
59
64
65+
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) =
62 let
68 let
@@ -79,8 +85,10 @@ fromCheckedDocs name (Docs.Docs comment aliases unions values) =
79 (Version $ (Pkg.versionToString Version.version))
85 (Version $ (Pkg.versionToString Version.version))
80
86
81
87
88+
82-- PRETTY JSON
89-- PRETTY JSON
83
90
91+
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 =
99 ]
107 ]
100
108
101
109
110+
102-- JSON for DOCUMENTATION
111-- JSON for DOCUMENTATION
103
112
113+
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)
128
138
129
139
140+
130-- JSON for VERSION
141-- JSON for VERSION
131
142
143+
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)
150
162
151
163
164+
152-- JSON for ALIAS
165-- JSON for ALIAS
153
166
167+
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)
173
187
174
188
189+
175-- JSON for UNION
190-- JSON for UNION
176
191
192+
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)
196
212
197
213
214+
198-- JSON for VALUE
215-- JSON for VALUE
199
216
217+
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)