docgen: fixes #9169 [backport]
This commit is contained in:
parent
895ac5bec4
commit
eb03684c57
1 changed files with 15 additions and 24 deletions
|
|
@ -247,18 +247,30 @@ proc genComment(d: PDoc, n: PNode): string =
|
||||||
toLinenumber(n.info), toColumn(n.info),
|
toLinenumber(n.info), toColumn(n.info),
|
||||||
dummyHasToc, d.options, d.conf), result)
|
dummyHasToc, d.options, d.conf), result)
|
||||||
|
|
||||||
proc genRecComment(d: PDoc, n: PNode): Rope =
|
proc genRecCommentAux(d: PDoc, n: PNode): Rope =
|
||||||
if n == nil: return nil
|
if n == nil: return nil
|
||||||
result = genComment(d, n).rope
|
result = genComment(d, n).rope
|
||||||
if result == nil:
|
if result == nil:
|
||||||
if n.kind notin {nkEmpty..nkNilLit, nkEnumTy, nkTupleTy}:
|
if n.kind in {nkStmtList, nkStmtListExpr, nkTypeDef, nkConstDef,
|
||||||
|
nkObjectTy, nkRefTy, nkPtrTy}:
|
||||||
|
# notin {nkEmpty..nkNilLit, nkEnumTy, nkTupleTy}:
|
||||||
for i in countup(0, len(n)-1):
|
for i in countup(0, len(n)-1):
|
||||||
result = genRecComment(d, n.sons[i])
|
result = genRecCommentAux(d, n.sons[i])
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
else:
|
else:
|
||||||
when defined(nimNoNilSeqs): n.comment = ""
|
when defined(nimNoNilSeqs): n.comment = ""
|
||||||
else: n.comment = nil
|
else: n.comment = nil
|
||||||
|
|
||||||
|
proc genRecComment(d: PDoc, n: PNode): Rope =
|
||||||
|
if n == nil: return nil
|
||||||
|
result = genComment(d, n).rope
|
||||||
|
if result == nil:
|
||||||
|
if n.kind in {nkProcDef, nkFuncDef, nkMethodDef, nkIteratorDef,
|
||||||
|
nkMacroDef, nkTemplateDef, nkConverterDef}:
|
||||||
|
result = genRecCommentAux(d, n[bodyPos])
|
||||||
|
else:
|
||||||
|
result = genRecCommentAux(d, n)
|
||||||
|
|
||||||
proc getPlainDocstring(n: PNode): string =
|
proc getPlainDocstring(n: PNode): string =
|
||||||
## Gets the plain text docstring of a node non destructively.
|
## Gets the plain text docstring of a node non destructively.
|
||||||
##
|
##
|
||||||
|
|
@ -429,27 +441,6 @@ proc getAllRunnableExamplesRec(d: PDoc; n, orig: PNode; dest: var Rope) =
|
||||||
proc getAllRunnableExamples(d: PDoc; n: PNode; dest: var Rope) =
|
proc getAllRunnableExamples(d: PDoc; n: PNode; dest: var Rope) =
|
||||||
getAllRunnableExamplesRec(d, n, n, dest)
|
getAllRunnableExamplesRec(d, n, n, dest)
|
||||||
|
|
||||||
when false:
|
|
||||||
proc findDocComment(n: PNode): PNode =
|
|
||||||
if n == nil: return nil
|
|
||||||
if not isNil(n.comment) and startsWith(n.comment, "##"): return n
|
|
||||||
for i in countup(0, safeLen(n)-1):
|
|
||||||
result = findDocComment(n.sons[i])
|
|
||||||
if result != nil: return
|
|
||||||
|
|
||||||
proc extractDocComment*(s: PSym, d: PDoc): string =
|
|
||||||
let n = findDocComment(s.ast)
|
|
||||||
result = ""
|
|
||||||
if not n.isNil:
|
|
||||||
if not d.isNil:
|
|
||||||
var dummyHasToc: bool
|
|
||||||
renderRstToOut(d[], parseRst(n.comment, toFilename(d.conf, n.info),
|
|
||||||
toLinenumber(n.info), toColumn(n.info),
|
|
||||||
dummyHasToc, d.options + {roSkipPounds}),
|
|
||||||
result)
|
|
||||||
else:
|
|
||||||
result = n.comment.substr(2).replace("\n##", "\n").strip
|
|
||||||
|
|
||||||
proc isVisible(d: PDoc; n: PNode): bool =
|
proc isVisible(d: PDoc; n: PNode): bool =
|
||||||
result = false
|
result = false
|
||||||
if n.kind == nkPostfix:
|
if n.kind == nkPostfix:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue