
    2yiV                       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m	Z	m
Z
mZmZ d dlmZ d dlmZmZmZ d dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d d	lmZ d d
l m!Z!m"Z"m#Z#m$Z$m%Z% d dl&m'Z' erd dl(m)Z* d dl+m,Z, d dl-m.Z.m/Z/ d dlm0Z0  ejb                  e2      Z3 G d de      Z4 G d dejj                  jl                        Z7 G d dejj                  jl                        Z8 G d dejr                  jt                        Z; G d dejx                  jx                  jz                        Z> G d dejj                  jl                        Z? G d dej                        ZAy)    )annotationsN)TYPE_CHECKINGAnyCallableIteratorMutableMappingSequence)unquote)urljoinurlsplit
urlunsplit)AMP_SUBSTITUTE)utils)StructureItem)get_toc)_removesuffixget_build_dateget_markdown_titlemetaweak_property)get_heading_text)ElementTree)MkDocsConfig)FileFiles)TableOfContentsc                     e Zd ZU d,dZd-dZd Zded	<   	 ded
<   	 ded<   	 ded<   	 ed.d       Zded<   	 ded<   	 ded<   	 ed-d       Z	e	j                  d/d       Z	ed-d       Zded<   	 ed-d       Zded<   	 ded<   	 dZded<   	 dZded<   	 dZded<   	 dZded <   	 d0d!Z	 	 d1	 	 	 	 	 	 	 d2d"Zd3d#Zd4d$Zed5d%       Zd6d&ZdZd'ed(<   	 dZd)ed*<   	 d7d+Zy)8Page
str | Nonefiler   Nonec                   | |_         || _        ||| _        d | _        d | _        d | _        d| _        t               | _        | j                  |j                  dd              | j                  |j                  dd       |j                  d      |j                  d             d | _        d | _        d | _        g | _        i | _        y )NFsite_urlrepo_urledit_uriedit_uri_template)pager    titlechildrenprevious_page	next_pageactiver   update_date_set_canonical_urlget_set_edit_urlmarkdown_title_from_rendercontenttocr   )selfr(   r    configs       X/var/www/html/content_weaver/venv/lib/python3.12/site-packages/mkdocs/structure/pages.py__init__zPage.__init__$   s    		DJ ! . 0

:t <=JJz4(&**Z*@&**M`Ba	

 .2	    boolc                    t        || j                        xr4 | j                  |j                  k(  xr | j                  |j                  k(  S N)
isinstance	__class__r(   r    )r5   others     r7   __eq__zPage.__eq__>   s?    udnn- (

ekk)(		UZZ'	
r9   c                    | j                   j                  }| j                  | j                  nd}| j                  xs | j                  j
                  }| d| d|dS )Nz[blank]z(title=z, url=))r>   __name__r(   abs_urlr    url)r5   namer(   rE   s       r7   __repr__zPage.__repr__E   sV    ~~&&%)ZZ%;4::.ll+diimmwugVC7!44r9   r1   r3   r   r4   zMutableMapping[str, Any]r   c                <    | j                   j                  }|dv ry|S )z6The URL of the page relative to the MkDocs `site_dir`.)../ )r    rE   )r5   rE   s     r7   rE   zPage.urlZ   s!     iimm+
r9   rD   canonical_urlc                    | j                   S )zXWhen `True`, indicates that this page is the currently viewed page. Defaults to `False`.)_Page__activer5   s    r7   r,   zPage.activeq   s     }}r9   c                r    t        |      | _        | j                  t        |      | j                  _        yy)z(Set active status of page and ancestors.N)r:   rN   parentr,   )r5   values     r7   r,   zPage.activev   s.     U;;"!%eDKK #r9   c                4    | j                   j                  dk(  S )Nindex)r    rF   rO   s    r7   is_indexzPage.is_index}   s    yy~~((r9   edit_urlc                j    | j                   xr& | j                  xr | j                  j                  dv S )zQEvaluates to `True` for the homepage of the site and `False` for all other pages.)rI   rJ   z
index.html)is_top_levelrU   r    rE   rO   s    r7   is_homepagezPage.is_homepage   s,       aT]]atyy}}Ha7aar9   zPage | Noner*   r+   Nr)   F
is_sectionTis_pageis_linkc                    |rN|j                  d      s|dz  }t        || j                        x| _        }t	        |      j
                  | _        y d | _        d | _        y N/)endswithr   rE   rL   r   pathrD   )r5   baserL   s      r7   r.   zPage._set_canonical_url   sS    ==%18txx1HHD#M277DL!%DDLr9   c                F   |s
|sd | _         y | j                  j                  }|d | _         y |r,t        j                  |      d   }|j                  ||      }n||j                  d      sJ ||z   }|r(|j                  d      sT|j                  d      sC|dz  }n=	 t        |      }|j                  r|j                  st        j                  d|d       t        |xs d|      | _         y # t        $ r%}t        j                  d|d|        Y d }~?d }~ww xY w)	Nr   )ra   
path_noextr_   )?#z
edit_uri: z; is not a valid URL, it should include the http:// (scheme)z is not a valid URL: rK   )rV   r    r%   	posixpathsplitextformatr`   
startswithr   schemenetloclogwarning
ValueErrorr   )	r5   r$   r%   r&   src_urinoextfile_edit_uri
parsed_urles	            r7   r0   zPage._set_edit_url   s*    ! DM))$$? DM&&w/2E-44'e4TM'H,=,=c,BBB$w.M ++J7@Q@QRU@VCT%m4
!((
0A0AKK$]$55pq  B>  Tj(99NqcRSSTs    <C2 2	D ;DD c                   |j                   j                  | |      }|	 | j                  j                  }t        j                  |      \  | _        | _	        y # t        $ r. t
        j                  d| j                  j                           t        $ r. t
        j                  d| j                  j                           w xY w)N)r'   r6   zFile not found: zEncoding error reading file: )pluginson_page_read_sourcer    content_stringOSErrorrm   errorsrc_pathro   r   get_datar1   )r5   r6   sources      r7   read_sourcezPage.read_source   s    33f3M>11 $(==#8 ty  		,TYY-?-?,@AB 		9$)):L:L9MNOs   A A,Cc                8    t        j                  dt               y )Nz@_set_title is no longer used in MkDocs and will be removed soon.)warningswarnDeprecationWarningrO   s    r7   
