
    RiS                    :   d Z ddlmZ ddlZddlZddlmZ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mZ ddlmZmZ ddlmZmZ er6ddl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'm(Z( ddl)m*Z* ddl+m,Z,  ejZ                  e.      Z/ G d de	j`                  e	j@                        Z1 G d de	jd                  e	j@                        Z3 G d de      Z4 G d de      Z5 G d de      Z6 G d d       Z7d&d!Z8d&d"Z9d'd#Z:d'd$Z;d(d%Z<y))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.
    )annotationsN)TYPE_CHECKINGcast)nodes)addnodes)SphinxAdmonition)Domain)NoUri)___)logging	texescape)SphinxDirectivenew_document)Set)AnyClassVar)ElementNode)Sphinx)BuildEnvironment)ExtensionMetadata
OptionSpec)HTML5Translator)LaTeXTranslatorc                      e Zd Zy)	todo_nodeN__name__
__module____qualname__     G/home/agent/.friday_env/lib/python3.12/site-packages/sphinx/ext/todo.pyr   r   (       r#   r   c                      e Zd Zy)todolistNr   r"   r#   r$   r'   r'   ,   r%   r#   r'   c                  (     e Zd ZdZeZd fdZ xZS )TodozEA todo entry, displayed (if configured) in the form of an admonition.c                   | j                   j                  d      sdg| j                   d<   t        |          \  }t	        |t
              s|gS |j                  dt        j                  t        d                   | j                  j                  j                  |d<   | j                  |       | j                  |       | j                  j                   j#                  |       |gS )Nclasszadmonition-todor   r)   )textdocname)optionsgetsuperrun
isinstancer   insertr   titler   envcurrent_documentr-   add_nameset_source_infostatedocumentnote_explicit_target)selftodo	__class__s     r$   r1   zTodo.run5   s    ||(%6$7DLL!'+-$	*6MAu{{&	23((33;;YdT"

006vr#   returnz
list[Node])r   r    r!   __doc__r   
node_classr1   __classcell__)r>   s   @r$   r)   r)   0   s    OJ r#   r)   c                  N    e Zd ZdZdZedd       ZddZd	dZ	 	 	 	 	 	 	 	 d
dZ	y)
TodoDomainr=   c                :    | j                   j                  di       S Ntodos)data
setdefaultr<   s    r$   rH   zTodoDomain.todosI   s    yy##GR00r#   c                <    | j                   j                  |d        y N)rH   pop)r<   r-   s     r$   	clear_doczTodoDomain.clear_docM   s    

w%r#   c                <    |D ]  }|d   |   | j                   |<    y rG   )rH   )r<   docnames	otherdatar-   s       r$   merge_domaindatazTodoDomain.merge_domaindataP   s)     	>G"+G"4W"=DJJw	>r#   c                \   | j                   j                  |g       }|j                  t              D ]x  }|j                  j                  d|       |j                  |       |j                  j                  sGt        j                  t        d      |d   j                         |       z y )Ntodo-definedzTODO entry found: %s   )location)rH   rJ   findallr   eventsemitappendconfigtodo_emit_warningsloggerwarningr   astext)r<   r5   r-   r:   rH   r=   s         r$   process_doczTodoDomain.process_docT   s     

