B t `ã@sÒdZddlZy,ddlmZmZddlmZddlmZWne k rLYnXddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZd d „Zdd„ZGdd„deƒZGdd„deƒZdd„ZdS)aÊ Adds a sphinx directive that can be used to automatically document a plugin. this:: .. autoplugin :: nose.plugins.foo :plugin: Pluggy produces:: .. automodule :: nose.plugins.foo Options ------- .. cmdoption :: --foo=BAR, --fooble=BAR Do the foo thing to the new thing. Plugin ------ .. autoclass :: nose.plugins.foo.Pluggy :members: Source ------ .. include :: path/to/nose/plugins/foo.py :literal: éN)ÚnodesÚutils)ÚViewList)Ú directives)Ú resolve_name)ÚPlugin)ÚBuiltinPluginManager)ÚConfig)Ú TestProgram)Úisclassc  Cs*|d} t| ƒ} | dd¡} | r,t| | ƒ} nDxBt| ƒD]6} t| | ƒ} t| ƒr6t| tƒr6| tk r6d| | f} Pq6Wtƒ}| d| d¡| dd¡| dd¡| dd¡| dd¡| ƒ}t ƒ}|  |i¡xJ|D]B}| |  ¡d¡| d d¡| d |j d d¡| d d¡qÔW| d d¡| d d¡| dd¡| d| d¡| dd¡| dd¡| dd¡| dd¡| d d¡| dt   |jdtj | j dd¡¡¡d¡| dd¡| dd¡t ¡}|j|_|jj}|jj}g|j_d|j_|j|d|dd||j_||j_|jS)NrÚpluginz%s.%sz.. automodule :: %s z ÚÚOptionsz-------z z Ú rz------z.. autoclass :: %s z :members: z :show-inheritance: ZSourcez.. include :: %s Úsourcez.pycz.pyz :literal: é)Ú match_titles)rÚgetÚgetattrÚdirr Ú issubclassrrÚappendÚ OptBucketÚoptionsÚhelprÚ relative_pathÚdocumentÚosÚpathÚabspathÚ__file__ÚreplacerÚsectionÚmemoÚ title_stylesÚ section_levelÚ nested_parseÚchildren)ÚdirnameÚ argumentsrÚcontentÚlinenoÚcontent_offsetÚ block_textÚstateÚ state_machineÚmod_nameÚmodZ plug_nameÚobjÚentryÚrstZplugÚoptsÚoptÚnodeÚsurrounding_title_stylesÚsurrounding_section_level©r:ú:/tmp/pip-unpacked-wheel-cjhnoqsi/nose/sphinx/pluginopts.pyÚautoplugin_directive1sd                     r<c Cstttƒd} |  t ¡¡} tƒ} x"|  ¡ d¡D]} |   | d¡q2W|   dd¡|   dd¡|   dd¡xJ| D]B} |   |   ¡d¡|   dd¡|   d| j dd¡|   dd¡qpWt   ¡}|j|_|jj}|jj}g|j_d |j_|j| d |d d ||j_||j_|jS) zproduces rst from nose help)Z parserClassZpluginsrz rz-------r z z rr)r)r rrZ getParserr ÚusagerÚ format_helpÚsplitrrrrr"rr#r$r%r&r')r(r)rr*r+r,r-r.r/ÚconfigÚparserr4Úliner6r7r8r9r:r:r;Úautohelp_directivets0      rCc@s.eZdZd dd„Zdd„Zdd„Zd d „ZdS) rNÚ nosetestscCsg|_||_||_dS)N)r5ÚdocÚprog)ÚselfrErFr:r:r;Ú__init__”szOptBucket.__init__cCs t|jƒS)N)Úiterr5)rGr:r:r;Ú__iter__™szOptBucket.__iter__cCs|j d|j¡ dd¡S)Nz%progz: z:: )rEr!rF)rGr:r:r;r>œszOptBucket.format_helpcOs|j t||Ž¡dS)N)r5rÚOpt)rGÚargÚkwr:r:r;Ú add_optionŸszOptBucket.add_option)NrD)Ú__name__Ú __module__Ú __qualname__rHrJr>rNr:r:r:r;r“s rc@s$eZdZdd„Zdd„Zdd„ZdS)rKcOsB||_| dd¡|_| dd¡|_| dd¡|_| dd¡|_dS)NÚactionÚdefaultÚmetavarr)r5ÚpoprRrSrTr)rGrLrMr:r:r;rH¤s z Opt.__init__cCsLg}x8|jD].}|}|jdkr0|d| |¡7}| |¡q Wdd |¡S)N)Ú store_trueÚ store_falsez=%sz.. cmdoption :: z, )r5rRÚmetarÚjoin)rGÚbufÚ optstringÚdescr:r:r;r«s  z Opt.optionscCs |jpdS)NÚDEFAULT)rT)rGr[r:r:r;rX´szOpt.metaN)rOrPrQrHrrXr:r:r:r;rK£s rKcCs*|jdtddtjd| dtdd¡dS)NZ autopluginr)rrr)r Zautohelpr)rrr)Z add_directiver<rZ unchangedrC)Zappr:r:r;Úsetup¹s r^)Ú__doc__rZdocutilsrrZdocutils.statemachinerZdocutils.parsers.rstrÚ ImportErrorZ nose.utilrZnose.plugins.baserZnose.plugins.managerrZ nose.configr Z nose.corer Úinspectr r<rCÚobjectrrKr^r:r:r:r;Ú s$       C