parent
2f13d27720
commit
9a2736d999
2 changed files with 7 additions and 0 deletions
|
|
@ -400,7 +400,13 @@ proc extractImports(n: PNode; result: PNode) =
|
||||||
for i in 0..<n.safeLen: extractImports(n[i], result)
|
for i in 0..<n.safeLen: extractImports(n[i], result)
|
||||||
|
|
||||||
proc prepareExamples(d: PDoc; n: PNode) =
|
proc prepareExamples(d: PDoc; n: PNode) =
|
||||||
|
|
||||||
|
var docComment = newTree(nkCommentStmt)
|
||||||
|
let loc = d.conf.toFileLineCol(n.info)
|
||||||
|
docComment.comment = "autogenerated by docgen from " & loc
|
||||||
|
|
||||||
var runnableExamples = newTree(nkStmtList,
|
var runnableExamples = newTree(nkStmtList,
|
||||||
|
docComment,
|
||||||
newTree(nkImportStmt, newStrNode(nkStrLit, d.filename)))
|
newTree(nkImportStmt, newStrNode(nkStrLit, d.filename)))
|
||||||
runnableExamples.info = n.info
|
runnableExamples.info = n.info
|
||||||
let imports = newTree(nkStmtList)
|
let imports = newTree(nkStmtList)
|
||||||
|
|
|
||||||
|
|
@ -2046,6 +2046,7 @@ proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||||
of mRunnableExamples:
|
of mRunnableExamples:
|
||||||
if c.config.cmd == cmdDoc and n.len >= 2 and n.lastSon.kind == nkStmtList:
|
if c.config.cmd == cmdDoc and n.len >= 2 and n.lastSon.kind == nkStmtList:
|
||||||
when false:
|
when false:
|
||||||
|
# some of this dead code was moved to `prepareExamples`
|
||||||
if sfMainModule in c.module.flags:
|
if sfMainModule in c.module.flags:
|
||||||
let inp = toFullPath(c.config, c.module.info)
|
let inp = toFullPath(c.config, c.module.info)
|
||||||
if c.runnableExamples == nil:
|
if c.runnableExamples == nil:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue