
    Fe                    x    d Z ddlmZ ddlZddlZddlZddlmZm	Z	 ddl
Z
erddlmZ ddlmZ d
dZddZdd	Zy)z<To publish HTML docs at GitHub Pages, create .nojekyll file.    )annotationsN)TYPE_CHECKINGAny)Sphinx)BuildEnvironmentc                d    | xr) t         j                  j                  |       j                  xs dS )zGet the domain from a URL. )urllibparseurlparsehostname)urls    8/usr/lib/python3/dist-packages/sphinx/ext/githubpages.py_get_domain_from_urlr      s'    66<<((-66<"<    c                Z   | j                   j                  dk7  ry| j                   j                  j                  d      j	                          t
        j                  j                  | j                   j                  d      }t        | j                  j                        }|r:|j                  d      s)t        |dd      5 }|j                  |       ddd       yt        j                  t               5  t        j"                  |       ddd       y# 1 sw Y   yxY w# 1 sw Y   yxY w)	aK  Manage the ``.nojekyll`` and ``CNAME`` files for GitHub Pages.

    For HTML-format builders (e.g. 'html', 'dirhtml') we unconditionally create
    the ``.nojekyll`` file to signal that GitHub Pages should not run Jekyll
    processing.

    If the :confval:`html_baseurl` option is set, we also create a CNAME file
    with the domain from ``html_baseurl``, so long as it is not a ``github.io``
    domain.

    If this extension is loaded and the domain in ``html_baseurl`` no longer
    requires a CNAME file, we remove any existing ``CNAME`` files from the
    output directory.
    htmlNz	.nojekyllCNAMEz
.github.iowzutf-8)encoding)builderformatoutdirjoinpathtouchospathjoinr   confightml_baseurlendswithopenwrite
contextlibsuppressFileNotFoundErrorunlink)appenv
cname_pathdomainfs        r   create_nojekyll_and_cnamer-      s     {{V#KK,224ckk00':J!#**"9"9:Ffool3*cG4 	 GGFO	 	
   !23 	"IIj!	" 	"	 	
	" 	"s   D6D!D!D*c                T    | j                  dt               t        j                  ddS )Nzenv-updatedT)versionparallel_read_safe)connectr-   sphinx__display_version__)r(   s    r   setupr4   7   s"    KK8911NNr   )r   strreturnr5   )r(   r   r)   r   r6   None)r(   r   r6   zdict[str, Any])__doc__
__future__r   r$   r   urllib.parser
   typingr   r   r2   sphinx.applicationr   sphinx.environmentr   r   r-   r4    r   r   <module>r?      s4    B "  	  % )3=
"BOr   