U
    [ShQ                     @   s   d Z dZddlm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dddddddddddddddddddZdd ZdS )z0
This package contains Docutils Writer modules.
reStructuredText    )import_moduleN)	languages	Component)	universalc                       sX   e Zd ZdZdZdZ fddZdZdZdZ	dZ
dd Zd	d
 Zdd Zdd Z  ZS )Writera  
    Abstract base class for docutils Writers.

    Each writer module or package must export a subclass also called 'Writer'.
    Each writer must support all standard node types listed in
    `docutils.nodes.node_class_names`.

    The `write()` method is the main entry point.
    writerZwritersc                    s   t   tjtjtjg S N)superget_transformsr   ZMessagesZFilterMessagesZStripClassesAndElementsself	__class__ L/root/rtd-docs/venv/lib/python3.8/site-packages/docutils/writers/__init__.pyr   !   s    zWriter.get_transformsNc                 C   s
   i | _ d S r	   )partsr   r   r   r   __init__8   s    zWriter.__init__c                 C   s6   || _ t|jj|j| _|| _|   | j	| j
S )a/  
        Process a document into its final form.

        Translate `document` (a Docutils document tree) into the Writer's
        native format, and write it out to its `destination` (a
        `docutils.io.Output` subclass object).

        Normally not overridden or extended in subclasses.
        )documentr   Zget_languagesettingsZlanguage_codereporterlanguagedestination	translatewriteoutput)r   r   r   r   r   r   r   A   s    
zWriter.writec                 C   s   t ddS )a  
        Do final translation of `self.document` into `self.output`.  Called
        from `write`.  Override in subclasses.

        Usually done with a `docutils.nodes.NodeVisitor` subclass, in
        combination with a call to `docutils.nodes.Node.walk()` or
        `docutils.nodes.Node.walkabout()`.  The ``NodeVisitor`` subclass must
        support all standard elements (listed in
        `docutils.nodes.node_class_names`) and possibly non-standard elements
        used by the current Reader as well.
        z"subclass must override this methodN)NotImplementedErrorr   r   r   r   r   S   s    zWriter.translatec                 C   s<   | j | jd< | jjj| jd< | jjj| jd< tj| jd< dS )zAssemble the `self.parts` dictionary.  Extend in subclasses.

        See <https://docutils.sourceforge.io/docs/api/publisher.html>.
        ZwholeencodingerrorsversionN)r   r   r   r   Zoutput_encodingZoutput_encoding_error_handlerdocutils__version__r   r   r   r   assemble_partsa   s
    zWriter.assemble_parts)__name__
__module____qualname____doc__Zcomponent_typeZconfig_sectionr   r   r   r   r   r   r   r   r"   __classcell__r   r   r   r   r      s   
	r   c                   @   s   e Zd ZdZdd ZdS )UnfilteredWriterz
    A writer that passes the document tree on unchanged (e.g. a
    serializer.)

    Documents written by UnfilteredWriters are typically reused at a
    later date using a subclass of `readers.ReReader`.
    c                 C   s
   t | S r	   )r   r   r   r   r   r   r   w   s    zUnfilteredWriter.get_transformsN)r#   r$   r%   r&   r   r   r   r   r   r(   m   s   r(   Z	html4css1Zhtml5_polyglotZs5_htmlZlatex2eZxetexZodf_odtZ	pseudoxmlZrlpdfZdocutils_xml)htmlZhtml4Zxhtml10html5ZxhtmlZs5latexZxelatexZluatexZlualatexZodfZodtZoofficeZ
openofficeZlibreofficepprintpformatZpdfxmlc                 C   s   |   }t||}ztd| }W nX tk
r|   zt|}W n6 tk
rv } ztd|  d| W 5 d}~X Y nX Y nX |jS )z6Return the Writer class from the `writer_name` module.zdocutils.writers.zWriter "z" not found. N)lower_writer_aliasesgetr   ImportErrorr   )Zwriter_namenamemoduleerrr   r   r   get_writer_class   s    ,r6   )r&   __docformat__	importlibr   r    r   r   Zdocutils.transformsr   r   r(   r0   r6   r   r   r   r   <module>   s8   [