summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-06-17 23:47:16 -0700
committerGitHub <noreply@github.com>2020-06-18 08:47:16 +0200
commitbb62feff72a911ca9a314eba6409a6f4f786b568 (patch)
tree7d1172d03eb1a2d4e360809529b1a08b0a9170a9 /compiler
parent7df27b5035ad128812fbd070e3fa80ef6819e4df (diff)
downloadNim-bb62feff72a911ca9a314eba6409a6f4f786b568.tar.gz
fix #14691 docgen works again for methods (#14701)
* fix #14691 docgen methods

* fixup
Diffstat (limited to 'compiler')
-rw-r--r--compiler/docgen.nim19
1 files changed, 5 insertions, 14 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index 0af830a42..a973bdfc1 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -609,21 +609,12 @@ proc getRoutineBody(n: PNode): PNode =
 
   so we normalize the results to get to the statement list containing the
   (0 or more) doc comments and runnableExamples.
-  (even if using `result = n[bodyPos]`, you'd still to apply similar logic).
   ]##
-  result = n[^1]
-  case result.kind
-  of nkSym:
-    result = n[^2]
-    case result.kind
-      of nkAsgn:
-        doAssert result[0].kind == nkSym
-        doAssert result.len == 2
-        result = result[1]
-      else: # eg: nkStmtList
-        discard
-  else:
-    discard
+  result = n[bodyPos]
+  if result.kind == nkAsgn and n.len > bodyPos+1 and n[bodyPos+1].kind == nkSym:
+    doAssert result[0].kind == nkSym
+    doAssert result.len == 2
+    result = result[1]
 
 proc getAllRunnableExamples(d: PDoc, n: PNode, dest: var Rope) =
   var n = n