Skip to content

Commit 5c4ac75

Browse files
committed
Document emitted function with original name and location
To make debugging easier.
1 parent 61070fa commit 5c4ac75

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Main.idr

+13-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ debug = dartStringDoc . show
150150
comment : String -> Doc
151151
comment c = "/* " <+> text c <+> "*/"
152152

153+
surroundWith : Doc -> Doc -> Doc
154+
surroundWith s d = s <+> d <+> s
155+
156+
mdCode : Doc -> Doc
157+
mdCode = surroundWith "`"
158+
159+
mdItalic : Doc -> Doc
160+
mdItalic = surroundWith "_"
161+
162+
docCommentFor : FC -> Name -> Doc
163+
docCommentFor fc n = "/// " <+> mdCode (shown n) <+> " from " <+> mdItalic (shown fc) <+> "." <+> line
164+
153165
argList : List Doc -> Doc
154166
argList [] = text "()"
155167
argList args = paren (commaSep args <+> ",")
@@ -939,7 +951,7 @@ mutual
939951
-> Core Doc
940952
dartStatement s = case s of
941953
FunDecl fc n ps body =>
942-
pure (line <+> dartName n <+> !(dartLambda ps body))
954+
pure (line <+> docCommentFor fc n <+> dartName n <+> !(dartLambda ps body))
943955
ForeignDecl fc n ss args ret =>
944956
pure (line <+> !(foreignDecl n ss args ret))
945957
SwitchStatement e cases@((IEConstant (BI _), _) :: _) maybeDefault =>

0 commit comments

Comments
 (0)