diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-09-08 20:11:01 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-09-08 21:57:27 +0200 |
commit | 07fcce6e631dfc07517e0cc1a2918954cd647f5f (patch) | |
tree | a911fcc740933a57d562b02749870fe8ffc0b8ca | |
parent | 3e87ef35faa92333d6c78af1109d5da0cf0fc9c7 (diff) | |
download | Nim-07fcce6e631dfc07517e0cc1a2918954cd647f5f.tar.gz |
docgen: different attachedType generation
-rw-r--r-- | compiler/docgen.nim | 15 | ||||
-rw-r--r-- | config/nimdoc.cfg | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 9c72d5a84..af940db00 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -440,11 +440,6 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) = dispA(result, "<span class=\"Other\">$1</span>", "\\spanOther{$1}", [rope(esc(d.target, literal))]) - if k in routineKinds and nameNode.kind == nkSym: - let att = attachToType(d, nameNode.sym) - if att != nil: - dispA(result, """<span class="attachedType" style="visibility:hidden">$1</span>""", "", - [rope esc(d.target, att.name.s)]) inc(d.id) let plainNameRope = rope(xmltree.escape(plainName.strip)) @@ -476,12 +471,18 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) = "itemSymOrID", "itemSymEnc", "itemSymOrIDEnc", "seeSrc"], [nameRope, result, comm, itemIDRope, plainNameRope, plainSymbolRope, symbolOrIdRope, plainSymbolEncRope, symbolOrIdEncRope, seeSrcRope])) + + var attype: Rope + if k in routineKinds and nameNode.kind == nkSym: + let att = attachToType(d, nameNode.sym) + if att != nil: + attype = rope esc(d.target, att.name.s) add(d.toc[k], ropeFormatNamedVars(getConfigVar("doc.item.toc"), ["name", "header", "desc", "itemID", "header_plain", "itemSym", - "itemSymOrID", "itemSymEnc", "itemSymOrIDEnc"], + "itemSymOrID", "itemSymEnc", "itemSymOrIDEnc", "attype"], [rope(getName(d, nameNode, d.splitAfter)), result, comm, itemIDRope, plainNameRope, plainSymbolRope, symbolOrIdRope, - plainSymbolEncRope, symbolOrIdEncRope])) + plainSymbolEncRope, symbolOrIdEncRope, attype])) # Ironically for types the complexSymbol is *cleaner* than the plainName # because it doesn't include object fields or documentation comments. So we diff --git a/config/nimdoc.cfg b/config/nimdoc.cfg index 195c97a2e..d19286703 100644 --- a/config/nimdoc.cfg +++ b/config/nimdoc.cfg @@ -49,7 +49,7 @@ $seeSrc # See doc.item for available substitution variables. doc.item.toc = """ <li><a class="reference" href="#$itemSymOrID" - title="$header_plain">$name</a></li> + title="$header_plain">$name<span class="attachedType" style="visibility:hidden">$attype</span></a></li> """ # HTML rendered for doc.item's seeSrc variable. Note that this will render to |