HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/sphinx/ext/__pycache__/inheritance_diagram.cpython-310.pyc
o

�$�a!C�@sdZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZmZddl
mZddlmZddlmZddlZddlmZdd	lmZdd
lmZddlmZmZmZmZmZddlm Z dd
l!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*e�+dej,�Z-dd�e.e��/�D�Z0de1defdd�Z2de1de1defdd�Z3Gdd�de4�Z5Gdd �d �Z6Gd!d"�d"e�Z7Gd#d$�d$e"�Z8d%e7de1fd&d'�Z9d(e&d%e7ddfd)d*�Z:d(e(d%e7ddfd+d,�Z;d(e*d%e7ddfd-d.�Z<d(ej=d%e7ddfd/d0�Z>d1edee1effd2d3�Z?dS)4a[
    sphinx.ext.inheritance_diagram
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Defines a docutils directive for inserting inheritance diagrams.

    Provide the directive with one or more classes or modules (separated
    by whitespace).  For modules, all of the classes in that module will
    be used.

    Example::

       Given the following classes:

       class A: pass
       class B(A): pass
       class C(A): pass
       class D(B, C): pass
       class E(B): pass

       .. inheritance-diagram: D E

       Produces a graph like the following:

                   A
                  / \
                 B   C
                / \ /
               E   D

    The graph is inserted as a PNG+image map into HTML and a PDF in
    LaTeX.

    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�
import_module)�Any�Dict�Iterable�List�Tuple�cast)�nodes)�Node)�
directives)�addnodes)�Sphinx)�BuildEnvironment)�figure_wrapper�graphviz�render_dot_html�render_dot_latex�render_dot_texinfo)�md5)�SphinxDirective)�
OptionSpec)�HTMLTranslator)�LaTeXTranslator)�TexinfoTranslatorz�^(?:([\w.]*)\.)?  # module names
                           (\w+)  \s* $          # class/final module name
                           cCsg|]	}t�|�r|�qS�)�inspect�isclass)�.0�objrr�@/usr/lib/python3/dist-packages/sphinx/ext/inheritance_diagram.py�
<listcomp>Bs
�r �objname�returncCs�zt|�WStyYdStyEt�|�}|sYdS|��\}}|dur,YdSz
t|�}t||d�WYStyDYYdSww)z�Import a object or module using *name* and *currentmodule*.
    *name* should be a relative name from *currentmodule* or
    a fully-qualified name.

    Returns imported object or module.  If failed, returns None value.
    N)r�	TypeError�ImportError�
module_sig_re�match�groups�getattr)r!�matched�modname�attrname�modulerrr�
try_importFs$

��r-�name�
currmodulecCs�d}|rt|d|�}|durt|�}|durtd|��t�|�r&|gSt�|�rGg}|j��D]}t�|�rD|j|jkrD|�	|�q2|Std|��)z0Import a class using its fully-qualified *name*.N�.zECould not import class or module %r specified for inheritance diagramz=%r specified for inheritance diagram is not a class or module)
r-�InheritanceExceptionrr�ismodule�__dict__�values�
__module__�__name__�append)r.r/�target�classes�clsrrr�import_classescs.��


��r;c@seZdZdS)r1N)r6r5�__qualname__rrrrr1�sr1c@sreZdZdZddddgfdeedededed	ed
eeefdee	ddfd
d�Z
deededee	fdd�Zdee	deded	ed
eeefdee	deeeeeeeffdd�Z
d4de	d	ed
eeefdefdd�Zdeefdd�Zdddd�Zdddd d!d"d#�Zd$d%d&�Zd'edefd(d)�Zd'edefd*d+�Zidiiifd,ed-ed.ed/ed0ed1edefd2d3�ZdS)5�InheritanceGraphz�
    Given a list of classes, determines the set of classes that they inherit
    from all the way to the root "object", and then is able to generate a
    graphviz dot graph from them.
    FrN�class_namesr/�
show_builtins�
private_bases�parts�aliases�top_classesr"c	Cs:||_|�||�}|�||||||�|_|jstd��dS)z�*class_names* is a list of child classes to show bases from.

        If *show_builtins* is True, then Python builtins will be shown
        in the graph.
        z(No classes found for inheritance diagramN)r>�_import_classes�_class_info�
