U
    [Sh                     @   sP   d Z dZddlZddlmZmZ ddlmZ G dd deZG dd	 d	eZ	dS )
z
Auxiliary transforms mainly to be used by Writer components.

This module is called "writer_aux" because otherwise there would be
conflicting imports like this one::

    from docutils import writers
    from docutils.transforms import writers
reStructuredText    N)nodes	languages)	Transformc                       s.   e Zd ZdZdZd fdd	Zdd Z  ZS )	Compounda  
    .. warning:: This transform is not used by Docutils since Dec 2010
                 and will be removed in Docutils 0.21 or later.

    Flatten all compound paragraphs.  For example, transform ::

        <compound>
            <paragraph>
            <literal_block>
            <paragraph>

    into ::

        <paragraph>
        <literal_block classes="continued">
        <paragraph classes="continued">
    i  Nc                    s"   t jdtdd t || d S )Nzddocutils.transforms.writer_aux.Compound is deprecated and will be removed in Docutils 0.21 or later.   )
stacklevel)warningswarnDeprecationWarningsuper__init__)selfdocumentZ	startnode	__class__ Q/root/rtd-docs/venv/lib/python3.8/site-packages/docutils/transforms/writer_aux.pyr   -   s
     zCompound.__init__c                 C   s\   | j tjD ]H}d}|D ](}|r4t|tjsBd}q|d d q||d d   qd S )NTFclasses	continued)r   findallr   compound
isinstanceZ	Invisibleappendreplace_self)r   r   Zfirst_childchildr   r   r   apply3   s    zCompound.apply)N)__name__
__module____qualname____doc__default_priorityr   r   __classcell__r   r   r   r   r      s   r   c                   @   s   e Zd ZdZdZdd ZdS )AdmonitionsaZ  
    Transform specific admonitions, like this:

        <note>
            <paragraph>
                 Note contents ...

    into generic admonitions, like this::

        <admonition classes="note">
            <title>
                Note
            <paragraph>
                Note contents ...

    The admonition title is localized.
    i  c                 C   s   t | jjj| jj}| jtjD ]f}|j	j
}|d | t|tjs$tj|jf|j|j}td|j| }|d| || q$d S )Nr    r   )r   Zget_languager   settingsZlanguage_codereporterr   r   Z
Admonitionr   r   r   r   
admonitionZ	rawsourcechildren
attributestitlelabelsinsertr   )r   languagenodeZ	node_namer'   r*   r   r   r   r   V   s    zAdmonitions.applyN)r   r   r   r    r!   r   r   r   r   r   r#   @   s   r#   )
r    __docformat__r	   Zdocutilsr   r   Zdocutils.transformsr   r   r#   r   r   r   r   <module>   s   
)