U
    [e                     @   s   d dl 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lmZ d dlmZ e
eZd	d
 Zdd ZdddZG dd dejZdd ZdS )    N)nodes)rst)
directives)ViewList)logging)nested_parse_with_titles)	extensionc                 C   s   t | pdS )N )inspectgetdoc)plugin r   U/var/www/html/services/stratfitenv/lib/python3.8/site-packages/stevedore/sphinxext.py_get_docstring   s    r   c                 c   sR   t |  D ]@}| | }t|jp$d}| d  }d|j|f |jfV  qd S )N
r   z
* %s -- %s)sortednamesr   r   
splitlinesstripnamemodule_name)mgrr   extdocsummaryr   r   r   _simple_list   s    r   r	   -Fc                 c   s   t |  D ]}| | }|r2|t|j |jfV  |rJ|j |jfV  n|j|jfV  |rr|t|j |jfV  d|jfV  t|j}|r||jfV  nd|j|j	|jfV  d|jfV  qd S )Nr   z0.. warning:: No documentation found for {} in {})
r   r   lenr   r   titler   r   formatZentry_point_target)r   overunder	titlecaser   r   r   r   r   r   _detailed_list(   s(    
 r#   c                   @   s6   e Zd ZdZejejejejejdZdZ	dd Z
dS )ListPluginsDirectivez4Present a simple list of the plugins in a namespace.)classdetailedr"   overline-styleunderline-styleTc                 C   s   d | j }td|  | jdd}| jdd}dd }tj||d	}t	 }d
| jk}d| jkr|t
||||d}nt|}|D ]"\}	}
|	 D ]}|||
 qqt }| jj|_t| j|| |jS )N zdocumenting plugins from %rr'   r	   r(   =c                 S   s   t d|j|f  d S )NzFailed to load %s: %s)LOGwarningmodule)r   eperrr   r   r   report_load_failureT   s    z5ListPluginsDirective.run.<locals>.report_load_failure)Zon_load_failure_callbackr"   r&   )r    r!   r"   )joincontentr   r+   infooptionsgetr   ZExtensionManagerr   r#   r   r   appendr   sectionstateZdocumentr   children)self	namespaceZoverline_styleZunderline_styler0   r   resultr"   datatextsourcelinenoder   r   r   runN   s4    

  
zListPluginsDirective.runN)__name__
__module____qualname____doc__r   Zclass_optionflagZsingle_char_or_unicodeZoption_specZhas_contentrB   r   r   r   r   r$   A   s   r$   c                 C   s    t d | dt dddS )Nzloading stevedore.sphinxextzlist-pluginsT)Zparallel_read_safeZparallel_write_safe)r+   r3   Zadd_directiver$   )Zappr   r   r   setupr   s
    
rH   )r	   r   F)r
   Zdocutilsr   Zdocutils.parsersr   Zdocutils.parsers.rstr   Zdocutils.statemachiner   Zsphinx.utilr   Zsphinx.util.nodesr   Z	stevedorer   	getLoggerrC   r+   r   r   r#   Z	Directiver$   rH   r   r   r   r   <module>   s   
	
1