o
    N i¯  ã                   @   s`   d 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	 G dd„ de	j
ƒZ
G dd	„ d	e	jƒZdS )
z
PEP HTML Writer.
ÚreStructuredTexté    N)ÚfrontendÚnodesÚutils)Ú	html4css1c                
   @   sè   e Zd ZdZe ej e 	¡ d¡ej ej 
e¡e¡¡ZdZe ej e 	¡ d¡ej ej 
e¡e¡¡Zejjddeef ddgdd	d
œfddgdd	d
œfejdgdejdœfff ZeedœZdZdZdZdd„ Zdd„ Zdd„ ZdS )ÚWriterzpep.cssÚdummyztemplate.txtzPEP/HTML Writer Optionsz¡For the PEP/HTML writer, the default value for the --stylesheet-path option is "%s", and the default value for --template is "%s". See HTML Writer Options above.z8Python's home URL.  Default is "https://www.python.org".z--python-homezhttps://www.python.orgz<URL>)ÚdefaultÚmetavarz>Home URL prefix for PEPs.  Default is "." (current directory).z
--pep-homeÚ.z--no-randomÚ
store_true)ÚactionÚ	validator)Ústylesheet_pathÚtemplate)r   zpep_html writer)Úwriterszhtml writerszhtml4css1 writerc                 C   s   t j | ¡ t| _d S )N)r   r   Ú__init__ÚHTMLTranslatorÚtranslator_class©Úself© r   úV/home/ubuntu/.local/lib/python3.10/site-packages/docutils/writers/pep_html/__init__.pyr   9   s   
zWriter.__init__c                 C   s  t j | ¡}| jj}|j}||d< |j|d< |dkrd|d< n|d |d< | j tj	¡}| j| }|d d  
¡ | _| j|d	< |jrGd|d
< ndd l}| d¡|d
< zdt| jƒ |d< W n tyk   | j|d< Y nw |d d  
¡ | _| j|d< d | j| j | j ¡|d< |S )NÚpyhomeÚpephomez..r   Úpepindexz	/dev/pepsr   é   ÚpepÚbanneré@   z%04iÚpepnumÚtitleÚ Úbody)r   r   Úinterpolation_dictÚdocumentÚsettingsÚpython_homeÚpep_homeÚfirst_child_matching_classr   Ú
field_listÚastextr    Ú	no_randomÚrandomÚ	randrangeÚintÚ
ValueErrorr!   ÚjoinÚbody_pre_docinfoÚdocinfor#   )r   Úsubsr&   r   ÚindexÚheaderr-   r   r   r   r$   =   s6   




ÿ
ÿzWriter.interpolation_dictc                 C   s*   t j | ¡ | jg| jd< | j| jd< d S )Nr!   r    )r   r   Úassemble_partsr!   Úpartsr    r   r   r   r   r7   Z   s   zWriter.assemble_partsN)Ú__name__Ú
__module__Ú__qualname__Údefault_stylesheetr   Úrelative_pathÚosÚpathr1   ÚgetcwdÚdirnameÚ__file__Údefault_stylesheet_pathÚdefault_templateÚdefault_template_pathr   r   Úsettings_specr   ÚSUPPRESS_HELPÚvalidate_booleanÚsettings_default_overridesÚrelative_path_settingsÚconfig_sectionÚconfig_section_dependenciesr   r$   r7   r   r   r   r   r      sN    þþýþþ
þùúÿr   c                   @   s   e Zd Zdd„ ZdS )r   c                 C   s.   t j | |¡ d|d v r| j d¡ d S d S )NÚrfc2822Úclassesz<hr />
)r   r   Údepart_field_listr#   Úappend)r   Únoder   r   r   rO   b   s   ÿz HTMLTranslator.depart_field_listN)r9   r:   r;   rO   r   r   r   r   r   `   s    r   )Ú__doc__Ú__docformat__r>   Úos.pathÚdocutilsr   r   r   Údocutils.writersr   r   r   r   r   r   r   Ú<module>   s   M