the documentation generator now supports system.runnableExamples
This commit is contained in:
parent
c1782fac21
commit
8d1a5dc8e7
9 changed files with 132 additions and 58 deletions
|
|
@ -1847,6 +1847,17 @@ proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
|||
analyseIfAddressTakenInCall(c, result)
|
||||
if callee.magic != mNone:
|
||||
result = magicsAfterOverloadResolution(c, result, flags)
|
||||
of mRunnableExamples:
|
||||
if gCmd == cmdDoc and n.len >= 2 and n.lastSon.kind == nkStmtList:
|
||||
if sfMainModule in c.module.flags:
|
||||
let inp = toFullPath(c.module.info)
|
||||
if c.runnableExamples == nil:
|
||||
c.runnableExamples = newTree(nkStmtList,
|
||||
newTree(nkImportStmt, newStrNode(nkStrLit, expandFilename(inp))))
|
||||
c.runnableExamples.add newTree(nkBlockStmt, emptyNode, n.lastSon)
|
||||
result = n
|
||||
else:
|
||||
result = emptyNode
|
||||
else:
|
||||
result = semDirectOp(c, n, flags)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue