
    2yi/5                       d dl mZ d dlZd dlZd dlZd dlZd dlmZmZ d dl	m
Z
mZ d dlZd dlmZ d dlZd dlmZ d dlmZmZ d dlmZmZmZmZmZ d d	lmZmZ d d
lmZ d dlm Z  d dlm!Z! erd dl"m#Z#  ejH                  e%      Z&	 	 d	 	 	 	 	 	 	 	 	 	 	 ddZ'	 	 	 	 	 	 	 	 	 	 	 	 ddZ(	 	 	 	 	 	 	 	 	 	 	 	 ddZ)ddZ*dddZ+	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d dZ,dddd!dZ-d"dZ.y)#    )annotationsN)TYPE_CHECKINGSequence)urljoinurlsplit)TemplateNotFound)utils)Abort
BuildError)FileFilesInclusionLevel	get_filesset_exclusions)
Navigationget_navigation)Page)DuplicateFilter)	templates)MkDocsConfigc                   | t        j                  d|j                        }|j                  D cg c]"  }t        j                  t        |      ||      $ }}|j                  D cg c]  }t        j                  |||       }}t        |t              r|j                         }t        j                  | ||||t        j                  t        j                         ||	      S c c}w c c}w )z9Return the template context for a given page or template..)	navpagesbase_url	extra_cssextra_javascriptmkdocs_versionbuild_date_utcconfigpage)r	   get_relative_urlurlr   normalize_urlstrr   
isinstancer   documentation_pagesr   TemplateContextmkdocs__version__get_build_datetime)	r   filesr    r!   r   scriptr   pathr   s	            W/var/www/html/content_weaver/venv/lib/python3.12/site-packages/mkdocs/commands/build.pyget_contextr0      s     ))#txx8 HNG^G^=CCKx8  HNGWGWXt$$T4:XIX%))+$$)))//1
 
 Ys   'C&(C+c                   |j                   j                  || |      }t        j                  |       r$t	        |j
                  xs d      j                  }nt        j                  d|       }t        ||||      }|j                   j                  || |      }|j                  |      }|j                   j                  || |      }|S )z6Return rendered output for given template as a string.)template_namer    /r   )r   )pluginson_pre_templater	   is_error_templater   site_urlr.   r"   r0   on_template_contextrenderon_post_template)nametemplater,   r    r   r   contextoutputs           r/   _build_templater?   =   s    
 ~~--hdSY-ZHt$ FOO2s388))#t4#ufx@G nn00U[0\G__W%F ^^,,V4PV,WFM    c                z   t         j                  d|         	 |j                  |       }t        | ||||      }|j                         rt        j                  j                  |j                  |       }t        j                  |j                  d      |       | dk(  rt         j                  d|         | d}t        |d	      5 }	t        j                  |j!                         D 	cg c]  }	|	j"                  |	j"                   c}	
      }
t%        j&                  	|d	|
      5 }|j)                  |j                  d             ddd       ddd       yyt         j+                  d|  d       y# t        $ r t         j	                  d|  d       Y yw xY wc c}	w # 1 sw Y   ZxY w# 1 sw Y   yxY w)z-Build a template using the theme environment.zBuilding theme template: Template skipped: 'z!' not found in theme directories.Nutf-8zsitemap.xmlzGzipping template: z.gzwb)r   )fileobjfilenamemodemtime' generated empty output.)logdebugget_templater   warningr?   striposr.   joinsite_dirr	   
