From a5a373d80961f80b7a190891a7160a1e656bb779 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sun, 12 Jan 2020 13:47:10 -0800 Subject: [PATCH] fix #13100 nim doc now treats `export localSymbol` correctly --- compiler/docgen.nim | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 5eaaed12041d..90e7cd6d0652 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -630,8 +630,12 @@ proc genDeprecationMsg(d: PDoc, n: PNode): Rope = else: doAssert false -proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) = - if not isVisible(d, nameNode): return +type DocFlags = enum + kDefault + kForceExport + +proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind, docFlags: DocFlags) = + if (docFlags != kForceExport) and not isVisible(d, nameNode): return let name = getName(d, nameNode) nameRope = name.rope @@ -847,7 +851,9 @@ proc documentRaises*(cache: IdentCache; n: PNode) = if p4 != nil: n[pragmasPos].add p4 if p5 != nil: n[pragmasPos].add p5 -proc generateDoc*(d: PDoc, n, orig: PNode) = +proc generateDoc*(d: PDoc, n, orig: PNode, docFlags: DocFlags = kDefault) = + template genItemAux(skind) = + genItem(d, n, n[namePos], skind, docFlags) case n.kind of nkPragma: let pragmaNode = findPragma(n, wDeprecated) @@ -855,27 +861,27 @@ proc generateDoc*(d: PDoc, n, orig: PNode) = of nkCommentStmt: d.modDesc.add(genComment(d, n)) of nkProcDef: when useEffectSystem: documentRaises(d.cache, n) - genItem(d, n, n[namePos], skProc) + genItemAux(skProc) of nkFuncDef: when useEffectSystem: documentRaises(d.cache, n) - genItem(d, n, n[namePos], skFunc) + genItemAux(skFunc) of nkMethodDef: when useEffectSystem: documentRaises(d.cache, n) - genItem(d, n, n[namePos], skMethod) + genItemAux(skMethod) of nkIteratorDef: when useEffectSystem: documentRaises(d.cache, n) - genItem(d, n, n[namePos], skIterator) - of nkMacroDef: genItem(d, n, n[namePos], skMacro) - of nkTemplateDef: genItem(d, n, n[namePos], skTemplate) + genItemAux(skIterator) + of nkMacroDef: genItemAux(skMacro) + of nkTemplateDef: genItemAux(skTemplate) of nkConverterDef: when useEffectSystem: documentRaises(d.cache, n) - genItem(d, n, n[namePos], skConverter) + genItemAux(skConverter) of nkTypeSection, nkVarSection, nkLetSection, nkConstSection: for i in 0..