class_infor1)	�selfr>r/r?r@rArBrCr9rrr�__init__�s��zInheritanceGraph.__init__cCs"g}|D]
}|�t||��q|S)zImport a list of classes.)�extendr;)rGr>r/r9r.rrrrD�sz InheritanceGraph._import_classesr9c	sFi�dtddf��������fdd��|D]}�|�qt����S)a�Return name and bases for all classes that are ancestors of
        *classes*.

        *parts* gives the number of dotted name parts to include in the
        displayed node names, from right to left. If given as a negative, the
        number of parts to drop from the left. A value of 0 displays the full
        dotted name. E.g. ``sphinx.ext.inheritance_diagram.InheritanceGraph``
        with ``parts=2`` or ``parts=-2`` gets displayed as
        ``inheritance_diagram.InheritanceGraph``, and as
        ``ext.inheritance_diagram.InheritanceGraph`` with ``parts=3`` or
        ``parts=-1``.

        *top_classes* gives the name(s) of the top most ancestor class to
        traverse to. Multiple names can be specified separated by comma.
        r:r"Ncs��s|tvrdS�s|j�d�rdS��|���}��|d��}d}z|jr:|j���d�d}|r:d|�dd�}Wn	tyDYnwg}||||f�|<|�vrUdS|j	D]$}�sa|tvraqX�sj|j�d�rjqX|�
��|����|�vr|�|�qXdS)N�_r�
�"%s"�"z\")�py_builtinsr6�
startswith�
class_name�__doc__�strip�split�replace�	Exception�	__bases__r7)r:�nodename�fullname�tooltip�doc�baselist�base�rB�all_classesrAr@�recurserGr?rCrrr_�s<��
��z-InheritanceGraph._class_info.<locals>.recurse)r�listr4)rGr9r?r@rArBrCr:rr]rrE�s
$"
zInheritanceGraph._class_infor:cCsl|j}|dvr|j}nd||jf}|dkr|}n|�d�}d�||d��}|dur4||vr4||S|S)z�Given a class object, return a fully-qualified name.

        This works for things I've tested in matplotlib so far, but may not be
        completely general.
        )�__builtin__�builtinsz%s.%srr0N)r5r6r<rS�join)rGr:rArBr,rX�result�
name_partsrrrrP�s
zInheritanceGraph.class_namecCsdd�|jD�S)z1Get all of the class names involved in the graph.cSsg|]\}}}}|�qSrr)rrJrXrrrr �sz8InheritanceGraph.get_all_class_names.<locals>.<listcomp>)rF)rGrrr�get_all_class_names�sz$InheritanceGraph.get_all_class_names�LRz"8.0, 12.0"�transparent)�rankdir�size�bgcolor�box�
g�?zA"Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans"z"setlinewidth(0.5),filled"�white)�shape�fontsize�height�fontname�style�	fillcolorg�?z"setlinewidth(0.5)")�	arrowsizers�attrscC�d�dd�t|���D��S)N�,cS�g|]}d|�qS)z%s=%sr�r�xrrrr �z7InheritanceGraph._format_node_attrs.<locals>.<listcomp>�rc�sorted�items�rGrvrrr�_format_node_attrs
�z#InheritanceGraph._format_node_attrscCrw)N�cSry)z%s=%s;
rrzrrrr r|z8InheritanceGraph._format_graph_attrs.<locals>.<listcomp>r}r�rrr�_format_graph_attrs
r�z$InheritanceGraph._format_graph_attrsr.�urls�env�graph_attrs�
node_attrs�
edge_attrsc
Cs(|j��}|j��}|j��}	|�|�|�|�|	�|�|r5|�|jj�|�|jj�|	�|jj�g}
|
�	d|�|
�	|�
|��t|j�D]>\}}}}
|��}||vred|||d<d|d<|
rk|
|d<|
�	d||�
|�f�|D]}|
�	d|||�
|	�f�qyqK|
�	d	�d
�|
�S)aVGenerate a graphviz dot graph from the classes that were passed in
        to __init__.

        *name* is the name of the graph.

        *urls* is a dictionary mapping class names to HTTP URLs.

        *graph_attrs*, *node_attrs*, *edge_attrs* are dictionaries containing
        key/value pairs to pass on as graphviz properties.
        z
digraph %s {
rL�URLz"_top"r8rYz
  "%s" [%s];
z  "%s" -> "%s" [%s];
z}
r�)�default_graph_attrs�copy�default_node_attrs�default_edge_attrs�update�config�inheritance_graph_attrs�inheritance_node_attrs�inheritance_edge_attrsr7r�r~rFr�rc)rGr.r�r�r�r�r��g_attrs�n_attrs�e_attrs�resrX�basesrY�this_node_attrs�	base_namerrr�generate_dots@





����

