Skip to content

Commit

Permalink
use iterator instead of creating a sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
RickBarretto committed Oct 30, 2023
1 parent 783e69d commit 780a1fa
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tools/builderUtils.nims
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,18 @@ func hasFlag*(args: seq[string], cmd: string,

macro implementationToStr(id: typed): string =
id.getImpl.toStrLit

proc getDocs(impl: string): seq[string] =
result = @[]
iterator getDocs(impl: string): string =
var found = false
for line in impl.splitLines():
let cleanline = line.strip()
if cleanline.startsWith("##"):
result.add cleanline[2 .. cleanline.high]
yield cleanline[2 .. cleanline.high]
found = true
# Don't iterate until the end of the implementation,
# Just until the end of the impl's documentation
elif result.len > 0:
return
elif found:
break

template help(ident: typed) =
for line in ident.implementationToStr.getDocs():
Expand Down

0 comments on commit 780a1fa

Please sign in to comment.