File: //usr/lib/python3/dist-packages/sphinx/ext/__pycache__/inheritance_diagram.cpython-310.pyc
o
�$�a!C � @ s d Z ddlZddlZddlZddlmZ ddlmZmZm Z m
Z
mZmZ ddl
mZ ddlmZ ddlmZ ddlZddlmZ dd lmZ dd
lmZ ddlmZmZmZmZmZ ddlm 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�Z3G dd� de4�Z5G dd � d �Z6G d!d"� d"e�Z7G d#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>d1edee1ef fd2d3�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
c C s g | ] }t �|�r|�qS � )�inspect�isclass)�.0�objr r �@/usr/lib/python3/dist-packages/sphinx/ext/inheritance_diagram.py�
<listcomp>B s
�r �objname�returnc C s� zt | �W S ty Y dS tyE t�| �}|sY dS |�� \}}|du r,Y dS z
t |�}t||d�W Y S tyD Y Y dS w w )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�moduler r r �
try_importF s$
��r- �name�
currmodulec C s� d}|rt |d | �}|du rt | �}|du rtd| ��t�|�r&|gS t�|�rGg }|j�� D ]}t�|�rD|j|jkrD|� |� q2|S td| ��)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- �InheritanceExceptionr r �ismodule�__dict__�values�
__module__�__name__�append)r. r/ �target�classes�clsr r r �import_classesc s. ��
��r; c @ s e Zd ZdS )r1 N)r6 r5 �__qualname__r r r r r1 � s r1 c @ sr e Zd ZdZddddg fdee dededed ed
eeef dee ddfd
d�Z
dee dedee fdd�Zdee deded ed
eeef dee deeeeee ef fdd�Z
d4de d ed
eeef defdd�Zdee fdd�Zdddd�Zdddd d!d"d#�Zd$d%d&�Zd'edefd(d)�Zd'edefd*d+�Zi di i i fd,ed-ed.ed/ed0ed1edefd2d3�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.
Fr N�class_namesr/ �
show_builtins�
private_bases�parts�aliases�top_classesr"