0 | module Idris.Doc.Annotations
 1 |
 2 | import Core.FC
 3 | import Core.Metadata
 4 | import Core.Name
 5 |
 6 | import Idris.Pretty
 7 |
 8 | %default total
 9 |
10 | public export
11 | data IdrisDocAnn
12 |   = Header
13 |   | Deprecation
14 |   | Declarations
15 |   | Decl Name FC
16 |   | DocStringBody
17 |   | UserDocString
18 |   | Syntax IdrisSyntax
19 |
20 | export
21 | -- TODO: how can we deal with bold & so on?
22 | docToDecoration : IdrisDocAnn -> Maybe Decoration
23 | docToDecoration (Syntax syn) = syntaxToDecoration syn
24 | docToDecoration _ = Nothing
25 |
26 | export
27 | styleAnn : IdrisDocAnn -> AnsiStyle
28 | styleAnn Header        = underline
29 | styleAnn Deprecation   = bold
30 | styleAnn Declarations  = []
31 | styleAnn (Decl {})     = []
32 | styleAnn DocStringBody = []
33 | styleAnn UserDocString = []
34 | styleAnn (Syntax syn)  = syntaxAnn syn
35 |
36 | export
37 | tCon : Name -> Doc IdrisDocAnn -> Doc IdrisDocAnn
38 | tCon n = annotate (Syntax $ TCon (Just n))
39 |
40 | export
41 | dCon : Name -> Doc IdrisDocAnn -> Doc IdrisDocAnn
42 | dCon n = annotate (Syntax $ DCon (Just n))
43 |
44 | export
45 | fun : Name -> Doc IdrisDocAnn -> Doc IdrisDocAnn
46 | fun n = annotate (Syntax $ Fun n)
47 |
48 | export
49 | header : Doc IdrisDocAnn -> Doc IdrisDocAnn
50 | header d = annotate Header d <+> colon
51 |