
    h%                        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  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g)z2Tests for tinypages build using sphinx extensions.    N)Path)subprocess_run_for_testingsphinxz4.1.3)
minversionc                    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S0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 )N-msphinx-W-bhtml-dT
MPLBACKEND capture_outputtextenvr   z!sphinx build failed with stdout:
z	
stderr:

z-sphinx build emitted the following warnings:
)sys
executablestrr   osenvironstdoutstderr
returncodepytestfailis_dir)
source_dirdoctree_dirhtml_dir
extra_argscmdprocouterrs           Q/var/www/html/env/lib/python3.13/site-packages/matplotlib/tests/test_sphinxext.pybuild_sphinx_htmlr(      s    !)zJ>>:tT6[!3z?CMPDNPC%Dt,rzz,<,.D ++C
++C??a E
,SESEDE
DSEJK??    c                 $	  ^^^ [         R                  " [        [        5      R                  S-  U SS9  U S-  S-  nUS-  mU S-  m[
        R                  SS	S
SS[        T5      [        [        [        5      R                  S-  5      [        U5      /	n[        USS0 [        R                  ES[        R                  S.ES9nUR                  nUR                  n[        U TU5        U4S jmU4S jnU4S j[        SS5       5       u  pxn	[         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%                  5       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U
R'                  S"5      S#:X  d   e[         R"                  " UT" S$5      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 ),N	tinypagesTdirs_exist_ok_buildr   _imagesdoctreesr   r	   r
   r   r   )r   GCOV_ERROR_FILEr   c                    > TSU  S3-  $ Nsome_plots-.png )numimg_dirs    r'   	plot_file!test_tinypages.<locals>.plot_file:   s    ;se4000r)   c                 0   > TR                   S-  SU  S3-  $ )Nplot_directiver4   r5   )parent)r7   r    s    r'   plot_directive_file+test_tinypages.<locals>.plot_directive_file=   s#    !!$44SE7NNNr)   c              3   4   >#    U  H  nT" U5      v   M     g 7fNr6   ).0ir9   s     r'   	<genexpr>!test_tinypages.<locals>.<genexpr>A   s     !D1)A,,s                  12_0012_01   some_plots.htmls   # Only a commentz
range4.pngzrange6_range6.pngs    This is the caption for plot 15.s    Plot 17 uses the caption option.s    This is the caption for plot 18.s&   plot-directive my-class my-other-classs#   This caption applies to both plots.      zrange6_range10.pngzincluded_plot_21.rsts   plt.plot(range(6))s   plt.plot(range(4)))rF   rO      rH   r   rQ   )shutilcopytreer   __file__r=   r   r   r   r   r   r   devnullr   r   r(   rangefilecmpcmp
read_bytescountreplacewrite_bytesstatst_mtime)tmp_pathr!   r#   r$   r%   r&   r>   range_10range_6range_4html_contentscontentsrC   modification_timesr    r8   r9   s                 @@@r'   test_tinypagesrf   #   s0   
OODN))K7"&(("V+H"GZ'K>>:tT6[!tH~$${23S]DC &DtKrzzK

KD ++C
++C 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==?M-///;;w, 67777;;w*= =>>>>.-???.-???.-???4EEEEF!KKK ;;w	"....;;x+?!?@@@@ 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   ;*Rc                    [        [        5      R                  n[        R                  " US-  U S-  5        [        R
                  " U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tinypages/conf.pyconf.pytinypages/_static_staticr0   	index.rstz#
.. plot::

    plt.plot(range(2))
r.   html1**/index-1.pyrF   html2-Dzplot_html_show_source_link=0r"   r   r   rT   r=   rR   copyfilerS   
write_textr(   lenlistglob)r_   r=   r    	html_dir1	html_dir2s        r'   test_plot_html_show_source_linkrz   |   s    (^""F
OOF00(Y2FG
OOF00(Y2FG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_linkrF   c                 ^   [        [        5      R                  n[        R                  " US-  U S-  5        [        R
                  " U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   rj   rk   r0   rl   z?
.. plot::
    :show-source-link: true

    plt.plot(range(2))
r.   r   rp   plot_html_show_source_link=rq   rn   rF   rr   r_   r{   r=   r    r!   s        r'   test_show_source_link_truer           (^""F
OOF00(Y2FG
OOF00(Y2FGZ'K'' )  ("V+HhX+,F+GHCJ KtHMM/234999r)   c                 ^   [        [        5      R                  n[        R                  " US-  U S-  5        [        R
                  " U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   rj   rk   r0   rl   z@
.. plot::
    :show-source-link: false

    plt.plot(range(2))
r.   r   rp   r}   rq   rn   r   rr   r~   s        r'   test_show_source_link_falser      r   r)   c                 l  ^ [         R                  " [        [        5      R                  S-  U S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 ) Nr+   Tr,   r.   r   r/   r0   rp   zplot_srcset=2xrq   c                    > TSU  U S3-  $ r3   r6   )r7   suffr8   s     r'   r9   &test_srcset_version.<locals>.plot_file   s    ;seD6666r)   )	rF   rO   rQ   rH   rI   rJ   rM      rP   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"rN   zutf-8)encodingzVsrcset="../_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   )rR   rS   r   rT   r=   r(   exists	read_text)r_   r!   r    r9   indstr8   s         @r'   test_srcset_versionr      s   
OODN))K7"&(("V+H"GZ'KhXC  !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)   rA   )__doc__rW   r   pathlibr   rR   r   matplotlib.testingr   r   importorskipr(   rf   rz   markparametrizer   r   r   r6   r)   r'   <module>r      s    8  	   
 9    H 1&V.r;, 51v>: ?:& 51v>: ?:&&Sr)   