@@ -2,17 +2,24 @@
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Error.Docs
3module Reporting.Error.Docs
4 ( Error(..)
4 ( Error(..)
5− , toReport
5+ , SyntaxProblem(..)
10import qualified Data.Name as Name
13import qualified Data.Name as Name
14+import qualified Data.NonEmptyList as NE
16+import Parse.Primitives (Row, Col)
17+import Parse.Symbol (BadOperator(..))
12import qualified Reporting.Annotation as A
18import qualified Reporting.Annotation as A
13import Reporting.Doc ((<>))
19import Reporting.Doc ((<>))
14import qualified Reporting.Doc as D
20import qualified Reporting.Doc as D
15import qualified Reporting.Render.Code as Code
21import qualified Reporting.Render.Code as Code
22+import qualified Reporting.Error.Syntax as E
16import qualified Reporting.Report as Report
23import qualified Reporting.Report as Report
@@ -20,36 +27,56 @@ import qualified Reporting.Report as Report
21 = NoDocs A.Region
28 = NoDocs A.Region
22 | ImplicitExposing A.Region
29 | ImplicitExposing A.Region
30+ | SyntaxProblem SyntaxProblem
31+ | NameProblems (NE.List NameProblem)
32+ | DefProblems (NE.List DefProblem)
37+ | OpBad BadOperator Row Col
39+ | Space E.Space Row Col
23− | Duplicate Name.Name A.Region A.Region
45+ = NameDuplicate Name.Name A.Region A.Region
24− | OnlyInDocs Name.Name A.Region
46+ | NameOnlyInDocs Name.Name A.Region
25− | OnlyInExports Name.Name A.Region
47+ | NameOnlyInExports Name.Name A.Region
26− | NoComment Name.Name A.Region
51+ = NoComment Name.Name A.Region
27 | NoAnnotation Name.Name A.Region
52 | NoAnnotation Name.Name A.Region
31−-- TO REPORT
56+-- TO REPORTS
34−toReport :: Code.Source -> Error -> Report.Report
59+toReports :: Code.Source -> Error -> NE.List Report.Report
35−toReport source err =
60+toReports source err =
36 case err of
61 case err of
37 NoDocs region ->
62 NoDocs region ->
38 Report.Report "NO DOCS" region [] $
64 Report.Report "NO DOCS" region [] $
39− D.stack
65+ Code.toSnippet source region Nothing
41 D.reflow $
67 D.reflow $
42 "You must have a documentation comment between the module\
68 "You must have a documentation comment between the module\
43 \ declaration and the imports."
69 \ declaration and the imports."
46 "Learn more at <http://package.elm-lang.org/help/documentation-format>"
72 "Learn more at <http://package.elm-lang.org/help/documentation-format>"
49 ImplicitExposing region ->
75 ImplicitExposing region ->
50 Report.Report "IMPLICIT EXPOSING" region [] $
77 Report.Report "IMPLICIT EXPOSING" region [] $
51− D.stack
78+ Code.toSnippet source region Nothing
53 D.reflow $
80 D.reflow $
54 "I need you to be explicit about what this module exposes:"
81 "I need you to be explicit about what this module exposes:"
@@ -59,9 +86,22 @@ toReport source err =
59 \ to be explicit about this is a way of adding another quality check before\
86 \ to be explicit about this is a way of adding another quality check before\
60 \ code gets published. So as you write out the public API, ask yourself if\
87 \ code gets published. So as you write out the public API, ask yourself if\
61 \ it will be easy to understand as people read the documentation!"
88 \ it will be easy to understand as people read the documentation!"
92+ error "TODO SyntaxProblem in docs"
94+ NameProblems problems ->
95+ fmap (toNameProblemReport source) problems
97+ DefProblems problems ->
98+ fmap (toDefProblemReport source) problems
101+toNameProblemReport :: Code.Source -> NameProblem -> Report.Report
102+toNameProblemReport source problem =
64− Duplicate name r1 r2 ->
104+ NameDuplicate name r1 r2 ->
65 Report.Report "DUPLICATE DOCS" r2 [] $
105 Report.Report "DUPLICATE DOCS" r2 [] $
66 Code.toPair source r1 r2
106 Code.toPair source r1 r2
@@ -81,7 +121,7 @@ toReport source err =
81 "Remove one of them!"
121 "Remove one of them!"
84− OnlyInDocs name region ->
124+ NameOnlyInDocs name region ->
85 Report.Report "DOCS MISTAKE" region [] $
125 Report.Report "DOCS MISTAKE" region [] $
86 Code.toSnippet source region Nothing
126 Code.toSnippet source region Nothing
@@ -94,7 +134,7 @@ toReport source err =
94 <> Name.toChars name <> "` and forgot to delete it here?"
134 <> Name.toChars name <> "` and forgot to delete it here?"
97− OnlyInExports name region ->
137+ NameOnlyInExports name region ->
98 Report.Report "DOCS MISTAKE" region [] $
138 Report.Report "DOCS MISTAKE" region [] $
99 Code.toSnippet source region Nothing
139 Code.toSnippet source region Nothing
@@ -110,6 +150,10 @@ toReport source err =
154+toDefProblemReport :: Code.Source -> DefProblem -> Report.Report
155+toDefProblemReport source problem =
113 NoComment name region ->
157 NoComment name region ->
114 Report.Report "NO DOCS" region [] $
158 Report.Report "NO DOCS" region [] $
115 Code.toSnippet source region Nothing
159 Code.toSnippet source region Nothing