on 1925e31 help sign in
77 lines 2.2 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 | NoComment Text
18 | NoType Text
22-- TO REPORT
25toReport :: Error -> Report.Report
26toReport err =
27 case err of
28 NoDocs ->
29 Report.report
30 "DOCUMENTATION ERROR"
31 Nothing
32 ( "You must have a documentation comment between the module\
33 \ declaration and the imports."
34 )
35 ( text "Learn more at <http://package.elm-lang.org/help/documentation-format>"
36 )
38 OnlyInDocs name suggestions ->
39 Report.report
40 "DOCUMENTATION ERROR"
41 Nothing
42 ("Your module documentation includes `" <> name <> "` which is not exported."
43 )
44 ( text $
45 "Is it misspelled? Should it be exported? "
46 <> Help.maybeYouWant suggestions
47 )
49 OnlyInExports names ->
50 Report.report
51 "DOCUMENTATION ERROR"
52 Nothing
53 ( "The following exports do not appear in your module documentation: "
54 <> Help.commaSep names
55 )
56 ( text $
57 "All exports must be listed in the module documentation after a @docs keyword.\n"
58 <> "Learn more at <http://package.elm-lang.org/help/documentation-format>"
59 )
61 NoComment name ->
62 Report.report
63 "DOCUMENTATION ERROR"
64 Nothing
65 ("The value `" <> name <> "` does not have a documentation comment.")
66 ( text "Learn more at <http://package.elm-lang.org/help/documentation-format>"
67 )
69 NoType name ->
70 Report.report
71 "MISSING ANNOTATION"
72 Nothing
73 ("The value `" <> name <> "` does not have a type annotation.")
74 ( text $
75 "Adding type annotations is best practice and it gives you a chance to name\n"
76 <> "types and type variables so they are as easy as possible to understand!"
77 )