
    le	F                        d dl mZ d dlmZ d dlmZ d dlmZ 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 d dlmZ d dlmZ d dlmZ  ej4                  e      Zd3dZd4dZd Zej@                  dejB                  dejD                  dejF                  dejH                  dejJ                  dejL                  dejN                  dejP                  dejR                  dejT                  dejV                  dejX                  dejZ                  d iZ.d! Z/d" Z0d# Z1d$ Z2d% Z3 G d& d'ejh                        Z5 G d( d)e      Z6 G d* d+e      Z7 G d, d-ejh                        Z8 G d. d/e      Z9 G d0 d1e      Z:d2 Z;y)5    )nodes)rst)
directives)ViewListN)addnodes)ObjectDescription)Domain)ObjType)XRefRole)logging)make_refnode)nested_parse_with_titles)cfg)	generatorc              #      K   d|z   d |rddj                  d |D              z   d d| d   z   | d	d
 D ]	  }d|z    |D ]  }d|d   z   |d	d
 D ]	  }d|z     y
w)zBuild a list-table directive.

    :param add: Function to add one row to output.
    :param headers: List of header values.
    :param data: Iterable of row data, yielding lists or tuples with rows.
    z.. list-table:: %sz   :header-rows: 1z   :widths: %s,c              3   2   K   | ]  }t        |        y wNstr).0cs     7/usr/lib/python3/dist-packages/oslo_config/sphinxext.py	<genexpr>z_list_table.<locals>.<genexpr>+   s     *Ca3q6*Cs    z	   - * %sr      Nz	     * %s)join)headersdatatitlecolumnshrowrs          r   _list_tabler%   !   s      
&&
#((*C7*C"CDD
H


""QR[ Ao "CF""QR 	"A/!	""s   A-A/c                 ^    d|z  dj                  fd| j                         D              S )N 
c              3   0   K   | ]  }|r|z   nd   ywr   N )r   xpaddings     r   r   z_indent.<locals>.<genexpr>9   s     I!AWq[2-Is   )r   
splitlines)textnr-   s     @r   _indentr1   6   s(    AgG99It7HIII    c                 V    t        j                  |       d|j                         }|S )N.)r   _normalize_group_namelower)
group_nameoption_nametargets      r   _make_anchor_targetr:   <   s*     11*=#))+-FMr2   stringbooleanintegerzfloating pointlistdictzmulti-valuedz
ip addresszport numberhostnameURIzhost addresszlist of filenameszlist of directory namesc                 *    | y| dk(  ryt        |       S )Nz<None>r   z''r   )choices    r   _get_choice_textrD   V   s    ~	2v;r2   c           	   #   	   K   t         j                  t               d      }d j                  z   d t	        d|z         t        j                         D ]%  }|rt	        d|z         t	        d|z         ' t         j                  dd       $t	        d j                  j                  z         t         j                  d	d       $t	        d
 j                  j                  z         t         j                  dd       rLdj                   j                  j                  D cg c]  }t        |       c}      }t	        d|z         	  j                  rt	        d        j*                  r)t	        d       t	        dd       t	        dd        j,                  r4t	        d       t	        d       t	        d       t	        d       	  j.                  ddiz  }|rBd |j7                         j9                         D ]  }	t	        |	j;                                 t         j                  dd       rt=        d  j                  j                  j?                         D              swd t	        d        j                  j                  D ]M  }d t	        t        |             t	        t	         j                  j                  |   xs d              O  j@                  r:d tC        d!d"g fd# j@                  D        d$%      D ]  }	t	        |	         jD                  rd t	        d&        jF                  rt	        d' jF                  z         nt	        d(       t	        d)       t	        d*        jH                  rYd+j                   jH                  j9                         D 
cg c]  }
|
j7                          c}
      }d t	        d,|z          d y c c}w # t        $ ry}dd l}t!        t"        j$                         s/|j'                  d j                  d j(                  d|       n!|j'                  d j                  d|       Y d }~*d }~ww xY w# t0        t2        t4        f$ r  j.                  }Y w xY wc c}
