ó 1Tc@s%dZddlZddlZddlZddlmZddlmZddlmZdej kr‚ej dj dƒZ ndd d gZ d Z e d d gƒZd„Zd„Zd„Zdd„Zd„Zd„Zdd„Zd„Zd„Zd„Zd„Zejd„ZdS(s  sphinx.apidoc ~~~~~~~~~~~~~ Parses a directory tree looking for Python modules and packages and creates ReST files appropriately to create code documentation with Sphinx. It also creates a modules index (named modules.). This is derived from the "sphinx-autopackage" script, which is: Copyright 2008 Société des arts technologiques (SAT), http://www.sat.qc.ca/ :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. iÿÿÿÿN(tpath(twalk(t __version__tSPHINX_APIDOC_OPTIONSt,tmemberss undoc-memberssshow-inheritances __init__.pys.pys.pyxcCs0|r&|}|r,|d|7}q,n|}|S(s#Join package and module with a dot.t.((tpackagetmoduletname((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pytmakename(s cCs˜tj|jd||jfƒ}|jr8d|GHdS|j r]tj|ƒr]d|GHn7d|GHt|dƒ}z|j|ƒWd|j ƒXdS(s0Write the output file for module/package .s%s.%ssWould create file %s.Ns!File %s already exists, skipping.sCreating file %s.tw( Rtjointdestdirtsuffixtdryruntforcetisfiletopentwritetclose(R ttexttoptstfnametf((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pyt write_file4s"    cCs/dddg|dt|ƒ}d||fS(s2Create a heading of [1, 2 or 3 supported].t=t-t~is%s %s (tlen(tlevelRt underlining((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pytformat_headingEs!cCs6dt||ƒ}xtD]}|d|7}qW|S(s4Create the automodule directive and add the options.s.. automodule:: %s s :%s: (R tOPTIONS(RRt directivetoption((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pytformat_directiveKs cCsU|jstdd|ƒ}nd}|t||ƒ7}tt||ƒ||ƒdS(s.Build the text of the file and write the file.is %s moduletN(t noheadingsR R$RR (RRRR((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pytcreate_module_fileSs  c Csxtddt||ƒƒ}g|D]*}tjtj||tƒƒr#|^q#}|r±|tddƒ7}|d7}x+|D]#}|dt||ƒ|f7}q}W|d7}ng|D]A}ttj||ƒ|ƒ r¸|tkr¸tj|ƒd^q¸}|r5|tdd ƒ7}|jr¶|d7}xú|D]}} t|t|| ƒƒ} |d | 7}|j s}tdd | ƒ} nd } | t t|| ƒ|ƒ7} t | | |ƒq2Wnrxo|D]g} t|t|| ƒƒ} |j sþ|tdd | ƒ7}n|t t|| ƒ|ƒ7}|d7}q½W|d7}n|tdd ƒ7}|t ||ƒ7}t t||ƒ||ƒdS(s.Build the text of the file and write the file.is %s packageit Subpackagess.. toctree:: s %s.%s s it Submoduless %s s %s moduleR%sModule contentsN( R R RRR tINITPYt shall_skiptsplitexttseparatemodulesR&R$R( troottmaster_packagetsubroottpy_filesRtsubsRtsubtsubmodstsubmodtmodfiletfiletext((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pytcreate_package_file^sF7  !  %         tmodulescCs“tdd|jƒ}|d7}|d|j7}|jƒd}x;|D]3}|j|dƒrgqHn|}|d|7}qHWt|||ƒdS( sCreate the module's index.is%ss .. toctree:: s :maxdepth: %s R%Rs %s N(R theadertmaxdepthtsortt startswithR(R9RR Rt prev_moduleR((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pytcreate_modules_toc_files   cCsUtj|ƒdkrtStj|ƒ}|dkrQ|jdƒrQ|j rQtStS(s%Check if we want to skip this module.is __init__.pyt_(RtgetsizetTruetbasenameR=tincludeprivatetFalse(RRtfilename((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pyR+¡s cs>ttj|ƒkr.|jtjƒd}nd }g}t|dtƒ}t|dtƒ}xÙt |d|ƒD]Å\‰}}t ‡‡fd†|Dƒƒ} t| k} | rÑ| j tƒ| j dtƒnˆ|krç|2qqn|röd ‰nd ‰t ‡‡‡fd†|Dƒƒ|(| r¹|sYt | ƒd ksYttjˆtƒ|ƒ r6ˆt |ƒjtjƒjtjdƒ} tˆ|| | ||ƒ|jt|| ƒƒq6qqˆ|krÑ|d ks×t‚x\| D]T} ttj|| ƒ|ƒsÞtj| ƒd} t|| |ƒ|j| ƒqÞqÞWqqW|S( s` Look for every file in the directory tree and create the corresponding ReST files. iÿÿÿÿt followlinksRDc3sJ|]@}tj|ƒdtkrttjˆ|ƒˆƒ r|VqdS(iN(RR,t PY_SUFFIXESt is_excludedR (t.0R(texcludesR.(s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pys ¿siRR@c3sA|]7}|jˆƒ rttjˆ|ƒˆƒ r|VqdS(N(R=RIRR (RJR3(texclude_prefixesRKR.(s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pys ÐsiN(R(RR@(R*tostlistdirtsplitRtseptNonetgetattrRERtsortedtremovetinsertRR+R tlstriptreplaceR8tappendR tAssertionErrorR,R'(trootpathRKRt root_packaget toplevelsRGRDR2tfilesR1tis_pkgt subpackagetpy_fileR((RLRKR.s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pyt recurse_tree®sD"    #   cCs)g|D]}tjtj|ƒƒ^qS(s&Normalize the excluded directory list.(Rtnormpathtabspath(RZRKtexclude((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pytnormalize_excludesèscCs4tj|ƒ}x|D]}||krtSqWtS(sÃCheck if the directory is in the exclude list. Note: by having trailing slashes, we avoid common prefix issues, like e.g. an exlude "foo" also accidentally excluding "foobar". (RRbRBRE(R.RKRd((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pyRIís   c !Cs tjddƒ}|jddddddd d d d ƒ|jd dddddd dddd dƒ|jddddddd dƒ|jddddddd td dƒ|jddddddd d ƒ|jd!d"dddd#d d$ƒ|jd%d&dddd'd d(ƒ|jd)d*dddd+d d,ƒ|jd-d.dddd/d d0ƒ|jd1d2dddd3d d4d d5ƒ|jd6d7dddd8d d9ƒ|jd:d;dddd<d d=ƒ|jd>d?dddd@ddAd dBƒ|jdCdDddddEd dFƒ|jdGdHddddId dJƒ|jdKddddLd dMƒ|j|dNƒ\}}|jr‚dOtGHdPS|s˜|jdQƒn|dP|dN}}|jsÆ|jdRƒn|j dikrút j |ƒj t jƒdS|_ n|jjdTƒr|jdN|_nt j|ƒsOtjdU|IJtjdNƒnt j|jƒs€|js€tj|jƒq€nt j t j|ƒƒ}t||ƒ}t|||ƒ}|jrîdSdVlm}|jƒd }d } x;|D]3} | j|dTƒrqïn| }| dW| 7} qïWtdX|jdYtdZd[d\|j d@|j pVd]dE|j!ped dI|j"p}|j!p}d d3dT|jd^d_d`t#dat#dbt#dct#ddt#de|j$df| ƒ} |js|j%| dgt#dh|j&ƒqn|j'st(||ƒndiS(js+Parse and check the command line arguments.tusages†usage: %prog [options] -o [exclude_path, ...] Look recursively in for Python modules and packages and create one reST file with automodule directives per package in the . The s can be files and/or directories that will be excluded from generation. Note: By default this script will not overwrite already created files.s-os --output-dirtactiontstoretdestR thelpsDirectory to place all outputtdefaultR%s-ds --maxdepthR;s;Maximum depth of submodules to show in the TOC (default: 4)ttypetintis-fs--forcet store_trueRsOverwrite existing filess-ls--follow-linksRGsNFollow symbolic links. Powerful when combined with collective.recipe.omelette.s-ns --dry-runRs%Run the script without creating filess-es --separateR-s1Put documentation for each module on its own pages-Ps --privateRDsInclude "_private" moduless-Ts--no-toctnotocs%Don't create a table of contents files-Es --no-headingsR&seDon't create headings for the module/package packages (e.g. when the docstrings already contain them)s-ss--suffixRsfile suffix (default: rst)trsts-Fs--fulltfulls.Generate a full project with sphinx-quickstarts-Hs --doc-projectR:s(Project name (default: root module name)s-As --doc-authortauthortstrs,Project author(s), used when --full is givens-Vs --doc-versiontversions*Project version, used when --full is givens-Rs --doc-releasetreleasesEProject release, used when --full is given, defaults to --doc-versions --versiont show_versions!Show version information and exitisSphinx (sphinx-apidoc) %sisA package path is required.s An output directory is required.iÿÿÿÿRs%s is not a directory.(t quickstarts %s RRPtdotR@tprojecttAuthortmastertindextepubt ext_autodoct ext_viewcodetmakefilet batchfiletmastertocmaxdeptht mastertoctreetsilentt overwriteN()toptparset OptionParsert add_optionREt parse_argsRvRterrorR R:RQRRbRORPRR=tisdirtsyststderrtexitRRMtmakedirsRcReRaRqtsphinxRwR<tdictRrRtRuRBR;tgenerateRRoR?( targvtparserRtargsRZRKR9tqsR>RRtd((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pytmainúsº        %          " (t__doc__RMRŒR†Rtsphinx.util.osutilRRRtenvironROR!R*tsetRHR RR RQR$R'R8R?R+RaReRIR“R˜(((s7/usr/local/lib/python2.7/site-packages/sphinx/apidoc.pyts2        1  :