o
    Ni                     @  s   d Z ddlmZ ddlZddlZddlZddlmZ ddl	Z	er2ddl
mZ ddlmZ ddlmZ dddZdddZdddZdS )z<To publish HTML docs at GitHub Pages, create .nojekyll file.    )annotationsN)TYPE_CHECKING)Sphinx)BuildEnvironment)ExtensionMetadataurlstrreturnc                 C  s   | r	t j| jp
dS )zGet the domain from a URL. )urllibparseurlparsehostname)r    r   J/home/ubuntu/.local/lib/python3.10/site-packages/sphinx/ext/githubpages.py_get_domain_from_url   s   r   appr   envr   Nonec                 C  s   | j jdkrdS | j jd  tj| j jd}t| j	j
}|rF|dsFt|ddd}|| W d   dS 1 s?w   Y  dS tt t| W d   dS 1 s\w   Y  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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)r   r   
cname_pathdomainfr   r   r   create_nojekyll_and_cname   s   ""r-   r   c                 C  s   |  dt tjddS )Nzenv-updatedT)versionparallel_read_safe)connectr-   sphinx__display_version__)r   r   r   r   setup8   s   r3   )r   r   r	   r   )r   r   r   r   r	   r   )r   r   r	   r   )__doc__
__future__r   r&   r   urllib.parser   typingr   r1   sphinx.applicationr   sphinx.environmentr   sphinx.util.typingr   r   r-   r3   r   r   r   r   <module>   s    

!