_set_titlezPage._set_title   s    NPb	
r9   c                   | j                   yd| j                  v r| j                  d   S | j                  r| j                  S | j                  t	        | j                         }||S | j
                  ry| j                  j                  j                  dd      j                  dd      }|j                         |k(  r|j                         }|S )a  
        Returns the title for the current page.

        Before calling `read_source()`, this value is empty. It can also be updated by `render()`.

        Checks these in order and uses the first that returns a valid title:

        - value provided on init (passed in from config)
        - value of metadata 'title'
        - content of the first H1 in Markdown content
        - convert filename to title
        Nr(   Home- _)r1   r   r2   r3   r   rY   r    rF   replacelower
capitalize)r5   title_from_mdr(   s      r7   r(   z
Page.title   s     == dii99W%%""***\\!.t}}=M($$		&&sC088cB;;=E!$$&Er9   c                   | j                   t        d      t        j                  |d   |d   xs i       }t               }|j	                  |       t        | j                  ||      }|j	                  |       t        | j                  ||      }|j	                  |       t               }|j	                  |       |j                  | j                         | _
        t        t        |dg             | _        |j                  | _        |j                   |j                   z  | _        t"        j%                         t&        j(                  kD  r|j*                  | _        yy)z;Convert the Markdown source file to HTML as per the config.Nz4`markdown` field hasn't been set (via `read_source`)markdown_extensionsmdx_configs)
extensionsextension_configs
toc_tokens)r1   RuntimeErrorMarkdown_RawHTMLPreprocessor	_register_ExtractAnchorsTreeprocessorr    _RelativePathTreeprocessor_ExtractTitleTreeprocessorconvertr3   r   getattrr4   r(   r2   present_anchor_idsrm   getEffectiveLevelloggingDEBUGlinks_to_anchors)r5   r6   filesmdraw_html_extextract_anchors_extrelative_path_extextract_title_exts           r7   renderzPage.render  s,   == UVV34$]39r

 ,-r":499eVT%%b)6tyy%P##B'68##B'zz$--072|R89"3"9"922\5T5TT 	   "W]]2$5$F$FD! 3r9   zset[str] | Noner   z!dict[File, dict[str, str]] | Noner   c                  | j                   sy | j                   j                         D ]  \  }}|j                         D ]  \  }}|j                  }||j                  "||j                  v r1d}|| j                  k(  rd}	|j                  d      rd}nd|j                   d| d}	t        j                  |d| j                  j                   d	| d
