[https://github.com/nim-lang/Nim/pull/9228](https://github.com/nim-lang/Nim/pull/9228)
 (nim doc can run code blocks) introduced this feature: 
    
    
    proc foo*() =
      ## Does something unexpected.
      ##
      ## .. code-block::
      ##    :test:
      ##    foo()
      ##
      ## Don't run it!
      raise newException(Exception, "boo!")
    
    
    Run

Isn't that redundant with runnableExamples? When should one be preferred over 
the other?

If we're allowing runnable code embedded inside documentation, I've argued we 
might as well use the friendlier, shorter syntax runnableExamples:
    
    
    proc foo*() =
      ## Does something unexpected.
      ##
      ## runnableExamples:
      ##    foo()
      ##
      ## Don't run it!
      raise newException(Exception, "boo!")
    
    
    Run

which also allows one-liners:
    
    
    proc foo*() =
      ## Does something unexpected.
      ## runnableExamples: foo()
      ## Don't run it!
      raise newException(Exception, "boo!")
    
    
    Run

## links

  * note: would also address concerns from 
[https://forum.nim-lang.org/t/4279](https://forum.nim-lang.org/t/4279)


Reply via email to