a
    ñ»jä  ã                   @   sÐ   d Z ddlZz,ddlmZmZ ddlmZ ddlmZ W n e	yJ   Y n0 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ dd„ Zdd„ ZG dd„ deƒZG dd„ deƒZdd„ ZdS )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	                 C   s$  |d }	t |	ƒ}
| dd ¡}|r,t|
|ƒ}nBt|
ƒD ]8}t|
|ƒ}t|ƒr4t|tƒr4|tur4d|	|f } qnq4tƒ }| d|	 d¡ | dd¡ | dd¡ | dd¡ | dd¡ |ƒ }t	ƒ }| 
|i ¡ |D ]B}| | 
¡ d¡ | d	d¡ | d
|j d d¡ | dd¡ qÐ| dd¡ | dd¡ | dd¡ | d| d¡ | dd¡ | dd¡ | dd¡ | dd¡ | dd¡ | dt |jd tj |
j dd¡¡¡ d¡ | dd¡ | dd¡ t ¡ }|j|_|jj}|jj}g |j_d|j_|j|d|dd� ||j_||j_|jS )Nr   Úpluginz%s.%sz.. automodule :: %s
ú	<autodoc>Ú ÚOptionsú-------ú   
ú   Ú
r   z------z.. autoclass :: %s
z   :members:
z   :show-inheritance:
ZSourcez.. include :: %s
Úsourcez.pycz.pyz   :literal:
é   ©Zmatch_titles)r   ÚgetÚgetattrÚdirr   Ú
issubclassr   r   Ú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ÚrstZplugÚoptsÚoptÚnodeÚsurrounding_title_stylesÚsurrounding_section_level© r>   ú<E:\soccer\ml_env\Lib\site-packages\nose/sphinx/pluginopts.pyÚautoplugin_directive"   sh    
þür@   c	                 C   s  t ttƒ d�}	|	 t ¡ ¡}
tƒ }|
 ¡  d¡D ]}| 	|d¡ q0| 	dd¡ | 	dd¡ | 	dd¡ |
D ]B}| 	| 
¡ d¡ | 	dd¡ | 	d|j d d¡ | 	dd¡ qjt ¡ }|j|_|jj}|jj}g |j_d	|j_|j|d	|d
d� ||j_||j_|jS )N)ZparserClassÚpluginsr   r   r   r   r   r   r   r   r   r   )r	   r   r   Z	getParserr
   Úusager   Úformat_helpÚsplitr   r   r   r   r&   r    r'   r(   r)   r*   r+   )r,   r-   r   r.   r/   r0   r1   r2   r3   ÚconfigÚparserr8   Úliner:   r;   r<   r=   r>   r>   r?   Úautohelp_directiveY   s.    rH   c                   @   s.   e Zd Zddd„Zdd„ Zdd„ Zd	d
„ ZdS )r   NÚ	nosetestsc                 C   s   g | _ || _|| _d S ©N)r9   ÚdocÚprog)ÚselfrK   rL   r>   r>   r?   Ú__init__u   s    zOptBucket.__init__c                 C   s
   t | jƒS rJ   )Úiterr9   ©rM   r>   r>   r?   Ú__iter__z   s    zOptBucket.__iter__c                 C   s   | j  d| j¡ dd¡S )Nz%progz:
z::
)rK   r%   rL   rP   r>   r>   r?   rC   }   s    zOptBucket.format_helpc                 O   s   | j  t|i |¤Ž¡ d S rJ   )r9   r   ÚOpt©rM   ÚargÚkwr>   r>   r?   Ú
add_option€   s    zOptBucket.add_option)NrI   )Ú__name__Ú
__module__Ú__qualname__rN   rQ   rC   rV   r>   r>   r>   r?   r   t   s   
r   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )rR   c                 O   sB   || _ | dd ¡| _| dd ¡| _| dd ¡| _| dd ¡| _d S )NÚactionÚdefaultÚmetavarr   )r9   ÚpoprZ   r[   r\   r   rS   r>   r>   r?   rN   …   s
    zOpt.__init__c                 C   sH   g }| j D ].}|}| jdvr.|d|  |¡ 7 }| |¡ q
dd |¡ S )N)Ú
store_trueÚstore_falsez=%sz.. cmdoption :: z, )r9   rZ   Úmetar   Újoin)rM   ÚbufÚ	optstringÚdescr>   r>   r?   r   Œ   s    

zOpt.optionsc                 C   s
   | j pdS )NÚDEFAULT)r\   )rM   rc   r>   r>   r?   r`   •   s    zOpt.metaN)rW   rX   rY   rN   r   r`   r>   r>   r>   r?   rR   „   s   	rR   c                 C   s*   | j dtddtjd� |   dtdd¡ d S )NZ
autopluginr   )r   r   r   )r   Zautohelpr   )r   r   r   )Zadd_directiver@   r   Z	unchangedrH   )Zappr>   r>   r?   Úsetup™   s
    þrf   )Ú__doc__r!   Zdocutilsr   r   Zdocutils.statemachiner   Zdocutils.parsers.rstr   ÚImportErrorZ	nose.utilr   Znose.plugins.baser   Znose.plugins.managerr   Znose.configr	   Z	nose.corer
   Úinspectr   r@   rH   Úobjectr   rR   rf   r>   r>   r>   r?   Ú<module>   s$   7