
    6Dh                     n    S SK J r   S SKrS SKrS SKrS\R                  R
                  l        S rS rSr	g)    )globNsphinx_gallery_pngc                    [         R                  R                  US   5      n[        [	        [         R                  R                  US5      5      5      n[        [	        [         R                  R                  US5      5      5      nUS   n[        5       n[        5       n	[        Xe5       H  u  pX;  d  M  U	[        U5      -  n	[        U5      n[         R                  R                  U5      S   S-   nUR                  U5        [        R                  " X5        [        R                  " X5        M     [        XS   5      $ )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                 G/var/www/html/env/lib/python3.13/site-packages/plotly/io/_sg_scraper.pyplotly_sg_scraperr%      s    D 77??:j#9:L$rww||L':;<D4\8<=>E$%:;&K5D%	?CHD"&':";#%77#3#34G#H#Kg#U 34KK1KK3 & k	#:;;    c                    U  Vs/ s HO  n[         R                  R                  X!5      R                  [         R                  S5      R                  S5      PMQ     nnSnU(       d  U$ US   n[         R                  R                  U5      S   n[         R                  R                  S[         R                  R                  U5      5      n[        U-  nU$ s  snf )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    * '&K 	199"&&#FMMcR&   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&   