code: def run(self):
      env = self.state.document.settings.env
      app = env.app
  
      show_code = "hide-code" not in self.options
      code_below = "code-below" in self.options
  
      setupcode = "\n".join(
          item["code"]
          for item in getattr(env, "pdvega_plot_setup", [])
          if item["docname"] == env.docname
      )
  
      code = "\n".join(self.content)
  
      if show_code:
          source_literal = nodes.literal_block(code, code)
          source_literal["language"] = "python"
  
      # get the name of the source file we are currently processing
      rst_source = self.state_machine.document["source"]
      rst_dir = os.path.dirname(rst_source)
      rst_filename = os.path.basename(rst_source)
  
      # use the source file name to construct a friendly target_id
      serialno = env.new_serialno("pdvega-plot")
      rst_base = rst_filename.replace(".", "-")
      div_id = "{0}-pdvega-plot-{1}".format(rst_base, serialno)
      target_id = "{0}-pdvega-source-{1}".format(rst_base, serialno)
      target_node = nodes.target("", "", ids=[target_id])
  
      # create the node in which the plot will appear;
      # this will be processed by html_visit_pdvega_plot
      plot_node = pdvega_plot()
      plot_node["target_id"] = target_id
      plot_node["div_id"] = div_id
      plot_node["code"] = code
      plot_node["setupcode"] = setupcode
      plot_node["relpath"] = os.path.relpath(rst_dir, env.srcdir)
      plot_node["rst_source"] = rst_source
      plot_node["rst_lineno"] = self.lineno
      plot_node["links"] = self.options.get(
          "links", app.builder.config.pdvegaplot_links
      )
      plot_node["url_root"] = app.config.pdvegaplot_url_root
  
      if "alt" in self.options:
          plot_node["alt"] = self.options["alt"]
  
      result = [target_node]
  
      if code_below:
          result += [plot_node]
      if show_code:
          result += [source_literal]
      if not code_below:
          result += [plot_node]
  
      return result
  
imports: import os
  import json
  import warnings
  import jinja2
  from docutils import nodes
  from docutils.parsers.rst import Directive
  from docutils.parsers.rst.directives import flag, unchanged
  from sphinx.locale import _
  from pdvega import Axes
  from .utils import exec_then_eval
label_desc: Use image node_id 1 for calling the PdVegaPlotDirective obj's underlying member method code with example usage: obj.run() and returns: result