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