on 17618de help sign in
74 lines 2.2 kB history raw
1{-# OPTIONS_GHC -Wall #-}
2module Reporting.Error.Docs where
4import Text.PrettyPrint.ANSI.Leijen (text)
6import qualified Reporting.Error.Helpers as Help
7import qualified Reporting.Report as Report
11data Error
12 = NoDocs
13 | OnlyInDocs String [String]
14 | OnlyInExports [String]
15 | NoComment String
16 | NoType String
20-- TO REPORT
23toReport :: Error -> Report.Report
24toReport err =
25 case err of
26 NoDocs ->
27 Report.report
28 "DOCUMENTATION ERROR"
29 Nothing
30 ( "You must have a documentation comment between the module declaration and the\n"
31 ++ "imports."
32 )
33 ( text "Learn more at <http://package.elm-lang.org/help/documentation-format>"
34 )
36 OnlyInDocs name suggestions ->
37 Report.report
38 "DOCUMENTATION ERROR"
39 Nothing
40 ("Your module documentation includes `" ++ name ++ "` which is not exported.")
41 ( text $
42 "Is it misspelled? Should it be exported? "
43 ++ Help.maybeYouWant suggestions
44 )
46 OnlyInExports names ->
47 Report.report
48 "DOCUMENTATION ERROR"
49 Nothing
50 ( "The following exports do not appear in your module documentation:\n"
51 ++ concatMap ("\n " ++) names
52 )
53 ( text $
54 "All exports must be listed in the module documentation after a @docs keyword.\n"
55 ++ "Learn more at <http://package.elm-lang.org/help/documentation-format>"
56 )
58 NoComment name ->
59 Report.report
60 "DOCUMENTATION ERROR"
61 Nothing
62 ("The value `" ++ name ++ "` does not have a documentation comment.")
63 ( text "Learn more at <http://package.elm-lang.org/help/documentation-format>"
64 )
66 NoType name ->
67 Report.report
68 "MISSING ANNOTATION"
69 Nothing
70 ("The value `" ++ name ++ "` does not have a type annotation.")
71 ( text $
72 "Adding type annotations is best practice and it gives you a chance to name\n"
73 ++ "types and type variables so they are as easy as possible to understand!"
74 )