on e00a3f3 help sign in
87 lines 2.5 kB history raw
1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Error.Docs where
5import Data.Text (Text)
7import qualified Reporting.Report as Report
8import qualified Reporting.Helpers as Help
9import Reporting.Helpers ((<>), text)
13data Error
14 = NoDocs
15 | OnlyInDocs Text [Text]
16 | OnlyInExports [Text]
17 | Duplicates Text
18 | NoComment Text
19 | NoType Text
23-- TO REPORT
26toReport :: Error -> Report.Report
27toReport err =
28 case err of
29 NoDocs ->
30 Report.report
31 "DOCUMENTATION ERROR"
32 Nothing
33 ( "You must have a documentation comment between the module\
34 \ declaration and the imports."
35 )
36 ( text "Learn more at <http://package.elm-lang.org/help/documentation-format>"
37 )
39 OnlyInDocs name suggestions ->
40 Report.report
41 "DOCUMENTATION ERROR"
42 Nothing
43 ("Your module documentation includes `" <> name <> "` which is not exported."
44 )
45 ( text $
46 "Is it misspelled? Should it be exported? "
47 <> Help.maybeYouWant suggestions
48 )
50 OnlyInExports names ->
51 Report.report
52 "DOCUMENTATION ERROR"
53 Nothing
54 ( "The following exports do not appear in your module documentation: "
55 <> Help.commaSep names
56 )
57 ( text $
58 "All exports must be listed in the module documentation after a @docs keyword.\n"
59 <> "Learn more at <http://package.elm-lang.org/help/documentation-format>"
60 )
62 Duplicates name ->
63 Report.report
64 "DOCUMENTATION ERROR"
65 Nothing
66 ( "There can only be one `" <> name <> "` in your module documentation."
67 )
68 ( text "Remove one of them!"
69 )
71 NoComment name ->
72 Report.report
73 "DOCUMENTATION ERROR"
74 Nothing
75 ("The `" <> name <> "` definition does not have a documentation comment.")
76 ( text "Learn more at <http://package.elm-lang.org/help/documentation-format>"
77 )
79 NoType name ->
80 Report.report
81 "MISSING ANNOTATION"
82 Nothing
83 ("The `" <> name <> "` definition does not have a type annotation.")
84 ( text $
85 "Adding type annotations is best practice and it gives you a chance to name\n"
86 <> "types and type variables so they are as easy as possible to understand!"
87 )