U
    \ae                     @   s8   d dl mZmZ d dlmZ d dlZdd Zdd ZdS )    )get_sectionname	isections)tour_descinfoNc                 C   sR   |  d | ddd | ddd | ddd | d	d
d | dt d S )Nzext.indexerheaders_dest.htmlheaders_mkdirsF headers_filename_sfxheaders_templatezheader.hzhtml-page-context)setup_extensionadd_config_valueconnectwriter)app r   8/home/runner/work/pygame/pygame/docs/reST/ext/headers.pysetup   s    
r   c                 C   s   |d krd S | j j}tj| jd }| jd rFtj|sFt| | jd }g }t|D ]}	t	|j
|	| q\|sxd S | j j}
dtj||f }tj||}| jd }t|ddd}||d	< z||
|| W 5 |  |d	= X d S )
Nr   r   r
   z%s%s.hr   wzutf-8)encodingZ	hdr_items)builderenvospathabspathconfiglexistsmakedirsr   r   append	templatesbasenamejoinopenclosewriterender)r   pagenametemplatenamecontextdoctreer   dirpathfilename_suffixitemssectionr   filenamefilepathtemplateheaderr   r   r   r      s,    


r   )Z	ext.utilsr   r   Zext.indexerr   r   r   r   r   r   r   r   <module>   s   