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