code: def get_doc(logger=None, plugin=None, reporthook=None):
      
      from ginga.GingaPlugin import GlobalPlugin, LocalPlugin
  
      if isinstance(plugin, GlobalPlugin):
          plugin_page = 'plugins_global'
          plugin_name = str(plugin)
      elif isinstance(plugin, LocalPlugin):
          plugin_page = 'plugins_local'
          plugin_name = str(plugin)
      else:
          plugin_page = None
          plugin_name = None
  
      try:
          index_html = _download_rtd_zip(reporthook=reporthook)
  
      # Download failed, use online resource
      except Exception as e:
          url = 'https://ginga.readthedocs.io/en/latest/'
  
          if plugin_name is not None:
              if toolkit.family.startswith('qt'):
                  # This displays plugin docstring.
                  url = None
              else:
                  # This redirects to online doc.
                  url += 'manual/{}/{}.html'.format(plugin_page, plugin_name)
  
          if logger is not None:
              logger.error(str(e))
  
      # Use local resource
      else:
          pfx = 'file:'
          url = '{}{}'.format(pfx, index_html)
  
          # https://github.com/rtfd/readthedocs.org/issues/2803
          if plugin_name is not None:
              url += '#{}'.format(plugin_name)
  
      return url
docs: Return URL to documentation. Attempt download if does not exist.
  
      Parameters
      ----------
      logger : obj or `None`
          Ginga logger.
  
      plugin : obj or `None`
          Plugin object. If given, URL points to plugin doc directly.
          If this function is called from within plugin class,
          pass ``self`` here.
  
      reporthook : callable or `None`
          Report hook for ``urlretrieve()``.
  
      Returns
      -------
      url : str or `None`
          URL to local documentation, if available.