
    O&iQ                     V   d Z ddlmZmZmZmZmZ ddlmZ ddl	m
Z
mZ ddlmZ ddlm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 ddlmZmZ ddl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j)        e*          Z+ G d dej,        ej
                  Z- G d dej.        ej
                  Z/ G d dee!          Z0 G d de          Z1 G d de!          Z2 G d d          Z3de&d e-d!dfd"Z4de&d e-d!dfd#Z5de(d e-d!dfd$Z6de(d e-d!dfd%Z7d&ed!ee8ef         fd'Z9dS )(zAllow todos to be inserted into your documentation.

Inclusion of todos can be switched of by a configuration variable.
The todolist directive collects all todos of your project and lists them along
with a backlink to the original location.
    )AnyDictListTuplecast)nodes)ElementNode)
directives)BaseAdmonitionN)addnodes)Sphinx)Domain)BuildEnvironment)NoUri)___)logging	texescape)SphinxDirectivenew_document)
OptionSpec)HTMLTranslator)LaTeXTranslatorc                       e Zd ZdS )	todo_nodeN__name__
__module____qualname__     \/home/geonatureadmin/si_en_reseau/tutos/venv/lib/python3.11/site-packages/sphinx/ext/todo.pyr   r              Dr"   r   c                       e Zd ZdS )todolistNr   r!   r"   r#   r&   r&   #   r$   r"   r&   c                   r     e Zd ZU dZeZdZdZdZdZ	e
j        e
j        dZeed<   dee         f fdZ xZS )	TodozO
    A todo entry, displayed (if configured) in the form of an admonition.
    Tr   F)classnameoption_specreturnc                 &   | j                             d          sdg| j         d<   t                                                      \  }t	          |t
          j                  r|gS t	          |t                    r|                    dt          j	        t          d                               | j        j        |d<   |                     |           |                     |           | j        j                            |           |gS t$          )Nr)   zadmonition-todor   r(   )textdocname)optionsgetsuperrun
isinstancer   system_messager   inserttitler   envr/   add_nameset_source_infostatedocumentnote_explicit_targetRuntimeError)selftodo	__class__s     r#   r3   zTodo.run6   s    |(( 	8%6$7DL!''++--dE011 
	6Mi(( 	KK5;AfII666777"h.DOMM$  &&&J44T:::6Mr"   )r   r   r    __doc__r   
node_classhas_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacer   class_option	unchangedr+   r   __annotations__r   r
   r3   __classcell__)rA   s   @r#   r(   r(   '   s           JK %($ K   
T$Z          r"   r(   c                       e Zd ZdZdZedeeee	         f         fd            Z
deddfdZdee         deddfd	Zd
ededej        ddfdZdS )
TodoDomainr@   r,   c                 8    | j                             di           S Ntodos)data
setdefaultr?   s    r#   rP   zTodoDomain.todosL   s    y##GR000r"   r/   Nc                 <    | j                             |d            d S N)rP   pop)r?   r/   s     r#   	clear_doczTodoDomain.clear_docP   s    
w%%%%%r"   docnames	otherdatac                 <    |D ]}|d         |         | j         |<   d S rO   )rP   )r?   rX   rY   r/   s       r#   merge_domaindatazTodoDomain.merge_domaindataS   s4     	> 	>G"+G"4W"=DJw	> 	>r"   r8   r<   c                 r   | j                             |g           }|                    t                    D ]}|j                            d|           |                    |           |j        j        rBt          
                    t          d          |d                                         |           d S )Ntodo-definedzTODO entry found: %s   )location)rP   rR   findallr   appemitappendconfigtodo_emit_warningsloggerwarningr   astext)r?   r8   r/   r<   rP   r@   s         r#   process_doczTodoDomain.process_docW   s    
%%gr22$$Y// 	. 	.DGLL...LLz, .r"89947>>;K;K(,  . . .	. 	.r"   )r   r   r    r*   labelpropertyr   strr   r   rP   rW   r[   r   r   r<   ri   r!   r"   r#   rM   rM   H   s        DE1tCi01 1 1 1 X1& & & & & &>c >t > > > > >	./ 	.# 	.#n	.15	. 	. 	. 	. 	. 	.r"   rM   c                   J    e Zd ZU dZdZdZdZdZi Ze	e
d<   dee         fdZdS )TodoListz%
    A list of all todo entries.
    Fr   r+   r,   c                 "    t          d          gS )N )r&   rS   s    r#   r3   zTodoList.runn   s     ~r"   N)r   r   r    rB   rD   rE   rF   rG   r+   r   rJ   r   r
   r3   r!   r"   r#   rn   rn   c   sh           K % K   T$Z      r"   rn   c                       e Zd Zdedej        deddfdZdej        deddfdZde	dedej
        fd	Zde	deddfd
