U
    \a                     @   s4   d Z ddlZddlZdZdd Zdd Zdd	 ZdS )
z
from: https://gist.github.com/mgedmin/6052926
Sphinx extension to add ReadTheDocs-style "Edit on GitHub" links to the
sidebar.
Loosely based on https://github.com/astropy/astropy/pull/347
    NzBSD (3 clause)c                 C   s   dj | jj|| jj|dS )Nz=https://github.com/{project}/{view}/{branch}/docs/reST/{path})projectviewbranchpath)formatconfigedit_on_github_projectedit_on_github_branch)appr   r    r   ?/home/runner/work/pygame/pygame/docs/reST/ext/edit_on_github.pyget_github_url   s    r   c                 C   sf   |dkrd S | j js"td d S tj|d| jj	}t
| d|}t
| d|}||d< ||d< d S )Nz	page.htmlz$edit_on_github_project not specifiedsourceZblobeditZshow_on_github_urlZedit_on_github_url)r   r   warningswarnosr   relpathgetbuildersrcdirr   )r
   pagenametemplatenamecontextdoctreer   Zshow_urlZedit_urlr   r   r   html_page_context   s    
r   c                 C   s,   |  ddd |  ddd | dt d S )Nr    Tr	   mainzhtml-page-context)add_config_valueconnectr   )r
   r   r   r   setup(   s    r    )__doc__r   r   __license__r   r   r    r   r   r   r   <module>   s   	