
    Ki                        d Z ddlmZ dZddlZddlZddlmZmZm	Z	 ddl
mZ dZer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  G d de	      Z G d de      ZddZy)z0
This package contains Docutils Reader modules.
    )annotationsreStructuredTextN)utilsparsers	Component)	universalF)Final)nodes)Input)Parser)	Transformc                  x     e Zd ZU dZdZded<   dZded<   d fdZ	 	 d	 	 	 	 	 ddZdd	Z	d
 Z
ddZddZ xZS )Readera9  
    Abstract base class for docutils Readers.

    Each reader module or package must export a subclass also called 'Reader'.

    The two steps of a Reader's responsibility are to read data from the
    source Input object and parse the data with the Parser object.
    Call `read()` to process a document.
    readerr	   component_typereadersconfig_sectionc                    t         |          t        j                  t        j                  t        j
                  gz   S N)superget_transformsr   DecorationsExposeInternalsStripComments)self	__class__s    e/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/docutils/readers/__init__.pyr   zReader.get_transforms,   s:    w%'9+@+@+4+D+D+4+B+B+D D 	D    c                    || _         	 t        |t              r| j                  |       |9t	        j
                  dt        d       | j                   | j                  |       d| _        	 d| _        y)a2  
        Initialize the Reader instance.

        :parser: A parser instance or name (an instance will be created).
        :parser_name: deprecated, use "parser".

        Several instance attributes are defined with dummy initial values.
        Subclasses may use these attributes as they wish.
        NzgArgument "parser_name" will be removed in Docutils 2.0.
  Specify parser name in the "parser" argument.   )
stacklevel)	parser
isinstancestr
set_parserwarningswarnPendingDeprecationWarningsourceinput)r   r"   parser_names      r   __init__zReader.__init__1   sw     &,	E fc"OOF#"MM L 4C {{",$(<!%
	$r   c                F    t        j                  |      } |       | _        y)zSet `self.parser` by name.N)r   get_parser_classr"   )r   r+   parser_classs      r   r%   zReader.set_parserT   s    //<"nr   c                    || _         | j                  s|| _        || _        | j                   j                         | _        | j                          | j                  S r   )r)   r"   settingsreadr*   parsedocument)r   r)   r"   r1   s       r   r2   zReader.readY   sE    {{ DK [[%%'


}}r   c                    | j                         }| j                  j                  | j                  |       dx|_        |_        || _        y)z(Parse `self.input` into a document tree.N)new_documentr"   r3   r*   current_sourcecurrent_liner4   )r   r4   s     r   r3   zReader.parseb   s?    $$&$**h/:>>("7(0r   c                j    t        j                  | j                  j                  | j                        S )z8Create and return a new empty document tree (root node).)r   r6   r)   source_pathr1   r   s    r   r6   zReader.new_documenti   s#    !!$++"9"94==IIr   returnzlist[type[Transform]])NN)r"   zParser | str | Noner+   z
str | Noner=   None)r+   r$   r=   r>   )r=   r>   )r=   znodes.document)__name__
__module____qualname____doc__r   __annotations__r   r   r,   r%   r2   r3   r6   __classcell__)r   s   @r   r   r      sa     %NE$%NE%D 04+/!$,!$(!$ !$F%
1Jr   r   c                      e Zd ZdZddZy)ReReaderz
    A reader which rereads an existing document tree (e.g. a
    deserializer).

    Often used in conjunction with `writers.UnfilteredWriter`.
    c                ,    t        j                  |       S r   )r   r   r;   s    r   r   zReReader.get_transformsw   s     ''--r   Nr<   )r?   r@   rA   rB   r    r   r   rF   rF   n   s    .r   rF   c                   | j                         }	 t        j                  d|z         }|j                  S # t        $ rF 	 t        j                  |      }n!# t        $ r}t        d|  d      |d}~ww xY wY |j                  S w xY w)z6Return the Reader class from the `reader_name` module.zdocutils.readers.zReader "z" not found.N)lower	importlibimport_moduleImportErrorr   )reader_namenamemoduleerrs       r   get_reader_classrR   }   s    DM(()<T)AB ==  M	M,,T2F 	M\BCL	M  ==Ms3   6 	B AB	A4A//A44BB)rN   r$   r=   ztype[Reader])rB   
__future__r   __docformat__rK   r&   docutilsr   r   r   docutils.transformsr   TYPE_CHECKINGtypingr	   r
   docutils.ior   docutils.parsersr   r   r   rF   rR   rH   r   r   <module>r[      s\   
 #"   . . )!'-NJY NJb.v .
r   