|	 d|          y )NrK   z$there is no such anchor on this pagezfnref:z6 This seems to be a footnote that is never referenced.z	the doc 'z' does not contain an anchor '#'
Doc file '' contains a link 'z', but rI   )r   itemsr'   r   r    rj   rp   rm   )
r5   r   	log_levelto_filelinksanchororiginal_linkr'   contextproblems
             r7   validate_anchor_linkszPage.validate_anchor_links0  s    $$"3399; 	NGU). %||<**2T444dii'DG((2"Z )'//)::YZ`YaabcG !2!2 33F}oU\]d\eefgnfop	r9   )r(   r   r    r   r6   r   returnr!   )r   r:   )r   str)rR   r:   )rb   r   r   r!   )NN)r$   r   r%   r   r&   r   r   r!   )r6   r   r   r!   r   r!   )r   r   )r6   r   r   r   r   r!   )r   r   r   intr   r!   )rC   
__module____qualname__r8   r@   rG   __annotations__propertyrE   r,   setterrU   rY   r)   rZ   r[   r\   r.   r0   r~   r   r   r(   r   r   r   r    r9   r7   r   r   #   s   4
5 6$ 
H #"M  Jg'
 
   ]]- - ) )  b b H H HdKJfGTbGTc   $(,	#?#? #? &	#?
 
#?J9

 ! !FG> +/.M:>7>r9   r   c                  $    e Zd ZddZddZddZy)r   c                "    t               | _        y r<   )setr   r5   r    r   r6   s       r7   r8   z%_ExtractAnchorsTreeprocessor.__init__J  s    ,/Er9   c                    | j                   j                  }|j                         D ]I  }|j                  d      x}r ||       |j                  dk(  s.|j                  d      x}sB ||       K y )NidarF   )r   additerr/   tag)r5   rootr   elementr   s        r7   runz _ExtractAnchorsTreeprocessor.runM  sj    %%))yy{ 	 G T**v*F{{c!$[[0060K	 r9   c                @    |j                   j                  | dd       y )Nmkdocs_extract_anchors   prioritytreeprocessorsregisterr5   r   s     r7   r   z&_ExtractAnchorsTreeprocessor._registerV  s    
""4)AA"Nr9   Nr    r   r   r   r6   r   r   r!   )r   etree.Elementr   r!   r   markdown.Markdownr   r!   )rC   r   r   r8   r   r   r   r9   r7   r   r   I  s    2 Or9   r   c                  f    e Zd ZddZd	dZed
d       Ze	 d	 	 	 	 	 	 	 	 	 dd       ZddZddZ	y)r   c                <    || _         || _        || _        i | _        y r<   )r    r   r6   r   r   s       r7   r8   z#_RelativePathTreeprocessor.__init__[  s    	
<>r9   c                    |j                         D ]_  }|j                  dk(  rd}n|j                  dk(  rd}n(|j                  |      }|J | j                  |      }|j	                  ||       a |S )z
        Update urls on anchors and images to make them relative.

        Iterates through the full document tree looking for specific
        tags and then makes them relative based on the site navigation
        r   hrefimgsrc)r   r   r/   path_to_urlr   )r5   r   r   keyrE   new_urls         r7   r   z_RelativePathTreeprocessor.runa  s{     yy{ 	&G{{c!%++c"C?"?&&s+GKKW%	& r9   c                    t        j                  t        j                  t        j                  |      |      j	                  d            S r^   )rg   normpathjoindirnamelstrip)clsr{   	dest_paths      r7   _target_uriz&_RelativePathTreeprocessor._target_uriw  s9    !!NN9,,X6	BII#N
 	
r9   c              #    K   | j                  |j                  |      }| t        j                  |      dk(  r|j                   y|h}|| j                  |j                  |      g}|d   |d   k(  r|j                          g }|r|j                  d        t        j                  |      d   s$|j                  d        |j                  d        |j                  d      s6|j                  d	      s%|s|j                  d
      s|j                  d        |D ]P  }	|D ]I  }
