on 84bfb4e help sign in
61 lines 2.5 kB history raw
1{-# OPTIONS_GHC -Wall #-}
2module Reporting.Error.Docs where
4import qualified Reporting.Error.Helpers as Help
5import qualified Reporting.Report as Report
8data Error
9 = NoDocs
10 | OnlyInDocs String [String]
11 | OnlyInExports [String]
12 | NoComment String
13 | NoType String
16-- TO REPORT
18toReport :: Error -> Report.Report
19toReport err =
20 case err of
21 NoDocs ->
22 Report.simple "DOCUMENTATION ERROR"
23 ( "You must have a documentation comment between the module declaration and the\n"
24 ++ "imports."
25 )
26 "Learn how at <http://package.elm-lang.org/help/documentation-format>"
28 OnlyInDocs name suggestions ->
29 Report.simple "DOCUMENTATION ERROR"
30 ("Your module documentation includes `" ++ name ++ "` which is not exported.")
31 ("Is it misspelled? Should it be exported? " ++ Help.maybeYouWant suggestions)
33 OnlyInExports names ->
34 Report.simple
35 "DOCUMENTATION ERROR"
36 ( "The following exports do not appear in your module documentation:\n"
37 ++ concatMap ("\n " ++) names
38 )
39 ( "All exports must be listed in the module documentation after a @docs keyword.\n"
40 ++ "Learn how at <http://package.elm-lang.org/help/documentation-format>"
41 )
43 NoComment name ->
44 Report.simple "DOCUMENTATION ERROR"
45 ("The value `" ++ name ++ "` does not have a documentation comment.")
46 ( "Documentation comments start with {-| and end with -}. They should provide a\n"
47 ++ "clear description of how they work, and ideally a small code example. This is\n"
48 ++ "extremely valuable for users checking out your package!\n\n"
49 ++ "If you think the docs are clearer without any words, you can use an empty\n"
50 ++ "comment {-|-} which should be used sparingly. Maybe you have a section of 20\n"
51 ++ "values all with the exact same type. The docs may read better if they are all\n"
52 ++ "described in one place.\n\n"
53 ++ "Learn more at <http://package.elm-lang.org/help/documentation-format>"
54 )
56 NoType name ->
57 Report.simple "MISSING ANNOTATION"
58 ("The value `" ++ name ++ "` does not have a type annotation.")
59 ( "Adding type annotations is best practice and it gives you a chance to name\n"
60 ++ "types and type variables so they are as easy as possible to understand!"
61 )