U
    ®[Öe‹.  ã                
   @   s6  d dl mZ d dlZd dlZd dlZzd dlZW n ek
rL   d dlZY nX z^d dlZzd dl	m
Z
 dZW n$ ek
r   d dlm
Z
 dZY nX d dlmZ d dlmZ W n. ek
rÚ Z zeeeƒƒ‚W 5 dZ[X Y nX d dlmZ d d	lmZ d d
lmZ ddddgZddgZdZdd„ ZG dd„ dejƒZdS )é    )ÚlogN)ÚapidocFT)Úapplication)Úsetup_command)Úgit)Úoptions)ÚversionÚautodoc_tree_index_modulesÚautodoc_index_modulesÚautodoc_tree_excludesÚautodoc_exclude_modulesÚAUTODOC_TREE_INDEX_MODULESÚAUTODOC_INDEX_MODULESzi%(heading)s
%(underline)s

.. automodule:: %(module)s
  :members:
  :undoc-members:
  :show-inheritance:
c                 C   s@   |D ]6}|  d¡r|dkrd| d| dd¡|d d… f < qd S )Nz.pyz__init__.pyTz%s.%sú/Ú.éýÿÿÿ)ÚendswithÚreplace)ÚargÚdirnameÚfilesÚfilename© r   úN/var/www/html/services/stratfitenv/lib/python3.8/site-packages/pbr/builddoc.pyÚ_find_modulesI   s    ÿ
ÿr   c                   @   sT   e Zd ZdgZdZdZdd„ Zddd„Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )ÚLocalBuildDocÚhtmlÚbuild_sphinxFc                 C   sj   | j  d¡}| j  d¡}| dd¡\}}d|krHtj |d d |¡}nd| }tj |¡sft |¡ |S )Nr   ÚpbrÚapi_doc_dir)NÚapiÚ
source_diré   zdoc/source/)ÚdistributionÚget_option_dictÚgetÚosÚpathÚjoinÚexistsÚmakedirs)ÚselfÚoption_dictZpbr_option_dictÚ_r   r!   r   r   r   Ú_get_source_dirV   s    ÿ
zLocalBuildDoc._get_source_dirNc                    s2  t  dtj tj¡ ¡ i }|  ¡ }| jjD ].}d|kr,t 	|¡D ]\}}}t
|||ƒ qBq,‡ fdd„‰t‡fdd„| ¡ D ƒƒ}tj |d¡}	t|	dƒŽ}
|
 d	¡ |D ]x}tj |d
| ¡}d| }dt|ƒ }t|||d}t  d| ¡ t|dƒ}| t| ¡ W 5 Q R X |
 d| ¡ qªW 5 Q R X d S )Nz[pbr] Autodocumenting from %sr   c                    s   t ‡ fdd„ˆD ƒƒ S )Nc                 3   s   | ]}t   ˆ |¡V  qd S ©N)Úfnmatch)Ú.0Úpat©Úmoduler   r   Ú	<genexpr>n   s   ÿzDLocalBuildDoc.generate_autoindex.<locals>.include.<locals>.<genexpr>)Úanyr3   )Úexcluded_modulesr3   r   Úincludem   s    ÿz1LocalBuildDoc.generate_autoindex.<locals>.includec                 3   s   | ]}ˆ |ƒr|V  qd S r/   r   )r1   Úmod)r8   r   r   r5   q   s      z3LocalBuildDoc.generate_autoindex.<locals>.<genexpr>zautoindex.rstÚwz.. toctree::
   :maxdepth: 1

z%s.rstzThe :mod:`%s` Moduleú=)r4   ÚheadingÚ	underlinez[pbr] Generating %sz
   %s.rst
)r   Úinfor&   r'   ÚabspathÚcurdirr.   r#   ÚpackagesÚwalkr   ÚsortedÚkeysr(   ÚopenÚwriteÚlenÚdictÚ_rst_template)r+   r7   Úmodulesr!   ÚpkgÚdirpathÚdirnamesr   Zmodule_listZautoindex_filenameZ	autoindexr4   Zoutput_filenamer<   r=   ÚvaluesZoutput_filer   )r7   r8   r   Úgenerate_autoindexc   s:    ÿ
ÿÿÿz LocalBuildDoc.generate_autoindexc                 C   s:   |   ¡ }ddd|dg}tr&| dd¡ t || j ¡ d S )Nz-HÚModulesz-or   r   r   )r.   Úapidoc_use_paddingÚinsertr   Úmainr   )r+   r!   Úcmdr   r   r   Ú_sphinx_tree†   s
    zLocalBuildDoc._sphinx_treec                 C   s^  | j st ¡ }ntj}i }| jr*| j|d< | jr:| j|d< | jrJ| j|d< | jrZ| j|d< | j	rrddddd	g|d
