
    g                     n    d dl m Z  d dlZd dlZd dlZdej                  j
                  _        d Zd ZdZ	y)    )globNsphinx_gallery_pngc                    t         j                  j                  |d         }t        t	        t         j                  j                  |d                  }t        t	        t         j                  j                  |d                  }|d   }t               }t               }	t        ||      D ]  \  }
}||	vs|	t        |      z  }	t        |      }t         j                  j                  |      d   dz   }|j                  |       t        j                  ||       t        j                  |
|        t        ||d         S )a<  Scrape Plotly figures for galleries of examples using
    sphinx-gallery.

    Examples should use ``plotly.io.show()`` to display the figure with
    the custom sphinx_gallery renderer.

    Since the sphinx_gallery renderer generates both html and static png
    files, we simply crawl these files and give them the appropriate path.

    Parameters
    ----------
    block : tuple
        A tuple containing the (label, content, line_number) of the block.
    block_vars : dict
        Dict of block variables.
    gallery_conf : dict
        Contains the configuration of Sphinx-Gallery
    **kwargs : dict
        Additional keyword arguments to pass to
        :meth:`~matplotlib.figure.Figure.savefig`, e.g. ``format='svg'``.
        The ``format`` kwarg in particular is used to set the file extension
        of the output file (currently only 'png' and 'svg' are supported).

    Returns
    -------
    rst : str
        The ReSTructuredText that will be rendered to HTML containing
        the images.

    Notes
    -----
    Add this function to the image scrapers
    src_filez*.pngz*.htmlimage_path_iteratorr   z.htmlsrc_dir)ospathdirnamesortedr   joinlistsetzipnextsplitextappendshutilmove
figure_rst)block
block_varsgallery_confkwargsexamples_dirpngshtmlsr   image_namesseenhtmlpngthis_image_path_pngthis_image_path_htmls                 R/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/plotly/io/_sg_scraper.pyplotly_sg_scraperr%      s   D 77??:j#9:L$rww||L':;<D4\8<=>E$%:;&K5D% 4	cd?CHD"&':";#%77#3#34G#H#Kg#U 34KK01KK234 k<	#:;;    c                    | D cg c]O  }t         j                  j                  ||      j                  t         j                  d      j                  d      Q }}d}|s|S |d   }t         j                  j                  |      d   }t         j                  j                  dt         j                  j                  |            }t        |z  }|S c c}w )a  Generate RST for a list of PNG filenames.

    Depending on whether we have one or more figures, we use a
    single rst call to 'image' or a horizontal list.

    Parameters
    ----------
    figure_list : list
        List of strings of the figures' absolute paths.
    sources_dir : str
        absolute path of Sphinx documentation sources

    Returns
    -------
    images_rst : str
        rst code to embed the images in the document
    / r      images)
r	   r
   relpathreplaceseplstripr   r   basenameSINGLE_HTML)figure_listsources_dirfigure_pathfigure_paths
images_rstfigure_nameexts          r$   r   r   A   s    * ' 	[199"&&#FMMcRL  Jq/K
''

;
'
*C'',,x)9)9+)FGK{*Js   ACz
.. raw:: html
    :file: %s
)
r   r	   r   plotlyio	renderersdefaultr%   r   r1    r&   r$   <module>r>      s8     	  2		   1<hBr&   