%%gr2$$Y/ 	DJJOOND1LLzz,,-.Q0@4  	r#   N)r@   zdict[str, list[todo_node]])r-   strr@   None)rQ   zSet[str]rR   zdict[str, Any]r@   rc   )r5   r   r-   rb   r:   nodes.documentr@   rc   )
r   r    r!   namelabelpropertyrH   rO   rS   ra   r"   r#   r$   rE   rE   E   sM    DE1 1&>#.1=K	r#   rE   c                  8    e Zd ZU dZdZdZdZdZi Zde	d<   ddZ
y)	TodoListzA list of all todo entries.Fr   zClassVar[OptionSpec]option_specc                    t        d      gS )N )r'   rK   s    r$   r1   zTodoList.runk   s     ~r#   Nr?   )r   r    r!   rA   has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacerj   __annotations__r1   r"   r#   r$   ri   ri   b   s,    %K %(*K%*r#   ri   c                  ,    e Zd ZddZddZddZd	dZy)
TodoListProcessorc                    |j                   | _         |j                  | _        |j                  | _        |j                  j                  d   | _        t        d      | _        | j                  ||       y )Nr=   rl   )builderr\   r5   domainsdomainr   r:   process)r<   appdoctreer-   s       r$   __init__zTodoListProcessor.__init__r   sQ    {{jj77ggoof-$R(Wg&r#   c                   t        j                  t        j                  | j                  j
                  j                         g       }t        |j                  t                    D ]  }| j                  j                  s|j                  j                  |       5|j                  d      rt        j                          g}ng }|D ]k  }|j#                         }|d   j%                          | j'                  ||       |j)                  |       | j+                  ||      }|j)                  |       m |j-                  |        y )Nids)	functoolsreduceoperatoriaddrw   rH   valueslistrX   r'   r\   todo_include_todosparentremover/   r   targetdeepcopyclearresolve_referencer[   create_todo_referencereplace_self)	r<   rz   r-   rH   nodecontentr=   new_todotodo_refs	            r$   rx   zTodoListProcessor.process{   s   !*!1!1MM4;;,,335r"
 23 	'D;;11""4(xx*/,,.)9 	)==?%%'&&x9x(55dGDx(	) g&+	'r#   c                   | j                   j                  rt        d      }n$t        d      |j                  |j                  fz  }|d |j                  d       }||j                  d      dz   d  }t        j                  dg      }|t        j                  |      z  }t        j                  t        d      t        d            }t        j                  d	d	|d
      }	 | j                  j                  ||d         |d<   |dxx   d|d   d   z   z  cc<   ||z  }|t        j                  |      z  }|S # t        $ r Y *w xY w)Nz<<original entry>>z3(The <<original entry>> is located in %s, line %d.)z<<z>>   ztodo-source)classeszoriginal entryrl   T)internalr-   refuri#r}   r   )r\   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   sH   ;;%%01KQR		V K
 5{//56[--d3a79:7

6"" >>!$4"5q9I7JKOOBHtD		"&,,"?"?i#Ih h3eQ#77
 		

6""  		s   #8D: :	EEc                "   |j                  t        j                        D ]  }d|v s||d<    | xj                  |z  c_        | j                  j                  | j                  || j                         | j                  j                  |       y)z'Resolve references in the todo content.refdocN)rX   r   pending_xrefr:   r5   resolve_referencesru   r   )r<   r=   r-   r   s       r$   r   z#TodoListProcessor.resolve_reference   sq    LL!6!67 	)D4!(X	)
 	##DMM7DLLIT"r#   N)ry   r   rz   rd   r-   rb   r@   rc   )rz   rd   r-   rb   r@   rc   )r=   r   r-   rb   r@   znodes.paragraph)r=   r   r-   rb   r@   rc   )r   r    r!   r{   rx   r   r   r"   r#   r$   rs   rs   q   s    ''6@	#r#   rs   c                r    | j                   j                  r| j                  |       y t        j                  rM   )r\   r   visit_admonitionr   SkipNoder<   r   s     r$   visit_todo_noder      s'    {{%%d#nnr#   c                &    | j                  |       y rM   )depart_admonitionr   s     r$   depart_todo_noder      s    4 r#   c                *   | j                   j                  r| j                  j                  d       | j                  j                  | j	                  |             t        d|d         }t        j                  |j                         | j                   j                        }| j                  j                  d|z         | xj                  dz  c_
        | j                  rd| j                  _        |j                  d       y t        j                  )Nz
\begin{sphinxtodo}{znodes.titler   z%s:}rV   T)r\   r   bodyr[   hypertarget_tor   r   escaper`   latex_engineno_latex_floatstablehas_problematicrN   r   r   )r<   r   
title_noder4   s       r$   latex_visit_todo_noder      s    {{%%		12		,,T23-a1
  !2!2!4dkk6N6NO		%(!::)-DJJ&nnr#   c                d    | j                   j                  d       | xj                  dz  c_        y )Nz\end{sphinxtodo}
rV   )r   r[   r   r   s     r$   latex_depart_todo_noder      s&    II*+Ar#   c           	        | j                  d       | j                  dddt        t        h             | j                  dddt        t        h             | j                  dddt        t        h             | j	                  t
               | j	                  t        t        t        ft        t        ft        t        ft        t        ft        t        f       | j                  d	t               | j                  d
t               | j                  t               | j!                  dt"               t$        j&                  dddS )NrU   r   Fhtml)typesr   r]   )r   latexr,   mantexinfor=   r'   zdoctree-resolvedr   T)versionenv_versionparallel_read_safe)	add_eventadd_config_value	frozensetbooladd_noder'   r   r   r   r   r   add_directiver)   ri   
add_domainrE   connectrs   sphinx__display_version__)ry   s    r$   setupr      s   MM.!-ufItfDUV)5&	4&@QR-ufItfDUVLLLL/0$&<=/0./ "23   fd#j(+NN:KK"$56--" r#   )r<   r   r   r   r@   rc   )r<   r   r   r   r@   rc   )ry   r   r@   r   )=rA   
__future__r   r~   r   typingr   r   docutilsr   r   r   sphinx.directives.admonitionsr   sphinx.domainsr	   sphinx.errorsr
   sphinx.localer   r   sphinx.utilr   r   sphinx.util.docutilsr   r   collections.abcr   r   r   docutils.nodesr   r   sphinx.applicationr   sphinx.environmentr   sphinx.util.typingr   r   sphinx.writers.html5r   sphinx.writers.latexr   	getLoggerr   r^   
Admonitionr   Generalr'   r)   rE   ri   rs   r   r   r   r   r   r"   r#   r$   <module>r      s    #   &    : !   * >#$,)3@44			8	$	  %-- 		u}}emm 	 * : N# N#b! 
r#   