zInheritanceGraph.generate_dot)rN)r6r5r<rQr�str�bool�intrrrHrDrrErPrfr�r�r�r�r�rr�rrrrr=�sn���
��
��
��
�$;��
������r=c@seZdZdZdS)�inheritance_diagramzN
    A docutils node to use as a placeholder for the inheritance diagram.
    N)r6r5r<rQrrrrr�@sr�c@sPeZdZUdZdZdZdZdZee	j
e	je	jd�Z
eed<deefd	d
�ZdS)�InheritanceDiagramzJ
    Run when the inheritance_diagram directive is first encountered.
    F�rT)rA�
private-bases�caption�top-classes�option_specr"c
Csrt�}|jj|_|jd��}|j�d��d�}|j�	dd�|d<d�
|�|d<g|d<|j�	dd��d	�D]}|��}|rE|d�|�q6zt
||jj�	d
�|dd|jv|jj|dd�}Wnty}}z|jjj||jd
�gWYd}~Sd}~ww|��D]}|dd||d|j�\}}	|�|�q�||d<d|jvr�|�|�|gSt|||jd�}
|�|
�|
gS)Nr�py�classrAz, �contentr�r�rxz	py:moduler�)rAr@rBrC)�linez:class:`%s`�graphr�)r��state�document�	argumentsrSr��
get_domain�role�options�getrcrRr7r=�ref_contextr��inheritance_aliasr1�reporter�warning�linenorfrI�add_namer)rG�noder>�
class_roler:r��errr.�refnodesr{�figurerrr�runVsH
�
�"���


zInheritanceDiagram.runN)r6r5r<rQ�has_content�required_arguments�optional_arguments�final_argument_whitespacer�r�flag�	unchanged�unchanged_requiredr�r�__annotations__rr
r�rrrrr�Gs
�r�r�cCs,|dt|d���}t|���dd�S)Nr�rAi����)r��encoder�	hexdigest)r��encodedrrr�get_graph_hash�sr�rGc
Cs|d}t|�}d|}|jjjj��}|jj|jj}i}tt	t
j|�}|D]I}	|	�d�durK|dkrAd|	�d�||	d<q(|	�d�||	d<q(|	�d�durq|dkrfd|d	|	�d�||	d<q(d	|	�d�||	d<q(|j
|||jjd
�}
t|||
iddd|d
d�tj�)zZ
    Output the graph for HTML.  This will insert a PNG with clickable
    image map.
    r��
inheritance%s�refuriN�SVGz../�reftitle�refid�#)r��inheritancezInheritance diagram of r�)�alt)r��builderr�r��graphviz_output_format�upper�current_docname�
out_suffixrrr�pending_xrefr�r�rr	�SkipNode)rGr�r��
graph_hashr.r��current_filenamer��
pending_xrefs�child�dotcoderrr�html_visit_inheritance_diagram�s, �
�r�cC�F|d}t|�}d|}|j||jjddid�}t|||id�tj�)z>
    Output the graph for LaTeX.  This will insert a PDF.
    r�r�rj�	"6.0,6.0"�r�r�r�)r�r�r�r�rr	r��rGr�r�r�r.r�rrr�latex_visit_inheritance_diagram�s�r�cCr�)z@
    Output the graph for Texinfo.  This will insert a PNG.
    r�r�rjr�r�r�)r�r�r�r�rr	r�r�rrr�!texinfo_visit_inheritance_diagram�s�r�cCstj�)N)r	r�)rGr�rrr�skip�sr��appcCs�|�d�|jttdftdftdftdftdfd�|�dt�|�	did�|�	did�|�	did�|�	did�t
jd	d
�S)Nzsphinx.ext.graphviz)�latex�html�text�man�texinfozinheritance-diagramr�Fr�r�r�T)�version�parallel_read_safe)�setup_extension�add_noder�r�r�r�r��
add_directiver��add_config_value�sphinx�__display_version__)r�rrr�setup�s
�r�)@rQrbr�re�	importlibr�typingrrrrrr�docutilsr	�docutils.nodesr
�docutils.parsers.rstrr�r�sphinx.applicationr
�sphinx.environmentr�sphinx.ext.graphvizrrrrr�sphinx.utilr�sphinx.util.docutilsr�sphinx.util.typingr�sphinx.writers.htmlr�sphinx.writers.latexr�sphinx.writers.texinfor�compile�VERBOSEr%�varsr4rNr�r-r;rUr1r=r�r�r�r�r�r��NodeVisitorr�r�rrrr�<module>sN% �;=!

