in _ext/sphinx_plotly_directive.py [0:0]
def mark_plot_labels(app, document):
"""
To make plots referenceable, we need to move the reference from the
"htmlonly" (or "latexonly") node to the actual figure node itself.
"""
for name, explicit in document.nametypes.items():
if not explicit:
continue
labelid = document.nameids[name]
if labelid is None:
continue
node = document.ids[labelid]
if node.tagname in ("html_only", "latex_only"):
for n in node:
if n.tagname == "figure":
sectname = name
for c in n:
if c.tagname == "caption":
sectname = c.astext()
break
node["ids"].remove(labelid)
node["names"].remove(name)
n["ids"].append(labelid)
n["names"].append(name)
document.settings.env.labels[name] = (
document.settings.env.docname,
labelid,
sectname,
)
break