
    h                        S r SSKJr  SSKrSSKJr  SSKJr  SSK	J
r
Jr  SSKJr  SSKJr  SS	 jrSS
 jrSS jrSS jrSS jrSSS jjrg)a  Machinery for documenting traitlets config options with Sphinx.

This includes:

- A Sphinx extension defining directives and roles for config options.
- A function to generate an rst file given an Application instance.

To make this documentation, first set this module as an extension in Sphinx's
conf.py::

    extensions = [
        # ...
        'traitlets.config.sphinxdoc',
    ]

Autogenerate the config documentation by running code like this before
Sphinx builds::

    from traitlets.config.sphinxdoc import write_doc
    from myapp import MyApplication

    writedoc('config/options.rst',    # File to write
             'MyApp config options',  # Title
             MyApplication()
            )

The generated rST syntax looks like this::

    .. configtrait:: Application.log_datefmt

        Description goes here.

    Cross reference like this: :configtrait:`Application.log_datefmt`.
    )annotationsN)defaultdict)dedent)	HasTraits	Undefined)Application)indentc                .    U R                  SSSS9  SSS.$ )zxRegisters the Sphinx extension.

You shouldn't need to call this directly; configure Sphinx to use this
module instead.
configtraitzConfig option)objnameT)parallel_read_safeparallel_write_safe)add_object_type)apps    mC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\traitlets/config/sphinxdoc.pysetupr   .   s$     }oN"&tDD    c                    U b	  U [         L a  g[        U [        [        [        [
        [        45      (       a  [        U 5      $ g)NFT)r   
isinstancestrlisttupledictsetbool)dvs    r   interesting_default_valuer   8   s4    

i"sD%s344Bxr   c                    / nU  H-  n[        U5      S:X  a  SOSnUR                  SU U S35        M/     SR                  U5      $ )N   -z--z``, )lenappendjoin)aliasesfmtedadashess       r   format_aliasesr)   @   sL    EA!r&!B'(  99Ur   c           
         / nU R                   n[        U R                  SS9R                  5       5       GH  u  pEUR                  R                   nUS-   UR
                  =(       d    S-   nUSU-   S/-  nUR                  R                  5       =(       d    SnUR                  [        [        U5      5      S-   5        SU;   a>  UR                  [        S	S
R                  S UR                   5       5      -   5      5        OUR                  [        SU-   5      5        [        UR                  5      (       aZ   UR                  5       n	U	bF  [#        U	5      S:  a  U	SS S-   n	U	R%                  SS5      n	UR                  [        SU	-  5      5        X   (       a*  ['        X   5      n
UR                  [        SU
-   5      5        UR                  S5        GM     SR                  U5      $ ! [          a    Sn	 Nf = f)zgGenerate rST documentation for this class' config options.

Excludes traits defined on parent classes.
T)config. z.. configtrait:: zNo description
Enumz
:options: r!   c              3  ,   #    U  H
  nS U-  v   M     g7f)z``%r``N ).0xs     r   	<genexpr>'class_config_rst_doc.<locals>.<genexpr>[   s     8\|!A|s   z:trait type: N@   =   z...z\nz\\nz:default: ``%s``z:CLI option: )__name__sortedclass_traitsitems	__class__namehelprstripr#   r	   r   r$   valuesr   default_valuedefault_value_repr	Exceptionr"   replacer)   )clstrait_aliaseslines	classname_traitttypefullnamer>   dvrfmt_aliasess              r   class_config_rst_docrO   H   s   
 EI3++4+8>>@A((s?ejj&6B7%0"55zz  "6&6VF4L)D01 U?LLtyy8\u||8\/\ \]^LL% 789 %U%8%899..0 s8b=cr(U*Ckk%1V$6$<=> "()@AKLL+ =>? 	RI BL 99U#  s   ;G..G=<G=c                   [        [        5      nU R                  R                  5        H  u  p#X   R	                  U5        M     U R
                  R                  5        Hx  u  nu  pV[        U5      S:X  d  M  [        [        U5      5      nXW   n[        U5      S:X  d  MB  [        [        U5      5      n	X   SL d  M_  XS-   U	-      R	                  U5        Mz     U$ )zBProduce a mapping of trait names to lists of command line aliases.r   Tr,   )	r   r   r%   r;   r#   flagsr"   nextiter)
r   resaliasrJ   flagcfgrI   rH   cls_cfg	traitnames
             r   reverse_aliasesrZ   x   s    
d
C))+
%  ,
 ))//+hss8q=T#YInG7|q  g/	%-C)34;;DA , Jr   c                   [        U5      n[        U S5       nUR                  US-   5        UR                  S[        U5      -  S-   5        UR                  S5        Ub  UR                  US-   5        UR	                  5        H.  nUR                  [        Xd5      5        UR                  S5        M0     SSS5        g! , (       d  f       g= f)aa  Write a rst file documenting config options for a traitlets application.

Parameters
----------
path : str
    The file to be written
title : str
    The human-readable title of the document
app : traitlets.config.Application
    An instance of the application class to be documented
preamble : str
    Extra text to add just after the title (optional)
wr.   =Nz

)rZ   openwriter"   _classes_inc_parentsrO   )pathtitler   preamblerF   fcs          r   	write_docrf      s     $C(M	dCA		s5z!T)*	GGHv%&))+AGG(:;GGDM , 
s   BC  
C)r   t.Anyreturndict[str, t.Any])r   rg   rh   r   )r%   z	list[str]rh   r   )rE   ztype[HasTraits]rF   ri   rh   r   )r   r   rh   zdict[str, list[str]])N)
ra   r   rb   r   r   r   rc   z
str | Nonerh   None)__doc__
__future__r   typingtcollectionsr   textwrapr   	traitletsr   r   traitlets.config.applicationr   traitlets.utils.textr	   r   r   r)   rO   rZ   rf   r1   r   r   <module>rt      sB   !D #  #  * 4 'E-`(r   