support same-line doc comments in routines (#18595)

* support same-line comments in routines
* remove assert as per review comment
This commit is contained in:
Timothee Cour
2021-07-27 10:50:59 -07:00
committed by GitHub
parent 4920b06973
commit 8d2f6bba3a
6 changed files with 205 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ from strutils import endsWith, contains, strip
from std/macros import newLit
macro deb(a): string = newLit a.repr.strip
macro debTyped(a: typed): string = newLit a.repr.strip
template main() =
doAssert repr({3,5}) == "{3, 5}"
@@ -243,5 +244,31 @@ template bar(): untyped =
echo "baz"
4)"""
block: # one liner doc comments
let a1 = deb:
func fn1(): int = 1 ## comment
func fn2(): int = 1
## comment
let a2 = debTyped:
func fn1(): int = 1 ## comment
func fn2(): int = 1
## comment
doAssert a1 == """
func fn1(): int =
## comment
1
func fn2(): int =
## comment
1"""
doAssert a2 == """
func fn1(): int =
## comment
result = 1
func fn2(): int =
## comment
result = 1"""
static: main()
main()