3

T'íc,
ã@s”dZddlZddlmZddlmZmZmZmZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZejeƒZd	d
ddgZGd
d„dƒZdS)z1Utility function and classes for Sphinx projects.éN)Úglob)ÚDictÚListÚOptionalÚSet)Ú__)Úget_matching_filesÚloggingÚpath_stabilize)Úcompile_matchers)ÚSEPÚrelpathz**/_sourcesz.#*z**/.#*z
*.lproj/**c@s~eZdZdZeeeefddœdd„Zdddœdd„Zgfeee	ed	œd
d„Z
eeedœd
d„Zdee
edœdd„ZdS)ÚProjectz;A project is the source code set of the Sphinx document(s).N)ÚsrcdirÚ
source_suffixÚreturncCs||_||_tƒ|_dS)N)rrÚsetÚdocnames)Úselfrr©rú0/tmp/pip-build-gk9425m9/sphinx/sphinx/project.pyÚ__init__szProject.__init__)ÚotherrcCs|j|_dS)z!Take over a result of last build.N)r)rrrrrÚrestoreszProject.restore)Ú
exclude_pathsrcsÌtƒˆ_t|tƒ}x°tˆj|ƒD] }ˆj|ƒ}|r"|ˆjkrˆtjj	ˆj|ƒd}‡fdd„t
|ƒDƒ}tjt
dƒ||ˆj|ƒddq"tjtjj	ˆj|ƒtjƒr°ˆjj|ƒq"tjt
dƒ|dq"WˆjS)	zbFind all document files in the source directory and put them in
        :attr:`docnames`.
        z.*csg|]}t|ˆjƒ‘qSr)r
r)Ú.0Úf)rrrú
<listcomp>,sz$Project.discover.<locals>.<listcomp>zDmultiple files found for the document "%s": %r
Use %r for the build.T)Úoncezdocument not readable. Ignored.)Úlocation)rrrÚ
EXCLUDE_PATHSrrÚpath2docÚosÚpathÚjoinrÚloggerÚwarningrÚdoc2pathÚaccessÚR_OKÚadd)rrZexcludesÚfilenameÚdocnameÚpatternÚfilesr)rrÚdiscover!s


zProject.discover)r+rcCsP|j|jƒrt||jƒ}x2|jD](}|j|ƒr t|ƒ}|dt|ƒ…Sq WdS)z“Return the docname for the filename if the file is a document.

        *filename* should be absolute or relative to the source directory.
        N)Ú
startswithrr
rÚendswithr
Úlen)rr+Úsuffixrrrr!7s
zProject.path2docT)r,ÚbasedirrcCsh|jttjjƒ}tjj|j|ƒ}x.|jD]}tjj||ƒr(Pq(Wt	|jƒd}|r\||S||SdS)z¯Return 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.
        rN)
Úreplacerr"r#Úsepr$rrÚisfileÚlist)rr,r4Úbasenamer3rrrr'FszProject.doc2path)T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrrrrrrr/rr!Úboolr'rrrrrs
r)r=r"rÚtypingrrrrZ
sphinx.localerZsphinx.utilrr	r
Zsphinx.util.matchingrZsphinx.util.osutilrr
Ú	getLoggerr:r%r rrrrrÚ<module>s