3 F\.@s6ddlmZddlZddlZddlZy ddlZWnek rLddlZYnXy^ddlZyddl m Z dZ Wn$ek rddlm Z dZ YnXddlm Z ddlm Z Wn.ek rZzeeeWYddZ[XnXddlmZdd lmZdd lmZd d d dgZddgZdZddZGddde jZdS))logN)apidocFT) application) setup_command)git)options)versionautodoc_tree_index_modulesautodoc_index_modulesautodoc_tree_excludesautodoc_exclude_modulesAUTODOC_TREE_INDEX_MODULESAUTODOC_INDEX_MODULESzi%(heading)s %(underline)s .. automodule:: %(module)s :members: :undoc-members: :show-inheritance: cCsDx>|D]6}|jdr|dkrd|d|jdd|ddf<qWdS) Nz.pyz __init__.pyTz%s.%s/.)endswithreplace)argdirnamefilesfilenamera/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/pbr/pbr/builddoc.py _find_modulesIs rc@sTeZdZdgZdZdZddZdddZd d Zd d Z d dZ ddZ ddZ dS) LocalBuildDochtml build_sphinxFcCsj|jjd}|jjd}|jdd\}}d|krHtjj|dd|}nd|}tjj|sftj||S) Nrpbr api_doc_dirapi source_dirz doc/source/)Nr!) distributionget_option_dictgetospathjoinexistsmakedirs)self option_dictZpbr_option_dict_r r"rrr_get_source_dirVs    zLocalBuildDoc._get_source_dirNcs>tjdtjjtji}|j}x>|jjD]2}d|kr.x$tj |D]\}}}t |||qFWq.Wfddt fdd|j D}tjj |d} t| d} | jd x|D]x} tjj |d | } d | } d t| }t| | |d }tjd| t| d}|jt|WdQRX| jd| qWWdQRXdS)Nz[pbr] Autodocumenting from %srcstfddD S)Nc3s|]}tj|VqdS)N)fnmatch).0pat)modulerr nszDLocalBuildDoc.generate_autoindex..include..)any)r3)excluded_modules)r3rincludems z1LocalBuildDoc.generate_autoindex..includec3s|]}|r|VqdS)Nr)r1mod)r7rrr4qsz3LocalBuildDoc.generate_autoindex..z autoindex.rstwz.. toctree:: :maxdepth: 1 z%s.rstzThe :mod:`%s` Module=)r3heading underlinez[pbr] Generating %sz %s.rst )rinfor'r(abspathcurdirr/r$packageswalkrsortedkeysr)openwritelendict _rst_template)r,r6modulesr"pkgdirpathdirnamesrZ module_listZautoindex_filenameZ autoindexr3Zoutput_filenamer;r<valuesZ output_filer)r6r7rgenerate_autoindexcs4      z LocalBuildDoc.generate_autoindexcCs:|j}ddd|dg}tr&|jddtj||jdS)Nz-HModulesz-orrr)r/apidoc_use_paddinginsertrmainr )r,r"cmdrrr _sphinx_trees  zLocalBuildDoc._sphinx_treecCs^|jstj}ntj}i}|jr*|j|d<|jr:|j|d<|jrJ|j|d<|jrZ|j|d<|j rrddddd g|d <t j |j |j |j|j|j|||j|jd }d |_ y|j|jd Wnttk r(}zVddlm}t||jrtjjdtjj|jdjddtjjdnWYdd}~XnX|jrZ|j j!|jj"}|jj#d}t$j%||dS)Nprojectrreleasetodayzapp.add_directivez app.add_rolezapp.add_generic_rolez app.add_nodezimage.nonlocal_uriZsuppress_warnings)ZfreshenvZwarningiserrorT)Z force_allr)utilszreST markup error: asciibackslashreplace index)&verbose cStringIOStringIOsysstdoutrUrrVrWsphinx_initializedrZSphinxr"Z config_dirZbuilder_target_dirZ doctree_dirbuilderZ fresh_envwarning_is_errorbuild all_files ExceptionZdocutilsrX isinstanceZ SystemMessageZstderrEstderrargsencodeZ link_indexconfigZ master_docZ out_suffixZget_outfilenamer'symlink)r,Z status_streamZ confoverridesZapperrrXsrcdstrrr _sphinx_runsH         zLocalBuildDoc._sphinx_runc Csx|jjd}t|jjt}ttddt}|s8|rjd}|rP|dt|7}|r`|d|7}t j |t j rt j |dt j|dtj|dd }tj|d d }tjd s|r|j|r|jt|jd ddgdj|jtjjtjtjddk}|st j d|jdgkr:t j d|r:|j|_|rLtj j!|Sx&|jD]}||_|j|j"qTWdS)NrcSs tj|S)N)r'getenv)xrrrsz#LocalBuildDoc.run..zThe 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 rZ SPHINX_DEBUGr r#zQ[pbr] Support for Sphinx < 1.6 will be dropped in pbr 4.0. Upgrade to Sphinx 1.6+ra'[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%setrC intersection_deprecated_optionslistfilter_deprecated_envsrwarnrZ_git_is_installedZwrite_git_changelogZgenerate_authorsrZget_boolean_optionr'rrrTrNr&splitfinalize_optionsrZSemanticVersionZfrom_pip_stringsphinx __version__buildersrcrBuildDocrunrq) r,r-Z warn_optsZwarn_envmsgZ tree_indexZ auto_indexZis_multibuilder_sphinxrcrrrrsT          zLocalBuildDoc.runcCstjj|dg|_dS)Nzsetup.py)rrinitialize_optionsr )r,rrrrs z LocalBuildDoc.initialize_optionscCsddlm}tjj||jjd}d|jdggdkrH|dd|_t |jt  rj|jrj|jj d|_|jj |_ |jj|_|jj|_d}|jjd }||kr|j||d|_t|d sd |_dS) Nr)utilrz command linercr#,r rrdF)rrrrrr$r%r&rrhrzr~get_namerU get_versionrrVZsplit_multiliner hasattrrd)r,rr-optrrrrs"        zLocalBuildDoc.finalize_options)N) __name__ __module__ __qualname__r command_namerbr/rNrTrqrrrrrrrrPs #,Gr) distutilsrr0r'r`r^ ImportErroriorZ sphinx.extrrPrrrgestrrrrrryr|rHrrrrrrrs8