
    
3j-                     L   S r SSKrSSKrSSKJr  SSKrSSKrSSKJr  SSK	r	\	R                  " SSS9  \" \5      R                  S-  rSS	 jrS
 rS r\	R"                  R%                  SSS/5      S 5       r\	R"                  R%                  SSS/5      S 5       rS rS rS rg)z2Tests for tinypages build using sphinx extensions.    N)Path)subprocess_run_for_testingsphinxz4.1.3)
minversionzdata/tinypagesc                    Uc  / OUn[         R                  SSSSS[        U5      [        U 5      [        U5      /	UQn[        USS0 [        R
                  ES[        R                  S.ES	9nUR                  nUR                  nUR                  S
:X  d   SU SU S35       eU(       a  [        R                  " SU 35        UR                  5       (       d   eg )Nz-msphinxz-Wz-bhtmlz-dT )
MPLBACKENDGCOV_ERROR_FILE)capture_outputtextenvr   z!sphinx build failed with stdout:
z	
stderr:

z-sphinx build emitted the following warnings:
)sys
executablestrr   osenvirondevnullstdoutstderr
returncodepytestfailis_dir)
source_dirdoctree_dirhtml_dir
extra_argscmdprocouterrs           Y/home/wildlama/miniconda3/lib/python3.13/site-packages/matplotlib/tests/test_sphinxext.pybuild_sphinx_htmlr%      s    !)zJ>>:tT6[!3z?CMPDNPC
 &DtKrzzK

KD ++C
++C??a E
,SESEDE
DSEJK??    c           
      	  ^
^^ [         R                  " [        U S[         R                  " SSS5      S9  U S-  S-  nUS-  mU S-  m
[	        U T
U5        U4S jmU
4S	 jnU4S
 j[        SS5       5       u  p4n[        R                  " UT" S5      5      (       d   e[        R                  " UT" S5      5      (       d   e[        R                  " UT" S5      5      (       d   e[        R                  " UT" S5      5      (       d   e[        R                  " UT" S5      5      (       d   e[        R                  " UT" S5      5      (       d   eUS-  R                  SS9nSU;   d   e[        R                  " UTS-  5      (       d   e[        R                  " UTS-  5      (       d   eSU;   d   eSU;   d   eSU;   d   eSU;   d   eSU;   d   eUR                  S5      S:X  d   e[        R                  " UT" S 5      5      (       d   e[        R                  " UTS!-  5      (       d   e[        R                  " UTS"-  5      (       d   e[        R                  " UTS#-  5      (       d   e[        R                  " UTS$-  5      (       d   e[        R                  " UTS%-  5      (       d   eU S&-  R                  5       nUR                  S'S(5      nU S&-  R                  U5        S) Vs/ s H#  nU" U5      R                  5       R                  PM%     n	n[	        U T
U5        [        R                  " UT" S 5      5      (       d   eU" S5      R                  5       R                  U	S*   :X  d   eU" S5      R                  5       R                  U	S   :X  d   eU" S+5      R                  5       R                  U	S   :X  d   e[        R                  " UT" S5      5      (       d   e[        R                  " UT" S5      5      (       d   e[        R                  " UT" S+5      5      (       d   eU" S5      R                  5       R                  U	S+   :  d   e[        R                  " UT" S5      5      (       d   eg s  snf ),NT_builddoctreesplot_directivedirs_exist_okignorer   _imagesc                    > TSU  S3-  $ Nsome_plots-.png )numimg_dirs    r$   	plot_file!test_tinypages.<locals>.plot_file5   s    ;se4000r&   c                 0   > TR                   S-  SU  S3-  $ )Nr*   r1   r2   )parent)r4   r   s    r$   plot_directive_file+test_tinypages.<locals>.plot_directive_file8   s#    !!$44SE7NNNr&   c              3   4   >#    U  H  nT" U5      v   M     g 7fNr3   ).0ir6   s     r$   	<genexpr>!test_tinypages.<locals>.<genexpr><   s     !D1)A,,s                  12_0012_01   some_plots.htmlutf-8encodingz# Only a commentz
range4.pngzrange6_range6.pngz This is the caption for plot 15.z7Plot 17 uses the caption option,
with multi-line input.z3Plot 17 uses the alt option, with multi-line input.z This is the caption for plot 18.z&plot-directive my-class my-other-classz#This caption applies to both plots.      zrange6_range10.pngzcustom-basename-6.pngzcustom-basename-4.pngzcustom-basename-4-6_00.pngzcustom-basename-4-6_01.pngzincluded_plot_21.rsts   plt.plot(range(6))s   plt.plot(range(4)))rB   rN      rD   r   rP   )shutilcopytree	tinypagesignore_patternsr%   rangefilecmpcmp	read_textcount
read_bytesreplacewrite_bytesstatst_mtime)tmp_pathr   r:   range_10range_6range_4html_contentscontentsr?   modification_timesr   r5   r6   s             @@@r$   test_tinypagesrf   *   sG   
OOIxt!11(J3CEF ("V+H"GZ'K hX61O "Ea!DHw;;w	!----;;w	!----;;x2////;;x7!34444;;w	' 23333;;w	".... 11<<g<NM...;;w, 67777;;w*= =>>>>->>> FVVV@MQQQ->>>3}DDDDEJJJ ;;w	"....;;x+?!?@@@@;;w*A ABBBB;;w*A ABBBB;;w*F FGGGG;;w*F FGGGG 11==?H 57LMH&&33H= $01#/a .a0557@@#/  1hX6;;w	".... q!&&(115G5JJJJq!&&(115G5JJJJq!&&(115G5JJJJ;;x1....;;w	!----;;w	!---- q!&&(114Fq4IIII;;w	!----!1s   2*Rc                    [         R                  " [        S-  U S-  5        [         R                  " [        S-  U S-  5        U S-  nU S-  R	                  S5        U S-  S-  n[        XU5        [        [        UR                  S5      5      5      S	:X  d   eU S-  S
-  n[        XUSS/S9  [        [        UR                  S5      5      5      S:X  d   eg )Nconf.py_staticr)   	index.rstz#
.. plot::

    plt.plot(range(2))
r(   html1**/index-1.pyrB   html2-Dzplot_html_show_source_link=0r   r   	rQ   copyfilerS   rR   
write_textr%   lenlistglob)r_   r   	html_dir1	html_dir2s       r$   test_plot_html_show_source_linkrx      s    
OOI	)8i+?@
OOI	)8i+?@Z'K'' )  8#g-IhY7tINN?345::: 8#g-IhY"&(F!GItINN?345:::r&   plot_html_show_source_linkrB   c                 <   [         R                  " [        S-  U S-  5        [         R                  " [        S-  U S-  5        U S-  nU S-  R	                  S5        U S-  S-  n[        XUSS	U 3/S
9  [        [        UR                  S5      5      5      S:X  d   eg )Nrh   ri   r)   rj   z?
.. plot::
    :show-source-link: true

    plt.plot(range(2))
r(   r   rn   plot_html_show_source_link=ro   rl   rB   rp   r_   ry   r   r   s       r$   test_show_source_link_truer}           OOI	)8i+?@
OOI	)8i+?@Z'K'' )  ("V+HhX+,F+GHCJ KtHMM/234999r&   c                 <   [         R                  " [        S-  U S-  5        [         R                  " [        S-  U S-  5        U S-  nU S-  R	                  S5        U S-  S-  n[        XUSS	U 3/S
9  [        [        UR                  S5      5      5      S:X  d   eg )Nrh   ri   r)   rj   z@
.. plot::
    :show-source-link: false

    plt.plot(range(2))
r(   r   rn   r{   ro   rl   r   rp   r|   s       r$   test_show_source_link_falser      r~   r&   c                 j   [         R                  " [        S-  U S-  5        [         R                  " [        S-  U S-  5        U S-  nU S-  R	                  S5        U S-  S-  n[        XU5        [        [        UR                  S5      5      5      S	:X  d   eUS
-  R                  5       nSU;   d   eg )Nrh   ri   r)   rj   zE
.. plot::
    :filename-prefix: custom-name

    plt.plot(range(2))
r(   r   z**/custom-name.pyrB   
index.htmlzcustom-name.py)
rQ   rq   rS   rR   rr   r%   rs   rt   ru   rX   r_   r   r   html_contents       r$   /test_plot_html_show_source_link_custom_basenamer      s    
OOI	)8i+?@
OOI	)8i+?@Z'K'' )  ("V+HhX6 tHMM"5678A=== |+668L|+++r&   c                 P   [         R                  " [        S-  U S-  5        [         R                  " [        S-  U S-  5        U S-  nU S-  R	                  S5        U S-  S-  n[        XU5        US-  R                  S	S
9nSU;   d   eSU;   d  SUR                  5       ;   d   eg g )Nrh   ri   r)   rj   z
.. plot::
    :include-source:
    :code-caption: Example plotting code

    import matplotlib.pyplot as plt
    plt.plot([1, 2, 3], [1, 4, 9])
r(   r   r   rK   rL   zExample plotting codez<p class="caption"caption)rQ   rq   rS   rR   rr   r%   rX   lowerr   s       r$   test_plot_html_code_captionr      s    
OOI	)8i+?@
OOI	)8i+?@Z'K'' )  ("V+HhX6 |+666HL"l222  </9@R@R@T3TTT3T/r&   c           
      n  ^ [         R                  " [        U S[         R                  " SSS5      S9  U S-  S-  nUS-  mU S-  n[	        XUSS	/S
9  SU4S jjnS H<  nU" U5      R                  5       (       d   eU" USS9R                  5       (       a  M<   e   TS-  R                  5       (       d   eTS-  R                  5       (       d   eTS-  R                  5       (       d   eTS-  R                  5       (       d   eTS-  R                  5       (       d   eTS-  R                  5       (       d   eTS-  R                  5       (       d   eTS-  R                  5       (       d   eSUS-  R                  SS9;   d   eSnXQS-  R                  SS9;   d   eSnXQS-  R                  SS9;   d   eg ) NTr(   r)   r*   r+   r   r.   rn   zplot_srcset=2xro   c                    > TSU  U S3-  $ r0   r3   )r4   suffr5   s     r$   r6   &test_srcset_version.<locals>.plot_file   s    ;seD6666r&   )	rB   rN   rP   rD   rE   rF   rI      rO   z.2x)r   znestedpage-index-1.pngznestedpage-index-1.2x.pngznestedpage-index-2.pngznestedpage-index-2.2x.pngznestedpage2-index-1.pngznestedpage2-index-1.2x.pngznestedpage2-index-2.pngznestedpage2-index-2.2x.pngzDsrcset="_images/some_plots-1.png, _images/some_plots-1.2x.png 2.00x"rJ   rK   rL   zVsrcset="../_images/nestedpage-index-1.png, ../_images/nestedpage-index-1.2x.png 2.00x"znestedpage/index.htmlzXsrcset="../_images/nestedpage2-index-2.png, ../_images/nestedpage2-index-2.2x.png 2.00x"znestedpage2/index.html)r	   )rQ   rR   rS   rT   r%   existsrX   )r_   r   r   r6   indstr5   s         @r$   test_srcset_versionr      s   
OOIxt!11(J3CEF ("V+H"GZ'KhX"&(8!9;7 /~$$&&&&5)002222 / ..6688881199;;;;..6688881199;;;;//77999922::<<<<//77999922::<<<< S,,777IJ K J8B44???QQQQ9B55@@'@RRRRr&   r=   )__doc__rV   r   pathlibr   rQ   r   matplotlib.testingr   r   importorskip__file__r9   rS   r%   rf   rx   markparametrizer}   r   r   r   r   r3   r&   r$   <module>r      s    8  	   
 9    H 1 N!!$44	.R.j;* 51v>: ?:$ 51v>: ?:$,,U0'Sr&   