on 2deedfb help sign in
85 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 ( Help.maybeYouWant (Just "Is it misspelled? Should it be exported?") suggestions
46 )
48 OnlyInExports names ->
49 Report.report
50 "DOCUMENTATION ERROR"
51 Nothing
52 ( "The following exports do not appear in your module documentation: "
53 <> Help.commaSep names
54 )
55 ( text $
56 "All exports must be listed in the module documentation after a @docs keyword.\n"
57 <> "Learn more at <http://package.elm-lang.org/help/documentation-format>"
58 )
60 Duplicates name ->
61 Report.report
62 "DOCUMENTATION ERROR"
63 Nothing
64 ( "There can only be one `" <> name <> "` in your module documentation."
65 )
66 ( text "Remove one of them!"
67 )
69 NoComment name ->
70 Report.report
71 "DOCUMENTATION ERROR"
72 Nothing
73 ("The `" <> name <> "` definition does not have a documentation comment.")
74 ( text "Learn more at <http://package.elm-lang.org/help/documentation-format>"
75 )
77 NoType name ->
78 Report.report
79 "MISSING ANNOTATION"
80 Nothing
81 ("The `" <> name <> "` definition does not have a type annotation.")
82 ( text $
83 "Adding type annotations is best practice and it gives you a chance to name\n"
84 <> "types and type variables so they are as easy as possible to understand!"
85 )