< t
j| j| j| j| j| j||| j| jd	}d| _	z|j| jd W nt tk
r( } zTddlm} t||jƒrtj d¡ tj |jd  dd¡¡ tj d¡ n‚ W 5 d }~X Y nX | jrZ|j j!|jj" }|j #d¡}t$ %||¡ d S )NÚprojectr   ÚreleaseÚtodayzapp.add_directivezapp.add_rolezapp.add_generic_rolezapp.add_nodezimage.nonlocal_uriZsuppress_warnings)ZfreshenvZwarningiserrorT)Z	force_allr   )ÚutilszreST markup error:
ÚasciiÚbackslashreplaceÚ
Úindex)&ÚverboseÚ	cStringIOÚStringIOÚsysÚstdoutrV   r   rW   rX   Úsphinx_initializedr   ZSphinxr!   Z
config_dirZbuilder_target_dirZdoctree_dirÚbuilderZ	fresh_envÚwarning_is_errorÚbuildÚ	all_filesÚ	ExceptionZdocutilsrY   Ú
isinstanceZSystemMessageZstderrF   ÚstderrÚargsÚencodeZ
link_indexÚconfigZ
master_docZ
out_suffixZget_outfilenamer&   Úsymlink)r+   Zstatus_streamZconfoverridesZappÚerrrY   ÚsrcÚdstr   r   r   Ú_sphinx_run   s\    




  ý     üÿzLocalBuildDoc._sphinx_runc           	      C   st  | j  d¡}t| ¡ ƒ t¡}ttdd„ tƒƒ}|s8|rjd}|rP|dt|ƒ 7 }|r`|d| 7 }t	 
|¡ t ¡ rŠtj|d tj|d t |dd	¡}t |d
d¡}t d¡sâ|r¼|  ¡  |râ|  t| dd dg¡d  ¡ ƒ¡ |  ¡  tj tj¡t dd¡k}|st	 
d¡ | jdgkr:t	 
d¡ |r:| j| _|rLtj  !| ¡S | jD ]}|| _|  ¡  |  "¡  qRd S )Nr   c                 S   s
   t  | ¡S r/   )r&   Úgetenv)Úxr   r   r   Ú<lambda>¿   ó    z#LocalBuildDoc.run.<locals>.<lambda>zÛThe autodoc and autodoc_tree features are deprecated in 4.2 and will be removed in a future release. You should use the sphinxcontrib-apidoc Sphinx extension instead. Refer to the pbr documentation for more information.z Deprecated options: %sz% Deprecated environment variables: %s)r,   r	   r   r
   r   ZSPHINX_DEBUGr   Ú r"   é   zQ[pbr] Support for Sphinx < 1.6 will be dropped in pbr 4.0. Upgrade to Sphinx 1.6+r   a'  [pbr] Sphinx 1.6 added native support for specifying multiple builders in the '[sphinx_build] builder' configuration option, found in 'setup.cfg'. As a result, the '[sphinx_build] builders' option has been deprecated and will be removed in pbr 4.0. Migrate to the 'builder' configuration option.)#r#   r$   ÚsetrD   ÚintersectionÚ_deprecated_optionsÚlistÚfilterÚ_deprecated_envsr   Úwarnr   Z_git_is_installedZwrite_git_changelogZgenerate_authorsr   Zget_boolean_optionr&   rs   rU   rO   r%   ÚsplitÚfinalize_optionsr   ZSemanticVersionZfrom_pip_stringÚsphinxÚ__version__Úbuildersrd   r   ÚBuildDocÚrunrr   )	r+   r,   Z	warn_optsZwarn_envÚmsgZ
tree_indexZ
auto_indexZis_multibuilder_sphinxrd   r   r   r   r†   ¹   sf    
þþ
þþÿÿ
ÿ


zLocalBuildDoc.runc                 C   s   t j | ¡ dg| _d S )Nzsetup.py)r   r…   Úinitialize_optionsr   )r+   r   r   r   rˆ      s    z LocalBuildDoc.initialize_optionsc                 C   sÌ   ddl m} tj | ¡ | j d¡}d| dg g¡d krH|d d | _t	| jt
ƒsh| jrh| j d¡| _| j ¡ | _| j ¡ | _| j ¡ | _d}| j d	¡}||kr¸| || d ¡| _t| d
ƒsÈd| _d S )Nr   )Úutilr   zcommand linerd   r"   ú,r   r   re   F)r   r‰   r   r…   r   r#   r$   r%   r„   ri   r|   r€   Úget_namerV   Úget_versionr   rW   Zsplit_multiliner   Úhasattrre   )r+   r‰   r,   Úoptr   r   r   r     s$    
ÿ
zLocalBuildDoc.finalize_options)N)Ú__name__Ú
__module__Ú__qualname__r„   Úcommand_namerc   r.   rO   rU   rr   r†   rˆ   r   r   r   r   r   r   P   s   
#,Gr   )Ú	distutilsr   r0   r&   ra   r_   ÚImportErrorÚior‚   Z
sphinx.extr   rQ   r   r   rh   ÚeÚstrr   r   r   r   r{   r~   rI   r   r…   r   r   r   r   r   Ú<module>   s<   
 ÿ
