@@ -7,16 +7,38 @@ module Reporting.Doc
7 , P.hcat, P.hsep, P.indent, P.sep, P.vcat
7 , P.hcat, P.hsep, P.indent, P.sep, P.vcat
8 , P.red, P.cyan, P.magenta, P.green, P.blue, P.black, P.yellow
8 , P.red, P.cyan, P.magenta, P.green, P.blue, P.black, P.yellow
9 , P.dullred, P.dullcyan, P.dullyellow
9 , P.dullred, P.dullcyan, P.dullyellow
11− , fromChars, fromName, fromInt, fromUtf8
11+ , fromChars
12− , toAnsi, toString, toLine
18+ , toString
15− , stack, reflow, commaSep
25+ , commaSep
16− , toSimpleNote, toSimpleHint, toFancyHint
27+ , toSimpleNote
17− , link, fancyLink, reflowLink, makeLink, makeNakedLink
36+ , makeNakedLink
18− , args, moreArgs
39+ , moreArgs
19− , ordinal, intToOrdinal
41+ , intToOrdinal
@@ -26,14 +48,16 @@ import Prelude hiding (cycle)
26import qualified Data.List as List
48import qualified Data.List as List
27import Data.Monoid ((<>))
49import Data.Monoid ((<>))
28import qualified Data.Name as Name
50import qualified Data.Name as Name
29−import qualified Data.Utf8 as Utf8
30import qualified System.Console.ANSI.Types as Ansi
51import qualified System.Console.ANSI.Types as Ansi
31import qualified System.Info as Info
52import qualified System.Info as Info
32import System.IO (Handle)
53import System.IO (Handle)
33import qualified Text.PrettyPrint.ANSI.Leijen as P
54import qualified Text.PrettyPrint.ANSI.Leijen as P
35import qualified Data.Index as Index
56import qualified Data.Index as Index
57+import qualified Elm.Package as Pkg
58+import qualified Elm.Version as V
36import qualified Json.Encode as E
59import qualified Json.Encode as E
60+import qualified Json.String as Json
@@ -50,16 +74,21 @@ fromName name =
50 P.text (Name.toChars name)
74 P.text (Name.toChars name)
77+fromVersion :: V.Version -> P.Doc
79+ P.text (V.toChars vsn)
82+fromPackage :: Pkg.Name -> P.Doc
84+ P.text (Pkg.toChars pkg)
53fromInt :: Int -> P.Doc
87fromInt :: Int -> P.Doc
54fromInt n =
88fromInt n =
55 P.text (show n)
89 P.text (show n)
58−fromUtf8 :: Utf8.String -> P.Doc
60− P.text (Utf8.toChars utf8)
64-- TO STRING
93-- TO STRING
@@ -111,12 +140,21 @@ commaSep conjunction addStyle names =
117toSimpleNote :: String -> P.Doc
146toSimpleNote :: String -> P.Doc
118toSimpleNote message =
147toSimpleNote message =
148+ toFancyNote (map P.text (words message))
151+toFancyNote :: [P.Doc] -> P.Doc
119− P.fillSep ((P.underline "Note" <> ":") : map P.text (words message))
153+ P.fillSep (P.underline "Note" <> ":" : chunks)
122toSimpleHint :: String -> P.Doc
160toSimpleHint :: String -> P.Doc
@@ -148,17 +186,17 @@ fancyLink word before fileName after =
148 (P.underline word <> ":") : before ++ P.text (makeLink fileName) : after
186 (P.underline word <> ":") : before ++ P.text (makeLink fileName) : after
151−makeLink :: String -> String
189+makeLink :: [Char] -> [Char]
152makeLink fileName =
190makeLink fileName =
153− "<https://elm-lang.org/" <> error "TODO V.toString V.compiler" <> "/" <> fileName <> ">"
191+ "<https://elm-lang.org/" <> V.toChars V.compiler <> "/" <> fileName <> ">"
156−makeNakedLink :: String -> String
194+makeNakedLink :: [Char] -> [Char]
157makeNakedLink fileName =
195makeNakedLink fileName =
158− "https://elm-lang.org/" <> error "TODO V.toString V.compiler" <> "/" <> fileName
196+ "https://elm-lang.org/" <> V.toChars V.compiler <> "/" <> fileName
161−reflowLink :: String -> String -> String -> P.Doc
199+reflowLink :: [Char] -> [Char] -> [Char] -> P.Doc
162reflowLink before fileName after =
200reflowLink before fileName after =
163 P.fillSep $
201 P.fillSep $
164 map P.text (words before)
202 map P.text (words before)
@@ -379,7 +417,7 @@ encodeChunks (Style bold underline color) revChunks =
380encodeColor :: Color -> E.Value
418encodeColor :: Color -> E.Value
381encodeColor color =
419encodeColor color =
382− E.string $
420+ E.string $ Json.fromChars $
383 case color of
421 case color of
384 Red -> "red"
422 Red -> "red"
385 RED -> "RED"
423 RED -> "RED"