U
    \Sh                     @  s   d Z ddlmZ ddlZddlZddlmZ ddlZddl	m
Z
 ddlmZ dddd	d
ZddddddZdddddZdS )z<To publish HTML docs at GitHub Pages, create .nojekyll file.    )annotationsN)Any)Sphinx)BuildEnvironmentstr)urlreturnc                 C  s   | rt j| jpdS )zGet the domain from a URL. )urllibparseurlparsehostname)r    r   I/root/rtd-docs/venv/lib/python3.8/site-packages/sphinx/ext/githubpages.py_get_domain_from_url   s    r   r   r   None)appenvr   c              	   C  s   | j jdkrdS ttj| j jdd  tj| j jd}t| j	j
}|r~|ds~t|ddd	}|| W 5 Q R X n$zt| W n tk
r   Y nX dS )
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wbZCNAMEz
.github.iowzutf-8)encoding)ZbuilderformatopenospathjoinZoutdircloser   configZhtml_baseurlendswithwriteunlinkFileNotFoundError)r   r   Z
cname_pathdomainfr   r   r   create_nojekyll_and_cname   s    r%   zdict[str, Any])r   r   c                 C  s   |  dt tjddS )Nzenv-updatedT)versionZparallel_read_safe)connectr%   sphinxZ__display_version__)r   r   r   r   setup6   s    r)   )__doc__
__future__r   r   urllib.parser
   typingr   r(   Zsphinx.applicationr   Zsphinx.environmentr   r   r%   r)   r   r   r   r   <module>   s   #