write_fileencodeopenget_build_timestampr'   r!   gzipGzipFilewriteinfo)r2   envr,   r    r   r<   r>   output_pathgz_filenamef	timestampgz_bufs               r/   _build_theme_templater`   [   s    II)-9:##M2
 ]HeVSIF||~ggll6??MBw/=M)II+M?;<(M-Kk4( 9A!55+0+D+D+F]a!&&J\166]	 ]]$i 9LLw!789	9 9 * 	&}o5NOP-  )-8YZ[ ^9 9	9 9sM   E8 "F1*F 
<F 

!F1+!F%F18"FF F1%F.	*F11F:c                    t         j                  d|         |j                  |       }|t         j                  d|  d       y	 t	        j
                  |j                        }t        | ||||      }|j                         r0t        j                  |j                  d      |j                         yt         j                  d|  d       y# t        $ r%}t         j                  d|  d|        Y d}~yd}~ww xY w)	z5Build user templates which are not part of the theme.zBuilding extra template: NrB   z' not found in docs_dir.zError reading template 'z': rC   rI   )rJ   rK   get_file_from_pathrM   jinja2Templatecontent_string	Exceptionr?   rN   r	   rR   rS   abs_dest_pathrY   )r2   r,   r    r   filer<   er>   s           r/   _build_extra_templaterj   |   s    II)-9:##M2D|)-8PQR??4#6#67
 ]HeVSIF||~w/1C1CD&}o5NOP  .}oSDEs   C 	C=C88C=Fc                   | |_         	 |r#| j                  j                         s		 d|_         y|j                  j	                  | ||      } | j                  |       | j                  J |j                  j                  | j                  | ||      | _        | j                  ||       | j                  J |j                  j                  | j                  | ||      | _	        	 d|_         y# t        $ rM}d| j                  j                   d}t        |t              s|d| z  }t        j!                  |        d}~ww xY w# d|_         w xY w)z4Read page content from docs_dir and render Markdown.Nr    r,   )r!   r    r,   zError reading page '': )_current_pagerh   is_modifiedr4   on_pre_pageread_sourcemarkdownon_page_markdownr9   contenton_page_contentrf   src_urir&   r   rJ   error)r!   r    r,   dirtyri   messages         r/   _populate_pager{      sH   F $ ..08  $3 ~~))$vU)K }}((( 77MMV5 8 
 	FE"||''' ~~55LLtF% 6 
  $  ():):(;2>!Z(1#wG		'  $s*   C0 B9C0 0	E9AEEE	 		Ec                   | |_         	 |r*| j                  j                         s	 d| _        d|_         yt        j                  d| j                  j                          d| _        t        ||||       }|j                  | j                  j                  dd            }|j                  j                  || ||      }|rd| j                  xs d	z   | _        |j                  |      }	|j                  j                  |	| |
      }	|	j!                         r<t#        j$                  |	j'                  dd      | j                  j(                         n-t        j+                  d| j                  j                   d       d| _        d|_         y# t,        $ rM}
d| j                  j                   d}t/        |
t0              s|d|
 z  }t        j3                  |        d}
~
ww xY w# d| _        d|_         w xY w)z;Pass a Page to theme template and write output to site_dir.FNzBuilding page Tr<   z	main.html)r!   r    r   zh<div class="mkdocs-draft-marker" title="This page will not be included into the built site.">DRAFT</div> )r!   r    rC   xmlcharrefreplace)errorszPage skipped: 'z'. Generated empty output.zError building page 'rm   rn   )ro   rh   rp   activerJ   rK   rw   r0   rL   metagetr4   on_page_contextru   r9   on_post_pagerN   r	   rR   rS   rg   rY   rf   r&   r   rx   )r!   r    	doc_filesr   rZ   ry   excludedr=   r<   r>   ri   rz   s               r/   _build_pager      s     F2$ ..0Z #Y 			N499#4#4"567 c9fd; ##DIIMM*k$JK ..00tFX[0\ LL.B0 L ) ,,V$v,N <<>g.ABDIID[D[ HHtyy'8'8&99STU #  )$))*;*;)<B?!Z(1#wG		' #s*   F EF 	G'AG""G''G* *G:)	serve_urlry   c               
   t        j                  d      }t        j                         }|j	                  t         j
                         | j                  r$t        j                  d      j                  |       |rt        j                  nt        j                  }	 t        j                         }| j                  j                  |       } | j                  j                  |        |s5t         j#                  d       t        j$                  | j&                         nt         j)                  d       |sNt         j#                  d| j&                          |r*t+        | j&                        rt         j#                  d       t-        |       }| j.                  j1                         }|j3                  ||        | j                  j5                  ||       }t7        ||        t9        ||       }	| j                  j;                  |	| |      }	t         j=                  d       g }
