code: def setup(app):
      if on_rtd and not os.path.exists(
          os.path.join(here, "_static", "jupyter-threejs.js")
      ):
          # We don't have a develop install on RTD, ensure we get autogen output:
          from subprocess import check_call
  
          popd = os.path.abspath(os.curdir)
          os.chdir(os.path.join(here, "..", "..", "js"))
          try:
              check_call(["npm", "install"])
              check_call(["npm", "run", "build:bundles-prod"])
          finally:
              os.chdir(popd)
  
      def add_scripts(app):
          for fname in ["jupyter-threejs.js"]:
              if not os.path.exists(
                  os.path.join(here, "_static", fname)
              ):
                  logger.warn("missing javascript file: %s" % fname)
              app.add_js_file(fname)
  
      def add_images(app):
          # TODO: Add all images automatically by dir
          for img_name in ("earth.jpg", "checkerboard.png"):
              img = os.path.join("examples", "img", img_name)
              app.builder.images[img] = img_name
  
      app.connect("builder-inited", add_scripts)
  
      if on_rtd:
          # Ensure example image resources are available. This requires a redirect on RTD.
          app.connect("builder-inited", add_images)
  
imports: import sys
  from os.path import dirname, join
  from sphinx.util import logging
  import os
label_desc: Use image node_id 1 for calling a global function with example usage: setup(app) without return types