ZdS )TodoListProcessorra   doctreer/   r,   Nc                    |j         | _         |j        | _        |j        | _        t          t          |j                            d                    | _        t          d          | _        | 	                    ||           d S )Nr@   rp   )
builderrd   r8   r   rM   
get_domaindomainr   r<   process)r?   ra   rs   r/   s       r#   __init__zTodoListProcessor.__init__u   sg    {j7:sw'9'9&'A'ABB$R((Wg&&&&&r"   c                    t          | j        j                                        g           }t	          |                    t                              D ]}| j        j        s|j	        
                    |           )|                    d          rt          j                    g}ng }|D ]}|                                }|d                                          |                     ||           |                    |           |                     ||          }|                    |           |                    |           d S )Nids)sumrw   rP   valueslistr`   r&   rd   todo_include_todosparentremover1   r   targetdeepcopyclearresolve_referencerc   create_todo_referencereplace_self)	r?   rs   r/   rP   nodecontentr@   new_todotodo_refs	            r#   rx   zTodoListProcessor.process~   s7   !$T[%6%=%=%?%?!D!D2233 	' 	'D;1 ""4(((xx */,..)9 	) 	)==??%%'''&&x999x(((55dGDDx((((g&&&&+	' 	'r"   r@   c                    | j         j        rt          d          }nt          d          |j        |j        fz  }|d |                    d                   }||                    d          dz   d          }t          j        dg          }|t          j        |          z  }t          j	        t          d          t          d                    }t          j
        d	d	|d
          }	 | j                            ||d                   |d<   |dxx         d|d         d         z   z  cc<   n# t          $ r Y nw xY w||z  }|t          j        |          z  }|S )Nz<<original entry>>z3(The <<original entry>> is located in %s, line %d.)z<<z>>   ztodo-source)classeszoriginal entryrp   T)internalr/   refuri#r{   r   )rd   todo_link_onlyr   sourcelinefindr   	paragraphTextemphasis	referenceru   get_relative_urir   )	r?   r@   r/   descriptionprefixsuffixparalinktextr   s	            r#   r   z'TodoListProcessor.create_todo_reference   s|   ;% 	5011KKRSS K34K 4k..t4445[--d33a7889777
6""" >!$4"5"5q9I7J7JKKOBHtDDD		"&,"?"?i"Y"YIhh3eQ#77 	 	 	D	 		
6"""s   -AD1 1
D>=D>c                     |                     t          j                  D ]}d|v r||d<   | xj        |z  c_        | j                            | j        || j                   | j                            |           dS )z'Resolve references in the todo content.refdocN)r`   r   pending_xrefr<   r8   resolve_referencesru   r   )r?   r@   r/   r   s       r#   r   z#TodoListProcessor.resolve_reference   s    LL!677 	) 	)D4!(X 	##DM7DLIIIT"""""r"   )r   r   r    r   r   r<   rl   ry   rx   r   r   r   r   r!   r"   r#   rr   rr   t   s        'F 'U^ 'c 'd ' ' ' ''u~ ' ' ' ' ' '2) c eo    8	#i 	## 	#$ 	# 	# 	# 	# 	# 	#r"   rr   r?   r   r,   c                 `    | j         j        r|                     |           d S t          j        rU   )rd   r   visit_admonitionr   SkipNoder?   r   s     r#   visit_todo_noder      s1    {% d#####nr"   c                 0    |                      |           d S rU   )depart_admonitionr   s     r#   depart_todo_noder      s    4     r"   c                    | j         j        r| j                            d           | j                            |                     |                     t          t          j        |d                   }t          j	        |
                                | j         j                  }| j                            d|z             |                    d           d S t          j        )Nz 
\begin{sphinxadmonition}{note}{r   z%s:})rd   r   bodyrc   hypertarget_tor   r   r7   r   escaperh   latex_enginerV   r   )r?   r   
title_noder7   s       r#   latex_visit_todo_noder      s    {% 		=>>>	,,T22333%+tAw//
 !2!2!4!4dk6NOO	%(((nr"   c                 :    | j                             d           d S )Nz\end{sphinxadmonition}
)r   rc   r   s     r#   latex_depart_todo_noder      s    I011111r"   ra   c           	         |                      d           |                     ddd           |                     ddd           |                     ddd           |                     t                     |                     t          t
          t          ft          t          ft
          t          ft
          t          ft
          t          f           | 	                    dt                     | 	                    d	t                     |                     t                     |                     d
t                     t           j        dddS )Nr]   r   Fhtmlr   re   )r   latexr.   mantexinfor@   r&   zdoctree-resolvedr   T)versionenv_versionparallel_read_safe)	add_eventadd_config_valueadd_noder&   r   r   r   r   r   add_directiver(   rn   
add_domainrM   connectrr   sphinx__display_version__)ra   s    r#   setupr      s,   MM.!!!-uf===)5&999-uf===LLLL&(89-/EF&(89%'78)+;<  > > > fd###j(+++NN:KK"$5666-"  r"   ):rB   typingr   r   r   r   r   docutilsr   docutils.nodesr	   r
   docutils.parsers.rstr   +docutils.parsers.rst.directives.admonitionsr   r   r   sphinx.applicationr   sphinx.domainsr   sphinx.environmentr   sphinx.errorsr   sphinx.localer   r   sphinx.utilr   r   sphinx.util.docutilsr   r   sphinx.util.typingr   sphinx.writers.htmlr   sphinx.writers.latexr   	getLoggerr   rf   
Admonitionr   Generalr&   r(   rM   rn   rr   r   r   r   r   rl   r   r!   r"   r#   <module>r      sg    0 / / / / / / / / / / / / /       ( ( ( ( ( ( ( ( + + + + + + F F F F F F        % % % % % % ! ! ! ! ! ! / / / / / /               * * * * * * * * > > > > > > > > ) ) ) ) ) ) . . . . . . 0 0 0 0 0 0		8	$	$	 	 	 	 	 %- 	 	 		 	 	 	 	u}em 	 	 	    >?   B. . . . . . . .6       "H# H# H# H# H# H# H# H#V. 	 d    !> ! !t ! ! ! !
 
y 
T 
 
 
 
2 2	 2d 2 2 2 2v $sCx.      r"   