on master help sign in
Begin upgrade of Docs code from String to Text
fe4ad5aEvan Czaplicki
src/Docs/AST.hs+14−12
@@ -1,6 +1,7 @@
1module Docs.AST where
1module Docs.AST where
2
2
3import qualified Data.Map as Map
3import qualified Data.Map as Map
4+import Data.Text (Text)
4
5
5import qualified Elm.Compiler.Type as Type
6import qualified Elm.Compiler.Type as Type
6import qualified Reporting.Annotation as A
7import qualified Reporting.Annotation as A
@@ -8,11 +9,12 @@ import qualified Reporting.Annotation as A
8
9
9-- FULL DOCUMENTATION
10-- FULL DOCUMENTATION
10
11
11−data Docs t = Docs
12+data Docs t =
13+ Docs
12− { comment :: String
14+ { comment :: Text
13− , aliases :: Map.Map String (A.Located Alias)
15+ , aliases :: Map.Map Text (A.Located Alias)
14− , types :: Map.Map String (A.Located Union)
16+ , types :: Map.Map Text (A.Located Union)
15− , values :: Map.Map String (A.Located (Value t))
17+ , values :: Map.Map Text (A.Located (Value t))
16 }
18 }
17
19
18
20
@@ -24,21 +26,21 @@ type Checked = Docs Type.Type
24-- VALUE DOCUMENTATION
26-- VALUE DOCUMENTATION
25
27
26data Alias = Alias
28data Alias = Alias
27− { aliasComment :: Maybe String
29+ { aliasComment :: Maybe Text
28− , aliasArgs :: [String]
30+ , aliasArgs :: [Text]
29 , aliasType :: Type.Type
31 , aliasType :: Type.Type
30 }
32 }
31
33
32
34
33data Union = Union
35data Union = Union
34− { unionComment :: Maybe String
36+ { unionComment :: Maybe Text
35− , unionArgs :: [String]
37+ , unionArgs :: [Text]
36− , unionCases :: [(String, [Type.Type])]
38+ , unionCases :: [(Text, [Type.Type])]
37 }
39 }
38
40
39
41
40data Value t = Value
42data Value t = Value
41− { valueComment :: Maybe String
43+ { valueComment :: Maybe Text
42 , valueType :: t
44 , valueType :: t
43− , valueAssocPrec :: Maybe (String,Int)
45+ , valueAssocPrec :: Maybe (Text,Int)
44 }
46 }
src/Docs/Centralize.hs+8−7
@@ -3,6 +3,7 @@ module Docs.Centralize (centralize) where
3import Control.Arrow (second)
3import Control.Arrow (second)
4import qualified Data.Map as Map
4import qualified Data.Map as Map
5import qualified Data.Maybe as Maybe
5import qualified Data.Maybe as Maybe
6+import Data.Text (Text)
6
7
7import qualified AST.Declaration as D
8import qualified AST.Declaration as D
8import qualified AST.Expression.Canonical as Canonical
9import qualified AST.Expression.Canonical as Canonical
@@ -18,7 +19,7 @@ import qualified Reporting.Annotation as A
18-- CENTRALIZE DOCUMENTATION
19-- CENTRALIZE DOCUMENTATION
19
20
20
21
21−centralize :: D.Canonical -> String -> Docs.Centralized
22+centralize :: D.Canonical -> Text -> Docs.Centralized
22centralize (D.Decls defs unions aliases infixes) comment =
23centralize (D.Decls defs unions aliases infixes) comment =
23 let
24 let
24 infixDict =
25 infixDict =
@@ -36,9 +37,9 @@ centralize (D.Decls defs unions aliases infixes) comment =
36
37
37
38
38defToEntry
39defToEntry
39− :: Map.Map String (String, Int)
40+ :: Map.Map Text (Text, Int)
40 -> A.Commented Canonical.Def
41 -> A.Commented Canonical.Def
41− -> Maybe (String, A.Located (Docs.Value (Maybe Type.Type)))
42+ -> Maybe (Text, A.Located (Docs.Value (Maybe Type.Type)))
42defToEntry infixDict (A.A (_, maybeComment) (Canonical.Def _ pattern _ maybeType)) =
43defToEntry infixDict (A.A (_, maybeComment) (Canonical.Def _ pattern _ maybeType)) =
43 case pattern of
44 case pattern of
44 A.A subregion (Pattern.Var name) ->
45 A.A subregion (Pattern.Var name) ->
@@ -55,7 +56,7 @@ defToEntry infixDict (A.A (_, maybeComment) (Canonical.Def _ pattern _ maybeType
55 Nothing
56 Nothing
56
57
57
58
58−unionToEntry :: A.Commented (D.Union Type.Canonical) -> (String, A.Located Docs.Union)
59+unionToEntry :: A.Commented (D.Union Type.Canonical) -> (Text, A.Located Docs.Union)
59unionToEntry (A.A (region, maybeComment) (D.Type name args ctors)) =
60unionToEntry (A.A (region, maybeComment) (D.Type name args ctors)) =
60 let
61 let
61 ctors' =
62 ctors' =
@@ -64,17 +65,17 @@ unionToEntry (A.A (region, maybeComment) (D.Type name args ctors)) =
64 (name, A.A region (Docs.Union maybeComment args ctors'))
65 (name, A.A region (Docs.Union maybeComment args ctors'))
65
66
66
67
67−aliasToEntry :: A.Commented (D.Alias Type.Canonical) -> (String, A.Located Docs.Alias)
68+aliasToEntry :: A.Commented (D.Alias Type.Canonical) -> (Text, A.Located Docs.Alias)
68aliasToEntry (A.A (region, maybeComment) (D.Type name args tipe)) =
69aliasToEntry (A.A (region, maybeComment) (D.Type name args tipe)) =
69 ( name
70 ( name
70 , A.A region (Docs.Alias maybeComment args (Extract.extract tipe))
71 , A.A region (Docs.Alias maybeComment args (Extract.extract tipe))
71 )
72 )
72
73
73
74
74−infixToEntry :: D.Infix -> (String, (String, Int))
75+infixToEntry :: D.Infix -> (Text, (Text, Int))
75infixToEntry (D.Infix name assoc precedence) =
76infixToEntry (D.Infix name assoc precedence) =
76 let
77 let
77 fixity =
78 fixity =
78− (D.assocToString assoc, precedence)
79+ (D.assocToText assoc, precedence)
79 in
80 in
80 ( name, fixity )
81 ( name, fixity )
src/Docs/Check.hs+14−17
@@ -1,25 +1,19 @@
1module Docs.Check (Result, check) where
1module Docs.Check (Result, check) where
2
2
3−import qualified Data.List as List
3+--import qualified Data.List as List
4−import qualified Data.Map as Map
4+--import qualified Data.Map as Map
5−import qualified Data.Set as Set
5+--import qualified Data.Set as Set
6−import qualified Data.Traversable as T
6+--import qualified Data.Traversable as T
7−import Text.Parsec ((<|>), choice, many, setPosition, string)
8−import Text.Parsec.Pos (newPos)
9
7
10import qualified AST.Variable as Var
8import qualified AST.Variable as Var
11import qualified Docs.AST as Docs
9import qualified Docs.AST as Docs
12−import qualified Elm.Compiler.Type as Type
10+--import qualified Elm.Compiler.Type as Type
13−import Elm.Utils ((|>))
11+--import Elm.Utils ((|>))
14−import Parse.Binop (infixOp)
15−import Parse.Helpers
12+--import Parse.Helpers
16− ( addLocation, anyUntil, commaSep1, parens, parse, simpleNewline
17− , var, whitespace
18− )
19import qualified Reporting.Annotation as A
13import qualified Reporting.Annotation as A
20import qualified Reporting.Error.Docs as Error
14import qualified Reporting.Error.Docs as Error
21−import qualified Reporting.Error.Helpers as Error (nearbyNames)
15+--import qualified Reporting.Error.Helpers as Error (nearbyNames)
22−import qualified Reporting.Region as R
16+--import qualified Reporting.Region as R
23import qualified Reporting.Result as R
17import qualified Reporting.Result as R
24
18
25
19
@@ -30,8 +24,10 @@ type Result w a =
30
24
31-- CHECK DOCUMENTATION
25-- CHECK DOCUMENTATION
32
26
33−check :: [Var.Value] -> A.Located (Maybe Docs.Centralized) -> Result w Docs.Checked
27+check :: [Var.Value] -> Maybe (A.Located Docs.Centralized) -> Result w Docs.Checked
34−check exports (A.A region maybeDocs) =
28+check exports maybeDocs =
29+ R.ok (error "TODO check docs" exports maybeDocs)
30+{-
35 case maybeDocs of
31 case maybeDocs of
36 Nothing ->
32 Nothing ->
37 R.throw region Error.NoDocs
33 R.throw region Error.NoDocs
@@ -180,3 +176,4 @@ valueName value =
180 Var.Value name -> name
176 Var.Value name -> name
181 Var.Alias name -> name
177 Var.Alias name -> name
182 Var.Union name _ -> name
178 Var.Union name _ -> name
179+-}