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