
    -Ph&                     B    d Z ddlZddlmZ ddlmZ dedededdfd	ZdS )
zLCreate an "edit this page" url compatible with bitbucket, gitlab and github.    N)Sphinx)ExtensionErrorapppagenametemplatenamereturnc                 n    dfd}|d<   t                              dd                    d<   dS )zJAdd a function that jinja can access for returning the edit URL of a page.r   Nc                     
 	d          } 	                     dd          }|r|                    d          s| d}dddd}i }	                     d	          }|2d|vrt          d|           	                     d          }||f|d<   |                    dddd           t	          |                              	                               ||            |                                D ]F\  }\  }}t          fd|D                       r#| t          j        |          j	        di fc S Gt          dt          |                                                     )z>Return a provider name and a URL for an "edit this page" link.page_source_suffixdoc_path /zhttps://bitbucket.orgzhttps://github.comzhttps://gitlab.com)bitbucket_url
github_url
gitlab_urledit_page_url_templateN	file_namezkMissing required value for `use_edit_page_button`. Ensure `file_name` appears in `edit_page_url_template`: edit_page_provider_name)r   )	Bitbucketz{{ bitbucket_url }}/{{ bitbucket_user }}/{{ bitbucket_repo }}/src/{{ bitbucket_version }}/{{ doc_path }}{{ file_name }}?mode=edit)GitHubzl{{ github_url }}/{{ github_user }}/{{ github_repo }}/edit/{{ github_version }}/{{ doc_path }}{{ file_name }})GitLabzn{{ gitlab_url }}/{{ gitlab_user }}/{{ gitlab_repo }}/-/edit/{{ gitlab_version }}/{{ doc_path }}{{ file_name }}))bitbucket_userbitbucket_repobitbucket_version)github_usergithub_repogithub_version)gitlab_usergitlab_repogitlab_version)r   r   c              3   F   K   | ]}                     |          d vV  dS ))NNoneN)get).0attrdoc_contexts     b/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pydata_sphinx_theme/edit_this_page.py	<genexpr>zDsetup_edit_url.<locals>.get_edit_provider_and_url.<locals>.<genexpr>F   s4      QQ4;??4((>QQQQQQ    zyMissing required value for `use_edit_page_button`. Ensure one set of the following in your `html_context` configuration:  )r#   endswithr   updatedictitemsalljinja2Templaterendersortedkeys)r   r   default_provider_urls
edit_attrsurl_templateprovider_nameattrsproviderr&   contextr   s           @r'   get_edit_provider_and_urlz1setup_edit_url.<locals>.get_edit_provider_and_url   s   @)=!>@@	 ;;z2.. 	&H--c22 	&"~~~H 5..!
 !
 
 {{#;<<#,..$&#& &  
 $KK(ABBM7Dl6SJ23LC
C 	
 	
 	
* 0117###H	BBB/9/?/?/A/A 	U 	U+E+HlQQQQ5QQQQQ U!E!>!>!E!T!T!T!TTTTTU :$Z__%6%677: :
 
 	
r)   r<   theme_show_toc_level   )r   N)intr#   )r   r   r   r;   doctreer<   s    ` `  r'   setup_edit_urlrA   	   s`    
?
 ?
 ?
 ?
 ?
 ?
 ?
B ,EG'( '*'++6La*P*P&Q&QG"###r)   )__doc__r0   sphinx.applicationr   sphinx.errorsr   strrA   r*   r)   r'   <module>rF      s    R R  % % % % % % ( ( ( ( ( (IR	IRIR.1IR	IR IR IR IR IR IRr)   