mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-14 15:23:27 +00:00
docgen: different attachedType generation
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user