o $a @sdZddlZddlmZddlmZmZmZmZddlm Z ddl m Z m Z m Z ddlmZddlmZmZe eZgd ZGd d d ZdS) z sphinx.project ~~~~~~~~~~~~~~ Utility function and classes for Sphinx projects. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N)glob)DictListOptionalSet)__)get_matching_filesloggingpath_stabilize)compile_matchers)SEPrelpath)z **/_sourcesz.#*z**/.#*z *.lproj/**c@seZdZdZdedeeefddfddZdd d Zgfd eede efd d Z dede efddZ ddede defddZdS)Projectz;A project is the source code set of the Sphinx document(s).srcdir source_suffixreturnNcCs||_||_t|_dS)N)rrsetdocnames)selfrrr0/usr/lib/python3/dist-packages/sphinx/project.py__init__s zProject.__init__othercCs |j|_dS)z!Take over a result of last build.N)r)rrrrrrestore%s zProject.restore exclude_pathscst_t|t}tj|D]P}|}|r`|jvrCtj j|d}fddt |D}t j t d|||ddqttj j|tjrWj|qt j t d|dqjS) zbFind all document files in the source directory and put them in :attr:`docnames`. z.*csg|]}t|jqSr)r r).0frrr 4sz$Project.discover..zDmultiple files found for the document "%s": %r Use %r for the build.T)oncezdocument not readable. Ignored.)location)rrr EXCLUDE_PATHSrrpath2docospathjoinrloggerwarningrdoc2pathaccessR_OKadd)rrexcludesfilenamedocnamepatternfilesrrrdiscover)s     zProject.discoverr-cCsP||jr t||j}|jD]}||r%t|}|dt| SqdS)zReturn the docname for the filename if the file is a document. *filename* should be absolute or relative to the source directory. N) startswithrr rendswithr len)rr-suffixrrrr"?s    zProject.path2docTr.basedircCsb|ttjj}tj|j|}|jD] }tj||rnqt |jd}|r-||S||S)zReturn the filename for the document name. If *basedir* is True, return as an absolute path. Else, return as a relative path to the source directory. r) replacer r#r$sepr%rrisfilelist)rr.r6basenamer5rrrr(Ns zProject.doc2path)rrrN)T)__name__ __module__ __qualname____doc__strrrrrrr1rr"boolr(rrrrrs r)r?r#rtypingrrrr sphinx.localer sphinx.utilrr r sphinx.util.matchingr sphinx.util.osutilr r getLoggerr<r&r!rrrrrs