|j?                  |	      D ]  }t         j=                  d
|j@                          |jB                  h|jD                  jG                         rN|r?|jD                  jI                         r%|
jK                  tM        ||jN                               tQ        d||        |jB                  J tS        |jB                  | ||        |
r't         j#                  ddjU                  |
      z          | j                  jW                  || |      }t         j=                  d       |jY                  ||       | j.                  jZ                  D ]  }t]        |||| |	        | j^                  D ]  }ta        ||| |	        t         j=                  d       |j?                  |	      }|D ]D  }|jB                  J tc        |jB                  | ||	|||jD                  jI                                F | jd                  jf                  jh                  }|D ]-  }|jB                  J |jB                  jk                  ||       / | j                  jm                  |        |jo                         x}r'djU                  d |D              }tq        d| d      t         j#                  dt        j                         |z
  dd       	 |j                  |       y# tr        $ r[}| j                  ju                  |       tw        |tx              r)t         j{                  t}        |             tq        d       d}~ww xY w# |j                  |       w xY w)zPerform a full site build.r)   )r    zCleaning site directoryzA 'dirty' build is being performed, this will likely lead to inaccurate navigation and other links within your site. This option is designed for site development purposes only.z%Building documentation to directory: z?The directory contains stale files. Use --clean to remove them.rl   zReading markdown pages.)	inclusionz	Reading: NzThe following pages are being built only for the preview but will be excluded from `mkdocs build` per `draft_docs` config:
  - z
  - zCopying static assets.)ry   r   zBuilding markdown pages.)r   )r,   	log_levelz, c              3  N   K   | ]  \  }}| d |j                          d  yw)rn   sN)lower).0kvs      r/   	<genexpr>zbuild.<locals>.<genexpr>^  s'     CDAqqc1779+Q/Cs   #%zAborted with z in strict mode!zDocumentation built in z.2fz seconds)rx   zAborted with a BuildError!)@logging	getLoggerr	   CountHandlersetLevelWARNINGstrict
addHandlerr   is_in_serveis_includedtime	monotonicr4   	on_configon_pre_buildrJ   rY   clean_directoryrQ   rM   #site_directory_contains_stale_filesr   themeget_envadd_files_from_themeon_filesr   r   on_navrK   r'   rw   r!   r   is_not_in_navis_excludedappendr   r#   r   r{   rP   on_envcopy_static_filesstatic_templatesr`   extra_templatesrj   r   
validationlinksanchorsvalidate_anchor_linkson_post_build
get_countsr
   rf   on_build_errorr&   r   rx   r%   removeHandler)r    r   ry   loggerwarning_counterr   startr,   rZ   r   r   rh   r<   r   r   countsmsgri   s                     r/   buildr      s   x(F ((*OW__-}}(#..?.7**^=W=WIg.  ))&1 	##6#2HH./!!&//2 KKg
 HH<V__<MNO<V__MZ[ &!ll""$""3/ ''f'=uf%UF+ nn##Ce#D		+,--	-B 	<DII	$,,01yy T^^%A%A%C!;!;!=OOGItxx$@AT4(99(((499feU;	< HHZ--)* nn##Ce#D
 			*+eyA55 	EH!(CD	E .. 	@H!(E63?	@ 			,---	-B	 	D99(((		69c3HbHbHd	 %%++33	 	ND99(((II++%9+M	N
 	$$F$3$//1161))CFCCC-u,<=>>*4>>+;e+CC*HQR 	_-  %%A%.a$IIc!f455 	_-s&   QT 	U,AU''U,,U/ /Vc                    t        t        j                  j                  |       xr t        j                  |             S )zGCheck if the site directory contains stale files from a previous build.)boolrO   r.   existslistdir)site_directorys    r/   r   r   o  s(    ~.M2::n3MNNr@   )Nr}   )r   r   r,   zSequence[File] | Filesr    r   r!   zPage | Noner   r%   returnztemplates.TemplateContext)r;   r%   r<   zjinja2.Templater,   r   r    r   r   r   r   r%   )r2   r%   rZ   jinja2.Environmentr,   r   r    r   r   r   r   None)r2   r%   r,   r   r    r   r   r   )F)
r!   r   r    r   r,   r   ry   r   r   r   )FF)r!   r   r    r   r   zSequence[File]r   r   rZ   r   ry   r   r   r   r   r   )r    r   r   z
str | Nonery   r   r   r   )r   r%   r   r   )/
__future__r   rV   r   rO   r   typingr   r   urllib.parser   r   rc   jinja2.exceptionsr   r)   r	   mkdocs.exceptionsr
   r   mkdocs.structure.filesr   r   r   r   r   mkdocs.structure.navr   r   mkdocs.structure.pagesr   mkdocs.utilsr   r   mkdocs.config.defaultsr   r   __name__rJ   r0   r?   r`   rj   r{   r   r   r    r@   r/   <module>r      s   "   	  * *  .   / Y Y ; ' ( "3 g! 	!  	
  @
(16@LS]<QQ/Q8=QGSQZdQ	QBQ.#$X =$
=$=$ =$ 
	=$
 
=$ =$ =$ 
=$@ <@u s.lOr@   