class_docstr: The figure directive which applies `:name:` option to the figure node
  instead of the image node.
class_docstr_tok: ["The","figure","directive","which","applies","`",":","name",":","`","option","to","the","figure","node","instead","of","the","image","node","."]
code: def run(self) -> list[Node]:
      name = self.options.pop("name", None)
      result = super().run()
      if len(result) == 2 or isinstance(
          result[0], nodes.system_message
      ):
          return result
  
      assert len(result) == 1
      figure_node = cast(nodes.figure, result[0])
      if name:
          # set ``name`` to figure_node if given
          self.options["name"] = name
          self.add_name(figure_node)
  
      # copy lineno from image node
      if figure_node.line is None and len(figure_node) == 2:
          caption = cast(nodes.caption, figure_node[1])
          figure_node.line = caption.line
  
      return [figure_node]
  
imports: from __future__ import annotations
  import os
  from os import path
  from typing import TYPE_CHECKING, Any, cast
  from docutils import nodes
  from docutils.nodes import Node, make_id
  from docutils.parsers.rst import directives
  from docutils.parsers.rst.directives import images, tables
  from docutils.parsers.rst.directives.misc import Meta
  from docutils.parsers.rst.roles import set_classes
  from sphinx.directives import optional_int
  from sphinx.domains.math import MathDomain
  from sphinx.locale import __
  from sphinx.util import logging
  from sphinx.util.docutils import SphinxDirective
  from sphinx.util.nodes import set_source_info
  from sphinx.util.osutil import SEP, os_path, relpath
label_desc: Use image node_id 1 for calling the Figure obj's underlying member method code with example usage: obj.run() and returns: list, result