diff options
author | Araq <rumpf_a@web.de> | 2018-10-30 21:54:24 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-10-30 21:58:59 +0100 |
commit | eb03684c57089fa33c3add694841a8f7f3ad8a72 (patch) | |
tree | 9fb25e191b35384b9bce0430c1190e9b4944ed8c /compiler/docgen.nim | |
parent | 895ac5bec4bc5c5a05e740c9c6abbc6867f84450 (diff) | |
download | Nim-eb03684c57089fa33c3add694841a8f7f3ad8a72.tar.gz |
docgen: fixes #9169 [backport]
Diffstat (limited to 'compiler/docgen.nim')
-rw-r--r-- | compiler/docgen.nim | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim index de2a9831d..4c4e68397 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -247,18 +247,30 @@ proc genComment(d: PDoc, n: PNode): string = toLinenumber(n.info), toColumn(n.info), 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 result = genComment(d, n).rope 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): - result = genRecComment(d, n.sons[i]) + result = genRecCommentAux(d, n.sons[i]) if result != nil: return else: when defined(nimNoNilSeqs): n.comment = "" 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 = ## 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) = 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 = result = false if n.kind == nkPostfix: |