1module Docs.Centralize (centralize) where
3import Control.Arrow (second)
4import qualified Data.Map as Map
5import qualified Data.Maybe as Maybe
7import qualified AST.Declaration as D
8import qualified AST.Expression.Canonical as Canonical
9import qualified AST.Pattern as Pattern
10import qualified AST.Type as Type
11import qualified Docs.AST as Docs
12import qualified Elm.Compiler.Type as Type
13import qualified Elm.Compiler.Type.Extract as Extract
14import qualified Reporting.Annotation as A
18-- CENTRALIZE DOCUMENTATION
21centralize :: D.Canonical -> String -> Docs.Centralized
22centralize (D.Decls defs unions aliases infixes) comment =
25 Map.fromList (map infixToEntry infixes)
29 (Map.fromList (map aliasToEntry aliases))
30 (Map.fromList (map unionToEntry unions))
31 (Map.fromList (Maybe.mapMaybe (defToEntry infixDict) defs))
35-- CONVERSION TO DOC ENTRIES
39 :: Map.Map String (String, Int)
40 -> A.Commented Canonical.Def
41 -> Maybe (String, A.Located (Docs.Value (Maybe Type.Type)))
42defToEntry infixDict (A.A (_, maybeComment) (Canonical.Def _ pattern _ maybeType)) =
44 A.A subregion (Pattern.Var name) ->
49 (fmap (Extract.toAliasedType . A.drop) maybeType)
50 (Map.lookup name infixDict)
52 Just (name, A.A subregion value)
58unionToEntry :: A.Commented (D.Union Type.Canonical) -> (String, A.Located Docs.Union)
59unionToEntry (A.A (region, maybeComment) (D.Type name args ctors)) =
62 map (second (map Extract.toAliasedType)) ctors
64 (name, A.A region (Docs.Union maybeComment args ctors'))
67aliasToEntry :: A.Commented (D.Alias Type.Canonical) -> (String, A.Located Docs.Alias)
68aliasToEntry (A.A (region, maybeComment) (D.Type name args tipe)) =
70 , A.A region (Docs.Alias maybeComment args (Extract.toAliasedType tipe))
74infixToEntry :: D.Infix -> (String, (String, Int))
75infixToEntry (D.Infix name assoc precedence) =
78 (D.assocToString assoc, precedence)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list