w w)-Nzunknown typez.. oslo.config:option:: %sr   z	:Type: %sz:Default: ``%s``z:Default: ``%r``minz:Minimum Value: %smaxz:Maximum Value: %schoicesz, z:Valid Values: %sz8:Mutable: This option can be changed without restarting.r   zIncompatible option class for z (z): z"Failed to fully format sample for : z::Advanced Option: Intended for advanced users and not usedz6by the majority of users, and might have a significant   z'effect on stability and/or performance.z6This option has a sample default set, which means thatz9its actual default value may vary from the one documentedzabove.defaultzthe value abovec              3   $   K   | ]  }|d u  
 y wr   r+   )r   r,   s     r   r   z_format_opt.<locals>.<genexpr>   s      6:AI6:s   z.. rubric:: Possible valuesz<No description provided>GroupNamec              3   z   K   | ]2  }|j                   xs |j                  xs j                  xs d f 4 yw)UNSETN)groupnamedest)r   dr7   opts     r   r   z_format_opt.<locals>.<genexpr>   s<      / '''Z&&/CHH/1 /s   8;zDeprecated Variations)r    z.. warning::z2   This option is deprecated for removal since %s.z)   This option is deprecated for removal.z%   Its value may be silently ignored z   in the future.r'   z   :Reason: )%_TYPE_DESCRIPTIONSgettyperS   r1   r   _format_defaultsgetattrrF   rG   r   rH   rD   mutableAttributeErrorwarnings
isinstancer   Optwarn	__class__advancedsample_defaulthelp	TypeErrorKeyError
ValueErrorstripr.   rstripallvaluesdeprecated_optsr%   deprecated_for_removaldeprecated_sincedeprecated_reason)rU   r7   opt_typerK   rC   choices_texterrr]   	help_textliner,   reasons   ``          r   _format_optrv   ^   s    !%%d3i&46H
&
11
H
+(
))--c2 8,w677,w677	8
 sxx%1*SXX\\9::sxx%1*SXX\\9::sxxD)yy030@0@"B&, #36": "B C)L899+;;J * ||HJ 	JDaI 	I5q: 	:  	DF 	FGI 	I 	HH	+<==	 OO%002 	)D$++-((	)
 sxxD)# 6:"xx//6686: 3:344hh&& 	JFH*6233'  (G,GI J J	J &!/--/ ./ 	 D $-	  !!n%% &(+(<(<= > > EFF=>>)**  XX"44??ACQqwwy C DFH.6122
H}"B  + 	#''3'MM3==#/
 MM88S* +!+L x,  HH		VCso   D2S6P!S P& 9A5S/R+  G*S*S%S&	R(/A.R#S#R((S+ SSSSc              #      K   d|z   | rd| z   d |rZ|j                   rM|j                   j                         j                         D ]  }t        |j	                                 d y y y w)Nz.. oslo.config:group:: %sz   :namespace: %sr   )rd   rh   r.   r1   ri   )	namespacer7   	group_objrt   s       r   _format_grouprz      so     
%

22!I--
HY^^NN((*557 	)D$++-((	) $ys   A2A4c              #      K   |xs d}t         j                  d| |       t        | ||      D ]  }|  |D ]  }t        ||      D ]  }|   y w)NDEFAULTz%s %s)LOGdebugrz   rv   )rx   r7   ry   opt_listrt   rU   s         r   _format_group_optsr      si     (yJIIgy*-iY? 
  Z0 	DJ	s   AAc              #   ~  K   t        j                  |       }|r^|D ]X  \  }}|D ]N  \  }}t        |t        j                        r|j
                  }n|}d}|d}t        ||||      }|D ]  }|  P Z yi }	i }
|D ]q  \  }}|D ]g  \  }}t        |t        j                        r|j
                  }n|}d}|d}|
j                  ||       |	j                  |g       j                  |       i s t        |	j                               D ].  \  }}t        d||
j                  |      |      }|D ]  }|  0 yw)zGenerate a series of lines of restructuredtext.

    Format the option help as restructuredtext and return it as a list
    of lines.
    Nr|   )rx   r7   ry   r   )r   
_list_optsr^   r   OptGrouprR   r   
setdefaultextendsorteditemsrW   )
namespacessplit_namespacesoptsrx   r   rQ   r7   linesrt   
by_section
group_objsignore
group_optss                r   _format_option_helpr      s     
+D#' 	Ix' teS\\2!&J!&J E%!*J*')#!	 " DJ	* 

 $ 
	IFH%- 	I!zeS\\2!&J!&J E%!*J%%j%8%%j"5<<ZH	I
	I '-Z-=-=-?&@ 	"J
&%$..4#	E  
	s   D;D=c                   H    e Zd Zej                  ej
                  dZdZd Zy)ShowOptionsDirective)split-namespacesconfig-fileTc                 *   d| j                   v }| j                   j                  d      }|ret        j                  d|       t	        j
                         }|j                  t        j                          |d|gd       |j                  d d  }n7| j                  D cg c]"  }|j                         r|j                         $ }}t               }| j                  j                  j                  }t!        t#        ||            D ]4  \  }}	|j%                  |	||       t        j'                  d||	rdnd	|	       6 t)        j*                         }
| j                  j                  |
_        t-        | j                  ||
       |
j.                  S c c}w )
Nr   r   zloading config file %sz--config-filezoslo.config.sphinxext)argsprojectz%5d%s%sr'   r   )optionsrW   r}   infor   
ConfigOptsregister_optsr   _generator_optsrx   contentrh   r   statedocumentcurrent_source	enumerater   appendr~   r   sectionr   children)selfr   config_fileconfr   r   resultsource_namecountrt   nodes              r   runzShowOptionsDirective.run&  sW   -=ll&&}5HH-{;>>#Dy889%{3/ *J 779 	J  jj))88$%8,&. / 	CKE4MM$U3IIitTB	C
 }}

++ 	!VT:}}1s   'FN)	__name__
__module____qualname__r   flag	unchangedoption_spechas_contentr   r+   r2   r   r   r     s'     'OO!++K
 K&r2   r   c                   (     e Zd ZdZ fdZd Z xZS )ConfigGroupXRefRolezCHandles :oslo.config:group: roles pointing to configuration groups.c                 .    t         t        |   d       y NT)warn_dangling)superr   __init__r   ra   s    r   r   zConfigGroupXRefRole.__init__R  s    !41 	2 	
r2   c                 
    ||fS r   r+   )r   envrefnodehas_explicit_titler    r9   s         r   process_linkz ConfigGroupXRefRole.process_linkW  s    v~r2   r   r   r   __doc__r   r   __classcell__ra   s   @r   r   r   O  s    I

r2   r   c                   (     e Zd ZdZ fdZd Z xZS )ConfigOptXRefRolezEHandles :oslo.config:option: roles pointing to configuration options.c                 .    t         t        |   d       y r   )r   r   r   r   s    r   r   zConfigOptXRefRole.__init___  s    / 	0 	
r2   c                 d    |s|}d|v r|j                  d      \  }}nd}|}t        ||      }||fS )Nr4   r|   )splitr:   )	r   r   r   r   r    r9   rQ   opt_nameanchors	            r   r   zConfigOptXRefRole.process_linkd  sC    !E&=$ll3/OE8EH$UH5f}r2   r   r   s   @r   r   r   \  s    K

	r2   r   c                   :    e Zd ZdZdZdZdej                  iZd Z	y)ConfigGroupr   r   Trx   c                 P   | j                   j                  j                  j                  }| j                  d   }| j
                  j                  d      }|j                  d   d   }||j                  d<   t        j                  d|z         |j                  ||<   t               dt        z   dz   fd	}|r|d
|}n|} ||        |dt        |      z          |d       | j                  D ]
  } ||        t!        j"                         }| j                   j                  |_        t%        | j                   |       |j&                  d   }	t)        j*                  |      }
|	d   j-                  |
       t/        j0                  g       }|g|j&                  z   S )Nr   rx   oslo.configgroupsoslo.config:groupzoslo.config group %s<>c                 *    j                  |        y)z8Append some text to the output result view to be parsed.N)r   )r/   r   r   s    r   _addzConfigGroup.run.<locals>._add  s    MM$,r2   rI   -r   ids)entries)r   r   settingsr   	argumentsr   rW   
domaindata	temp_datar}   r~   docnamer   r   lenr   r   r   r   r   r   r5   r   r   index)r   r   r7   rx   cached_groupsr   r    rt   r   first_childtarget_name	indexnoder   r   s               @@r   r   zConfigGroup.runy  sk   jj!!**..^^A&
LL$$[1	}5h? .8)*		(:56
 %(KKj!Hns*	-  ):6EEUS3u:RLL 	DJ	}}

++ VT:mmA& //
;E!!+.NN2.	{T]]**r2   N)
r   r   r   required_argumentsoptional_argumentsr   r   r   r   r   r+   r2   r   r   r   p  s*    KZ))K.+r2   r   c                       e Zd ZdZd Zd Zy)ConfigOptionz2Description of a configuration option (.. option).c                 t    |}t         j                  d|       |t        j                  ||      z  }|g|d<   |S )z/Transform an option description into RST nodes.zoslo.config option %sallnames)r}   r~   r   	desc_name)r   sigsignodeoptnames       r   handle_signaturezConfigOption.handle_signature  s>    		)738%%gw77&i
r2   c                 B   | j                   j                  d   d   }| j                   j                  j                  d      }t	        ||      }|d   j                  |       | j                  j                  j                  |       | j                   j                  ||<   y )Nr   r   r   r   )
r   r   r   rW   r:   r   r   r   note_explicit_targetr   )r   	firstnamer   r   cached_options	currgroupr   s          r   add_target_and_indexz!ConfigOption.add_target_and_index  s    ,,];IFHH&&**+>?	 *)S9k*

009 '+hh&6&6{#r2   N)r   r   r   r   r   r   r+   r2   r   r   r     s    87r2   r   c                   l    e Zd ZdZdZdZd edd      iZee	dZ
 e        e       dZi i dZd	 Zd
 Zy)ConfigDomainzoslo.config domain.r   configoptionzconfiguration optionoption)rQ   r   )r   rQ   )r   r   c                     |dk(  r8|j                  dd      \  }}	t        |||j                  d   d   |   |||	      S |dk(  r#t        |||j                  d   d   |   |||      S y)	zResolve cross-referencesr   r4   r   r   r   rQ   r   N)r   r   r   )
r   r   fromdocnamebuildertypr9   r   contnoder7   r8   s
             r   resolve_xrefzConfigDomain.resolve_xref  s     (?&,ll3&:#J}-i8@  '>}-h7?  r2   c                     |d   j                         D ]  \  }}||v s|| j                  d   |<    |d   j                         D ]  \  }}||v s|| j                  d   |<    y )Nr   r   )r   r   )r   docnames	otherdatar9   r   s        r   merge_domaindatazConfigDomain.merge_domaindata  s|    (399; 	7OFG("/6		)$V,	7  )288: 	6OFG(".5		(#F+	6r2   N)r   r   r   r   rR   labelr
   object_typesr   r   r   r   r   rolesinitial_datar   r  r+   r2   r   r   r     s`    DE 6AL J
 $%$&E
 L
06r2   r   c                     t        j                  d       | j                  dt               | j	                  t
               dddS )NFzshow-optionsT)parallel_read_safeparallel_write_safe)	oslo_i18nenable_lazyadd_directiver   
add_domainr   )apps    r   setupr    s?     % n&:;NN< "# r2   r*   )   )<docutilsr   docutils.parsersr   docutils.parsers.rstr   docutils.statemachiner   r
  sphinxr   sphinx.directivesr   sphinx.domainsr	   r
   sphinx.rolesr   sphinx.utilr   sphinx.util.nodesr   r   oslo_configr   r   	getLoggerr   r}   r%   r1   r:   StrOptBoolOptIntOptFloatOptListOptDictOptMultiStrOptIPOptPortOptHostnameOptURIOptHostAddressOpt_ConfigFileOpt_ConfigDirOptrV   rD   rv   rz   r   r   	Directiver   r   r   r   r   r   r  r+   r2   r   <module>r,     s\      + *   / ! " !  * 6  !g!"*J JJKKJJ	LL"KKKKOO^II|KKOOZJJ+0 $nb		3l/3== /d
( 
 (7+#-- 7+t7$ 76366 36lr2   