t        j                   |
|	            }||vs#|j                  d      r5| |j                  |       K R yw)zfFirst yields the resolved file uri for the link, then proceeds to yield guesses for possible mistakes.rI   Nr      c                    | S r<   r   ps    r7   <lambda>zB_RelativePathTreeprocessor._possible_target_uris.<locals>.<lambda>  s    a r9   c                .    t        j                  | d      S )Nzindex.mdrg   r   r   s    r7   r   zB_RelativePathTreeprocessor._possible_target_uris.<locals>.<lambda>  s    innQ
&C r9   c                .    t        j                  | d      S )Nz	README.mdr   r   s    r7   r   zB_RelativePathTreeprocessor._possible_target_uris.<locals>.<lambda>  s    innQ&D r9   .mdr_   c                     t        | d      dz   S )Nz.htmlr   )r   r   s    r7   r   zB_RelativePathTreeprocessor._possible_target_uris.<locals>.<lambda>  s    mAw&?%&G r9   z../)r   rp   rg   r   rE   popappendrh   r`   rj   r   )r   r    ra   use_directory_urlssuggest_absolute
target_uritriedprefixessuffixesprefsufguesss               r7   _possible_target_urisz0_RelativePathTreeprocessor._possible_target_uris}  sI    
 __T\\48
d#s*,,$ ?@A;(1+%LLN/1OOK(!!*-b1OOCDOODE##C(MM%(#4==+=OOGH 	%D %!**3t95%e.>.>u.EKIIe$	%	%s   EE5	E5E5c                   t        |      \  }}}}}d }d\  }}	|s|r|S |j                  d      r\| j                  j                  j                  j
                  }|t        j                  urf|}d| j                  j                   d| d}	nFt        |v r|S |s:|r6| j                  j                  | j                  i       j                  ||       |S t        |      }| j                  | j                  || j                  j                        }
|	r|}d }n&t!        |
      }| j"                  j%                  |      }||	st'        j(                  |      d   sJ|H| j                  j                  j                  j*                  }d| j                  j                   d| d}	nf||j-                  d      k7  rd	| d
nd}| j                  j                  j                  j.                  }d| j                  j                   d| d| d}	|	r| j                  j0                  j3                         rt5        t6        j8                  |      }|t6        j:                  kD  rd}|
D ]  }| j"                  j%                  |      |r|| j                  j                  k(  rd}nB|t        j                  u rd|z   }n*t=        j>                  || j                  j                        }tA        dd|||f      } n d|v rd|v r	d|vrd| }|r	|	d| dz  }	tB        jC                  ||	       |S |J |J |r,| j                  j                  |i       j                  ||       |j0                  j3                         r| j                  j0                  j3                         rt6        j:                  }nBt5        t6        j8                  | j                  j                  j                  j.                        }d| j                  j                   d| d}	tB        jC                  ||	       t=        j>                  |jD                  | j                  jD                        }tA        dd|||f      S )N)r   rK   )r_   \r   z' contains an absolute link 'z', it was left as is.r   z*' contains an unrecognized relative link 'r_   z 'r   rK   r   z', but the targetz( is not found among documentation files.@rI   zmailto:z Did you mean 'z'?z' contains a link to 'z(' which is excluded from the built site.)#r   rj   r6   
validationr   absolute_links_AbsoluteLinksValidationValueRELATIVE_TO_DOCSr    rp   r   r   
setdefault
urlunquoter  r   nextr   get_file_from_pathrg   rh   unrecognized_linksr   	not_found	inclusionis_excludedminr   INFOr   r   get_relative_urlr   rm   rE   )r5   rE   rk   rl   ra   queryr   absolute_linkwarning_levelrn   possible_target_urisr   target_filetargetsuggest_urls                  r7   r   z&_RelativePathTreeprocessor.path_to_url  s   .6sm+eV!&w VJ^^K( KK2288GGM$A$R$RR -&tyy'8'8&99VWZV[[pqs"J%%00B?JJ6SVWJ$#99IItT[[;; 
 JK 23J**77
CKw%%d+B/M4I $ 6 6 < < O O !2!2 33]^a]b c) * 
 0:SZZ_/L2j\+RT $ 6 6 < < F F !2!2 33Fse L%%+H,TV 
 yy""..0 #GLL- @ w}}, 0 6Dzz44T:F!ddii.?.?&?#%D*.K.\.\\#&:D#(#9#9$		@Q@Q#RD&0"b$v1N&O6 czcSjS^(/uoR@@GGGM7+J%%%&&&!!,,["=HHQTU  ,,.yy""..0 ' #GLL$++2H2H2N2N2X2X YTYY../ 0<GI  GGM7+%%kootyy}}E2r4788r9   c                >    |j                   j                  | dd       y )Nrelpathr   r   r   s     r7   r   z$_RelativePathTreeprocessor._register  s    
""4A6r9   Nr   r   r   r   r   )r{   r   r   r   r   r   )F)
r    r   ra   r   r   r:   r   r:   r   zIterator[str])rE   r   r   r   r   )
rC   r   r   r8   r   classmethodr   r  r   r   r   r9   r7   r   r   Z  sl    ?, 
 

 W\#%#%"#%8<#%PT#%	#% #%Ja9F7r9   r   c                  0     e Zd Zd fdZddZddZ xZS )r   c                @    t         |           t               | _        y r<   superr8   r   r   r5   r>   s    r7   r8   z_RawHTMLPreprocessor.__init__      ,/Er9   c                    t               }|j                  dj                  |             |j                          |j                  | _        |S )N
)_HTMLHandlerfeedr   closer   )r5   linesparsers      r7   r   z_RawHTMLPreprocessor.run  s:    DIIe$%"(";";r9   c                @    |j                   j                  | dd       y )Nmkdocs_raw_html   r   )preprocessorsr   r   s     r7   r   z_RawHTMLPreprocessor._register  s#    
!!#b 	" 	
r9   r   )r*  	list[str]r   r0  r   )rC   r   r   r8   r   r   __classcell__r>   s   @r7   r   r   
  s    2
r9   r   c                  ,     e Zd Zd fdZd fdZ xZS )r'  c                @    t         |           t               | _        y r<   r!  r#  s    r7   r8   z_HTMLHandler.__init__  r$  r9   c                    |D ]1  \  }}|dk(  s|dk(  s|dk(  s| j                   j                  |       3 t        |   ||      S )Nr   rF   r   )r   r   r"  handle_starttag)r5   r   attrskvr>   s        r7   r6  z_HTMLHandler.handle_starttag!  sQ     	/DAqDyQ&[SCZ''++A.	/ w&sE22r9   r   )r   r   r7  zSequence[tuple[str, str]]r   r!   )rC   r   r   r8   r6  r1  r2  s   @r7   r'  r'    s    23 3r9   r'  c                  6    e Zd ZU dZded<   ded<   ddZd	dZy)
r   Nr   r(   r   r   c                l    |D ].  }|j                   dk(  rt        || j                        | _         |S  |S )Nh1)r   r   r   r(   )r5   r   els      r7   r   z_ExtractTitleTreeprocessor.run,  s=     	Bvv~-b$'':
		 r9   c                N    || _         |j                  j                  | dd       y )Nmkdocs_extract_titler   r   )r   r   r   r   s     r7   r   z$_ExtractTitleTreeprocessor._register3  s%    
""4)?!"Lr9   r  r   )rC   r   r   r(   r   r   r   r   r9   r7   r   r   (  s    E:Mr9   r   c                      e Zd ZdZy)r  r   N)rC   r   r   r  r   r9   r7   r  r  8  s    r9   r  )B
__future__r   enumr   rg   r   typingr   r   r   r   r   r	   urllib.parser
   r
  r   r   r   r1   markdown.extensions.tocmarkdown.htmlparsermarkdown.postprocessorsmarkdown.treeprocessorsmarkdown.utilr   mkdocsr   mkdocs.structurer   mkdocs.structure.tocr   mkdocs.utilsr   r   r   r   r   mkdocs.utils.renderingr   	xml.etreer   etreemkdocs.config.defaultsr   mkdocs.structure.filesr   r   r   	getLoggerrC   rm   r   r   Treeprocessorr   r   r/  Preprocessorr   
htmlparser
HTMLParserr'  r   IntEnumr  r   r9   r7   <module>rY     s   "     S S . 6 6      (  * ( _ _ 3.324 g!c= cL	O8#:#:#H#H O"m7!8!8!F!F m7`
811>> 
$	38&&11<< 	3M!8!8!F!F M DLL r9   