mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 22:35:24 +00:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user