fixes #3655
This commit is contained in:
parent
90025e242d
commit
7f55bfc7d5
1 changed files with 10 additions and 5 deletions
|
|
@ -16,7 +16,7 @@ import
|
||||||
wordrecg, syntaxes, renderer, lexer, packages/docutils/rstast,
|
wordrecg, syntaxes, renderer, lexer, packages/docutils/rstast,
|
||||||
packages/docutils/rst, packages/docutils/rstgen,
|
packages/docutils/rst, packages/docutils/rstgen,
|
||||||
packages/docutils/highlite, sempass2, json, xmltree, cgi,
|
packages/docutils/highlite, sempass2, json, xmltree, cgi,
|
||||||
typesrenderer, astalgo, modulepaths, lineinfos, sequtils
|
typesrenderer, astalgo, modulepaths, lineinfos, sequtils, intsets
|
||||||
|
|
||||||
type
|
type
|
||||||
TSections = array[TSymKind, Rope]
|
TSections = array[TSymKind, Rope]
|
||||||
|
|
@ -32,6 +32,8 @@ type
|
||||||
conf*: ConfigRef
|
conf*: ConfigRef
|
||||||
cache*: IdentCache
|
cache*: IdentCache
|
||||||
exampleCounter: int
|
exampleCounter: int
|
||||||
|
emitted: IntSet # we need to track which symbols have been emitted
|
||||||
|
# already. See bug #3655
|
||||||
|
|
||||||
PDoc* = ref TDocumentor ## Alias to type less.
|
PDoc* = ref TDocumentor ## Alias to type less.
|
||||||
|
|
||||||
|
|
@ -119,6 +121,7 @@ proc newDocumentor*(filename: string; cache: IdentCache; conf: ConfigRef): PDoc
|
||||||
initStrTable result.types
|
initStrTable result.types
|
||||||
result.onTestSnippet = proc (d: var RstGenerator; filename, cmd: string; status: int; content: string) =
|
result.onTestSnippet = proc (d: var RstGenerator; filename, cmd: string; status: int; content: string) =
|
||||||
localError(conf, newLineInfo(conf, d.filename, -1, -1), warnUser, "only 'rst2html' supports the ':test:' attribute")
|
localError(conf, newLineInfo(conf, d.filename, -1, -1), warnUser, "only 'rst2html' supports the ':test:' attribute")
|
||||||
|
result.emitted = initIntSet()
|
||||||
|
|
||||||
proc dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArray[Rope]) =
|
proc dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArray[Rope]) =
|
||||||
if conf.cmd != cmdRst2tex: addf(dest, xml, args)
|
if conf.cmd != cmdRst2tex: addf(dest, xml, args)
|
||||||
|
|
@ -377,7 +380,7 @@ when false:
|
||||||
else:
|
else:
|
||||||
result = n.comment.substr(2).replace("\n##", "\n").strip
|
result = n.comment.substr(2).replace("\n##", "\n").strip
|
||||||
|
|
||||||
proc isVisible(n: PNode): bool =
|
proc isVisible(d: PDoc; n: PNode): bool =
|
||||||
result = false
|
result = false
|
||||||
if n.kind == nkPostfix:
|
if n.kind == nkPostfix:
|
||||||
if n.len == 2 and n.sons[0].kind == nkIdent:
|
if n.len == 2 and n.sons[0].kind == nkIdent:
|
||||||
|
|
@ -388,8 +391,10 @@ proc isVisible(n: PNode): bool =
|
||||||
# exception tracking information here. Instead we copy over the comment
|
# exception tracking information here. Instead we copy over the comment
|
||||||
# from the proc header.
|
# from the proc header.
|
||||||
result = {sfExported, sfFromGeneric, sfForward}*n.sym.flags == {sfExported}
|
result = {sfExported, sfFromGeneric, sfForward}*n.sym.flags == {sfExported}
|
||||||
|
if result and containsOrIncl(d.emitted, n.sym.id):
|
||||||
|
result = false
|
||||||
elif n.kind == nkPragmaExpr:
|
elif n.kind == nkPragmaExpr:
|
||||||
result = isVisible(n.sons[0])
|
result = isVisible(d, n.sons[0])
|
||||||
|
|
||||||
proc getName(d: PDoc, n: PNode, splitAfter = -1): string =
|
proc getName(d: PDoc, n: PNode, splitAfter = -1): string =
|
||||||
case n.kind
|
case n.kind
|
||||||
|
|
@ -520,7 +525,7 @@ proc docstringSummary(rstText: string): string =
|
||||||
|
|
||||||
|
|
||||||
proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
|
proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
|
||||||
if not isVisible(nameNode): return
|
if not isVisible(d, nameNode): return
|
||||||
let
|
let
|
||||||
name = getName(d, nameNode)
|
name = getName(d, nameNode)
|
||||||
nameRope = name.rope
|
nameRope = name.rope
|
||||||
|
|
@ -601,7 +606,7 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
|
||||||
d.types.strTableAdd nameNode.sym
|
d.types.strTableAdd nameNode.sym
|
||||||
|
|
||||||
proc genJsonItem(d: PDoc, n, nameNode: PNode, k: TSymKind): JsonNode =
|
proc genJsonItem(d: PDoc, n, nameNode: PNode, k: TSymKind): JsonNode =
|
||||||
if not isVisible(nameNode): return
|
if not isVisible(d, nameNode): return
|
||||||
var
|
var
|
||||||
name = getName(d, nameNode)
|
name = getName(d, nameNode)
|
||||||
comm = $genRecComment(d, n)
|
comm = $genRecComment(d, n)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue