MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / mark_plot_labels

Function mark_plot_labels

lib/matplotlib/sphinxext/plot_directive.py:238–265  ·  view source on GitHub ↗

To make plots referenceable, we need to move the reference from the "htmlonly" (or "latexonly") node to the actual figure node itself.

(app, document)

Source from the content-addressed store, hash-verified

236
237
238def mark_plot_labels(app, document):
239 """
240 To make plots referenceable, we need to move the reference from the
241 "htmlonly" (or "latexonly") node to the actual figure node itself.
242 """
243 for name, explicit in document.nametypes.items():
244 if not explicit:
245 continue
246 labelid = document.nameids[name]
247 if labelid is None:
248 continue
249 node = document.ids[labelid]
250 if node.tagname in ('html_only', 'latex_only'):
251 for n in node:
252 if n.tagname == 'figure':
253 sectname = name
254 for c in n:
255 if c.tagname == 'caption':
256 sectname = c.astext()
257 break
258
259 node['ids'].remove(labelid)
260 node['names'].remove(name)
261 n['ids'].append(labelid)
262 n['names'].append(name)
263 document.settings.env.labels[name] = \
264 document.settings.env.docname, labelid, sectname
265 break
266
267
268class PlotDirective(Directive):

Callers

nothing calls this directly

Calls 1

removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…