
    lj$                        d 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rddlmZ d	gZ e            \  ZZZd
 e                                D             ZddZddZ G d d	e          ZdS )zKA directive for documenting type aliases and other module-level attributes.    )annotations)TYPE_CHECKING)nodes)	Directive)
StringList)parse_module_attributes)SphinxAliasAttrDocumenterc                J    g | ] }|                                 D ]	}|D ]}|
!S  )values).0module_dictcategory_dict
alias_names       g/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/utils/docbuild/autoaliasattr_directive.py
<listcomp>r      sb       $++--  	#	  	         basestraliassubstitutionreturnc                   g }t          |          }t          |           }dd}d}d}	 |                     ||          }|dk    rnR|dk    s || |d	z
                     r2||z   |k    s || ||z                      r|                    |           ||z   }o|d
d
d         D ]}	| d
|	         |z   | |	|z   d
         z   } | S )a  Auxiliary function for substituting type aliases into a base
    string, when there are overlaps between the aliases themselves.

    Parameters
    ----------
    base
        The string in which the type aliases will be located and
        replaced.
    alias
        The substring to be substituted.
    substitution
        The string which will replace every occurrence of ``alias``.

    Returns
    -------
    str
        The new string after the alias substitution.
    charr   r   boolc                8    |                                   o| dk    S )N_)isalnum)r   s    r   	conditionz smart_replace.<locals>.condition3   s    <<>>!1dck1r   r   T   N)r   r   r   r   )lenfindappend)
r   r   r   occurrences	len_aliaslen_baser    startios
             r   smart_replacer,      s   & KE

I4yyH2 2 2 2 E	AIIeU##77FFiiQU,,F	MX%%4I3F)G)G%q!!!I 2 ? ?BQBx,&a)moo)>>Kr   appr	   Nonec                <    |                      dt                     d S )Nautoaliasattr)add_directiver
   )r-   s    r   setupr2   H   s    o':;;;;;r   c                  &    e Zd ZdZdZdZdZd	dZdS )
r
   a)  Directive which replaces Sphinx's Autosummary for module-level
    attributes: instead, it manually crafts a new "Type Aliases"
    section, where all the module-level attributes which are explicitly
    annotated as :class:`TypeAlias` are considered as such, for their
    use all around the Manim docs.

    These type aliases are separated from the "regular" module-level
    attributes, which get their traditional "Module Attributes"
    section autogenerated with Sphinx's Autosummary under "Type
    Aliases".

    See ``docs/source/_templates/autosummary/module.rst`` to watch
    this directive in action.

    See :func:`~.parse_module_attributes` for more information on how
    the modules are parsed to obtain the :class:`TypeAlias` information
    and separate it from the other attributes.
    r0   r"   Tr   list[nodes.Element]c           
     N   | j         d         }|                    d          }t                              |d           }t                              |d           }t
                              |d           }t          j                    }|t          j        | dg          }||z  }|t          j	        d          z  }|
                                D ]\  }}t          j        |                                                    dd          g          }	||	z  }|r|	t          j        |          z  }	t          j                    }
|	|
z  }	|
                                D ]\  }}|d	         }t          D ]}t          ||d
| d          }t!          d| dddd| dg          }d|v r|d         }t          D ] }|                    d| dd
| d          }!|#|D ] }|                    d| dd| d          }!|                    d          }|                    t!          d |D                                  t          j                    }| j                            |d|           |
|z  }
|t          j        | dg          }||z  }|t          j	        d          z  }|
                                D ]T\  }}t!          d| dddd| dg          }t          j                    }| j                            |d|           ||z  }U|t          j        | dg          }||z  }|t          j	        d          z  }t!          dgd |D                       }t          j                    }| j                            |d|           ||z  }|gS )Nr   zmanim.z.alias)idszType Aliases)text r   
definitionz
:class:`~.`z.. class::  z    .. parsed-literal::z        docz:class:`
c                    g | ]}d | S )    r   )r   lines     r   r   z+AliasAttrDocumenter.run.<locals>.<listcomp>   s    'L'L'L$t'L'L'Lr   z	.typevarsz	TypeVar'sz.datazModule Attributesz.. autosummary::c              3      K   | ]	}d | V  
dS )r?   Nr   )r   attrs     r   	<genexpr>z*AliasAttrDocumenter.run.<locals>.<genexpr>   s(      BBmTmmBBBBBBr   )	argumentsremoveprefixALIAS_DOCS_DICTget	DATA_DICTTYPEVAR_DICTr   	containersectionrubricitemslowerreplacetitle
ALIAS_LISTr,   r   splitextendstatenested_parse)selfmodule_namemodule_alias_dictmodule_attrs_listmodule_typevarscontentmodule_alias_sectioncategory_namer   category_sectioncategory_alias_containerr   
alias_info	alias_defAunparsed	alias_docT	doc_linesalias_containermodule_typevars_sectionnamer9   typevar_containermodule_attrs_sectiondata_containers                             r   runzAliasAttrDocumenter.rund   s   nQ'!..x88+//TBB%MM+t<<&**;==/## (#(=6L6L6L5M#N#N#N ++G !ELn$E$E$EE  1B0G0G0I0I <@ <@,}#(=&,,..66sC@@A$ $ $  %(88$  H$(G(G(GG$+0?+<+<( $<<  /<.A.A.C.C ,@ ,@*J
 !+< 8I' S S$1)Q@QQ@Q@Q@Q$R$R		
  *6*6652y22	  	 H 
** %/u$5	!+ W WA(1(9(9(a(((DUQRDUDUDU(V(VII +6%4 Y Y,5,=,=h!hhhST,X,X		 %.OOD$9$9	 &'L'L)'L'L'LMM   ',o&7&7OJ++HaIII,?,,Y,@^ &&+mK9R9R9R8S&T&T&T#..G $u|'E'E'EE# %4$9$9$;$; = = j &,d,,1/://	 	 %*O$5$5!
''!5FGGG'+<<'' (#(=6K6K6K5L#M#M#M ++G !EL6I$J$J$JJ  "&BB0ABBB H #_..NJ##Ha@@@ N2 yr   N)r   r4   )__name__
__module____qualname____doc__objtyperequired_argumentshas_contentrm   r   r   r   r
   r
   L   sJ         & GKH H H H H Hr   N)r   r   r   r   r   r   r   r   )r-   r	   r   r.   )rq   
__future__r   typingr   docutilsr   docutils.parsers.rstr   docutils.statemachiner   #manim.utils.docbuild.module_parsingr   sphinx.applicationr	   __all__rF   rH   rI   r   rQ   r,   r2   r
   r   r   r   <module>r}      sB   Q Q " " " " " "                   * * * * * * , , , , , , G G G G G G *)))))) 
! ,C+B+D+D (L &--//  
) ) ) )X< < < <` ` ` ` `) ` ` ` ` `r   