Hello,
I'd like to make an assert that appends the conditions to the documentation comments.
Something like:
proc fn(x: float) =
## Bla, bla, bla.
##
## Preconditions:
assertDoc x >= 0.0
assertDoc x < 100.0
...
Result:
Bla, bla, bla.
Preconditions:
x >= 0.0
x < 100.0
Is possible to do this in Nim?
Thank you.
this would be entirely covered by https://github.com/nim-lang/RFCs/issues/270, both pre-conditions and post-conditions:
proc sleep(t: int) {.requires t>=0.} = ...
would render the pragma in the doc comment AND (when checks are enabled) would check the condition@xigoi
Ah, good to know it, I'll try to do it.
@timothee
Great, that would be a nice solution.
Thank you.