diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 19eb45be8d..a2e7626b42 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -327,6 +327,10 @@ proc pushCom(g: var TSrcGen, n: PNode) = setLen(g.comStack, g.comStack.len + 1) g.comStack[^1] = n +proc popCom(g: var TSrcGen): PNode = + result = g.comStack[^1] + setLen(g.comStack, g.comStack.len - 1) + proc popAllComs(g: var TSrcGen) = setLen(g.comStack, 0) @@ -1353,6 +1357,10 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext, fromStmtList = false) = if not n[0].isExported() and renderNonExportedFields notin g.flags: # Skip if this is a property in a type and its not exported # (While also not allowing rendering of non exported fields) + if shouldRenderComment(g, n): + # `shouldRenderComment` indicts that we have comments to render + # but it's a non-exported field, so we just pop without rendering any comment + discard popCom(g) return # render postfix for object fields: exclFlags = g.flags * {renderNoPostfix} diff --git a/nimdoc/testproject/expected/testproject.html b/nimdoc/testproject/expected/testproject.html index 43a72d99db..62d9911c03 100644 --- a/nimdoc/testproject/expected/testproject.html +++ b/nimdoc/testproject/expected/testproject.html @@ -82,6 +82,9 @@ Rectangle ## A four-sided shape">Shapes
  • T19396
  • +
  • Xxx
  • @@ -455,6 +458,16 @@ + + +
    +
    Xxx = object
    +  field*: int
    +  field3*: int               ## Doc comment2
    +
    + + +
    diff --git a/nimdoc/testproject/expected/testproject.idx b/nimdoc/testproject/expected/testproject.idx index 81d65a05a2..94c0477932 100644 --- a/nimdoc/testproject/expected/testproject.idx +++ b/nimdoc/testproject/expected/testproject.idx @@ -67,6 +67,7 @@ nim T19396 testproject.html#T19396 object T19396 404 nim somePragma testproject.html#somePragma.t template somePragma() 408 nim MyObject testproject.html#MyObject object MyObject 412 nim AnotherObject testproject.html#AnotherObject object AnotherObject 417 +nim Xxx testproject.html#Xxx object Xxx 424 nimgrp bar testproject.html#bar-procs-all proc 43 nimgrp baz testproject.html#baz-procs-all proc 46 heading Basic usage testproject.html#basic-usage Basic usage 0 diff --git a/nimdoc/testproject/expected/theindex.html b/nimdoc/testproject/expected/theindex.html index 71a487e0cf..62b9da9a2a 100644 --- a/nimdoc/testproject/expected/theindex.html +++ b/nimdoc/testproject/expected/theindex.html @@ -342,6 +342,10 @@
  • testproject: proc tripleStrLitTest()
  • +
    Xxx:
    z1: