
    $g                        d Z ddlZddlZddl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mZmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZmZ dd	l m!Z!m"Z"m#Z#m$Z$ dd
l%m&Z& ddl'm(Z( 	 ddlm)Z) n# e*$ r	 ddl)m)Z) Y nw xY w G d d          Z+d de,de-de+fdZ. G d d          Z/de,de,de0de-fdZ1de,dee,ee,         f         fdZ2dddde,deee,ef                  dee0         dee,ef         fdZ3dS )!zThis module is responsible for loading the documentation from Python objects.

It uses [`inspect`](https://docs.python.org/3/library/inspect.html) for introspecting objects,
iterating over their members, etc.
    N)	lru_cache)chain)
attrgetter)Path)
AnyCallableDictListMappingOptionalSequenceSetTupleUnion)	AttributeClassFunctionMethodModuleObjectSource)get_class_attributesget_instance_attributesget_module_attributesmerge)PARSERS)
RE_SPECIAL)cached_propertyc            	          e Zd ZdZddededed          ddfdZedefd            Z	edefd	            Z
edd
            ZdefdZdefdZdefdZdefdZdefdZdefdZdefdZdefdZdefdZdefdZdefdZdS )
ObjectNodea)  Helper class to represent an object tree.

    It's not really a tree but more a backward-linked list:
    each node has a reference to its parent, but not to its child (for simplicity purposes and to avoid bugs).

    Each node stores an object, its name, and a reference to its parent node.
    Nobjnameparentreturnc                     	 t          j        |          }n# t          $ r Y nw xY w|| _        	 || _        	 || _        dS )zInitialize the object.

        Arguments:
            obj: A Python object.
            name: The object's name.
            parent: The object's parent node.
        N)inspectunwrap	Exceptionr!   r"   r#   )selfr!   r"   r#   s       O/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/pytkdocs/loader.py__init__zObjectNode.__init__%   s]    	.%%CC 	 	 	
 D	 '	',2s    
$$c                     | j         g}| j        }|r#|                    |j                    |j        }|#d                    t	          |                    S )zyReturn the Python dotted path to the object.

        Returns:
            The Python dotted path to the object.
        .)r"   r#   appendjoinreversed)r)   partscurrents      r*   dotted_pathzObjectNode.dotted_path?   s[     + 	%LL&&&nG  	% xx(((    c                 >    t          j        | j        j                  S )zkReturn the object's module file path.

        Returns:
            The object's module file path.
        )r&   
getabsfilerootr!   r)   s    r*   	file_pathzObjectNode.file_pathM   s     !$)-000r4   c                 ,    | j         | j         j        S | S )zYReturn the root of the tree.

        Returns:
            The root of the tree.
        )r#   r7   r8   s    r*   r7   zObjectNode.rootV   s     ;";##r4   c                 4    t          j        | j                  S )zdTell if this node's object is a module.

        Returns:
            The root of the tree.
        )r&   ismoduler!   r8   s    r*   	is_modulezObjectNode.is_modulea   s     )))r4   c                 4    t          j        | j                  S )zoTell if this node's object is a class.

        Returns:
            If this node's object is a class.
        )r&   isclassr!   r8   s    r*   is_classzObjectNode.is_classi   s     tx(((r4   c                 4    t          j        | j                  S )zuTell if this node's object is a function.

        Returns:
            If this node's object is a function.
        )r&   
isfunctionr!   r8   s    r*   is_functionzObjectNode.is_functionq   s     !$(+++r4   c                 4    t          j        | j                  S )zwTell if this node's object is a coroutine.

        Returns:
            If this node's object is a coroutine.
        )r&   iscoroutinefunctionr!   r8   s    r*   is_coroutine_functionz ObjectNode.is_coroutine_functiony   s     *48444r4   c                 ^    t          | j        t                    p|                                 S )zuTell if this node's object is a property.

        Returns:
            If this node's object is a property.
        )
isinstancer!   propertyis_cached_propertyr8   s    r*   is_propertyzObjectNode.is_property   s'     $(H--J1H1H1J1JJr4   c                 6    t          | j        t                    S )zTell if this node's object is a cached property.

        Returns:
            If this node's object is a cached property.
        )rH   r!   r   r8   s    r*   rJ   zObjectNode.is_cached_property   s     $(O444r4   c                 \    t          | j        o| j                                                  S )zTell if the object of this node's parent is a class.

        Returns:
            If the object of this node's parent is a class.
        )boolr#   r@   r8   s    r*   parent_is_classzObjectNode.parent_is_class   s'     DK:DK$8$8$:$:;;;r4   c                 t    t          d           }|                                 ot          | j        |          S )zqTell if this node's object is a method.

        Returns:
            If this node's object is a method.
        c                      d S N rS   r4   r*   <lambda>z&ObjectNode.is_method.<locals>.<lambda>   s    T r4   )typerO   rH   r!   )r)   function_types     r*   	is_methodzObjectNode.is_method   s6     \\**##%%M*TX}*M*MMr4   c                 4    t          j        | j                  S )a  Tell if this node's object is a method descriptor.

        Built-in methods (e.g. those implemented in C/Rust) are often
        method descriptors, rather than normal methods.

        Returns:
            If this node's object is a method descriptor.
        )r&   ismethoddescriptorr!   r8   s    r*   is_method_descriptorzObjectNode.is_method_descriptor   s     )$(333r4   c                     | j         sdS | j         j        j                            | j        d          }|                                 ot          |t                    S )z}Tell if this node's object is a staticmethod.

        Returns:
            If this node's object is a staticmethod.
        FN)r#   r!   __dict__getr"   rO   rH   staticmethodr)   self_from_parents     r*   is_staticmethodzObjectNode.is_staticmethod   sT     { 	5;?377	4HH##%%T*5E|*T*TTr4   c                     | j         sdS | j         j        j                            | j        d          }|                                 ot          |t                    S )z{Tell if this node's object is a classmethod.

        Returns:
            If this node's object is a classmethod.
        FN)r#   r!   r\   r]   r"   rO   rH   classmethodr_   s     r*   is_classmethodzObjectNode.is_classmethod   sT     { 	5;?377	4HH##%%S*5E{*S*SSr4   rR   )r$   r    )__name__
__module____qualname____doc__r   strr   r+   rI   r3   r9   r7   rN   r=   r@   rC   rF   rK   rJ   rO   rW   rZ   ra   rd   rS   r4   r*   r    r       s         C s H\4J VZ    4 )S ) ) ) X) 13 1 1 1 X1    X*4 * * * *)$ ) ) ) ),T , , , ,5t 5 5 5 5KT K K K K5D 5 5 5 5< < < < <N4 N N N N	4d 	4 	4 	4 	4	U 	U 	U 	U 	U	T 	T 	T 	T 	T 	T 	Tr4   r    Fpathnew_path_syntaxr$   c                    | st          d|            g }d| v s|rX	 |                     d          \  }}|                    d          }n# t           $ r | g }}Y nw xY wt          j        |          }n|                     d          }	 d                    |          }	 t          j        |          }nh# t
          $ rZ}t          |          dk    rt          d|  d          ||                    d|                    d	                     Y d
}~nd
}~ww xY wt          ||j
                  }	|D ]+}
t          |	j        |
          }t          ||
|	          }|}	,|	}d
}|	j        r|t          j        |	j                  }t          j        |	j        j                  r+|(||	j        j        urt          ||j
                  |	_        n|	j        }	|	j        r|S )a	  Transform a path into an actual Python object.

    The path can be arbitrary long. You can pass the path to a package,
    a module, a class, a function or a global variable, as deep as you
    want, as long as the deepest module is importable through
    `importlib.import_module` and each object is obtainable through
    the `getattr` method. It is not possible to load local objects.

    Args:
        path: The dot/colon-separated path of the object.
        new_path_syntax: Whether to use the "colon" syntax for the path.

    Raises:
        ValueError: When the path is not valid (evaluates to `False`).
        ImportError: When the object or its parent module could not be imported.

    Returns:
        The leaf node representing the object and its parents.
    z&path must be a valid Python path, not :r-   T   zImporting 'zn' failed, possible causes are:
- an exception happened while importing
- an element in the path does not existr   Nr#   )
ValueErrorsplit	importlibimport_moduler/   ImportErrorleninsertpopr    re   getattrr!   r#   r&   	getmoduler<   )rj   rk   objectsmodule_pathobject_pathparent_moduleobj_parent_modulesparent_module_patherrorcurrent_nodeobj_namer!   childleafreal_modules                  r*   get_object_treer      sg   (  JH$HHIIIG
d{{o{	-'+zz#$K "'',,GG  	, 	, 	,#'KKK	, "/<< "ZZ__	!$*<!=!= ) 78J K K   > > >)**a//%Cd C C C  !	!
 q"4"8"8"<"<========>		$ m]-CDDL  l&113>>>D K


)!+L,<==KL/344 	&;l>Q>U+U+U&0k>R&S&S##* 

) Ks*   A AA!B6 6
D ADDc                   Z   e Zd ZdZ	 	 	 	 	 d/deee                  dedee         ded	ed
dfdZ	d0dedee
ee         ef                  d
efdZ	 d0dedee
ee         ef                  d
efdZeded
efd            Z	 d0dedee
ee         ef                  d
efdZdedee         ded
efdZdedededeeef         dee
ee         ef                  deded
dfdZded
efdZded
efdZeded
efd            Z eded
efd             Z!eded
efd!            Z"ed0ded"ee         d
efd#            Z#ded
e$fd$Z%ded
e$fd%Z&ded
e$fd&Z'd0ded'eee                  d
e$fd(Z(ed0ded"ee         d
efd)            Z)d*ed+ee         d
efd,Z* e+d-          d*ed
efd.            Z,dS )1LoaderzThis class contains the object documentation loading mechanisms.

    Any error that occurred during collection of the objects and their documentation is stored in the `errors` list.
    NgoogleFfiltersdocstring_styledocstring_optionsinherited_membersrk   r$   c                     |sg }d |D             | _         t          |         di |pi | _        g | _        || _        || _        dS )a  Initialize the object.

        Arguments:
            filters: A list of regular expressions to fine-grain select members. It is applied recursively.
            docstring_style: The style to use when parsing docstrings.
            docstring_options: The options to pass to the docstrings parser.
            inherited_members: Whether to select inherited members for classes.
            new_path_syntax: Whether to use the "colon" syntax for the path.
        c                 `    g | ]+}|t          j        |                    d                     f,S )!)recompilelstrip).0filtrs     r*   
<listcomp>z#Loader.__init__.<locals>.<listcomp>8  s3    TTT5
5<<+<+< = =>TTTr4   NrS   )r   r   docstring_parsererrorsselect_inherited_membersrk   )r)   r   r   r   r   rk   s         r*   r+   zLoader.__init__$  se    "  	GTTGTTT ' 8 U U<M<SQS U U!#(9%.r4   r3   membersc                 ,   |du rt                      }t          || j                  }|                                r|                     ||          }n&|                                r|                     ||          }n|                                r|                     |          }n|	                                r| 
                    |          }n|                                s|                                r|                     |          }ni|                                r|                     |          }n?|                                r|                     |          }n|                     |          }|                    | j                   |S )a  Get the documentation for an object and its children.

        Arguments:
            dotted_path: The Python dotted path to the desired object.
            members: `True` to select members and filter them, `False` to select no members,
                or a list of names to explicitly select the members with these names.
                It is applied only on the root object.

        Returns:
            The documented object.
        T)setr   rk   r=   get_module_documentationr@   get_class_documentationra   get_staticmethod_documentationrd   get_classmethod_documentationrZ   rW    get_regular_method_documentationrC   get_function_documentationrK   get_property_documentationget_attribute_documentationparse_all_docstringsr   )r)   r3   r   r   root_objects        r*   get_object_documentationzLoader.get_object_documentation>  s    d??eeG {D,@AA>> 	A77gFFKK]]__ 	A66tWEEKK!!## 	A==dCCKK  "" 		A<<TBBKK&&(( 	ADNN,<,< 	A??EEKK 	A99$??KK 	A99$??KK::4@@K(()>???r4   nodeselect_membersc                    |j         }|j        }|                    d          d         }	 t          t	          j        |          d          }ne# t          $ rX 	 t          |j                  	                                }|rt          |d          nd}n# t          t          f$ r d}Y nw xY wY nw xY wt          |||j        t	          j        |          |          }|du r|S |pt                      }t          |          }	|                    | j        |	           t	          j        |          D ]&\  }
}|                     |
|          r	t'          ||
|          }|                                rN|j        j         t	          j        |j                   u r)|                    |                     |                     |                                rN|j        j         t	          j        |j                   u r)|                    |                     |                     |
|	v r/|                    |                     ||	|
                              (t9          |d	          rrt;          j        |j                  D ]X\  }}}|                     ||          r<tA          | d|           }|                    | !                    |                     Y|S )
a	  Get the documentation for a module and its children.

        Arguments:
            node: The node representing the module and its parents.
            select_members: Explicit members to select.

        Returns:
            The documented module object.
        r-   ro   rn   N)r"   rj   r9   	docstringsourceF)
attributesrp   __path__)"r!   r3   rr   r   r&   	getsourceOSErrorr   r9   	read_textUnicodeDecodeErrorr   getdocr   r   parse_docstringr   
getmembersselectr    r@   r7   rz   	add_childr   rC   r   r   hasattrpkgutiliter_modulesr   r   r   )r)   r   r   modulerj   r"   r   coder   attributes_datamember_namemember
child_node_modnamer   s                   r*   r   zLoader.get_module_documentatione  s	    zz#r"	;G-f55q99FF 	; 	; 	;;DN++5577 -1:ad /0   	; nnV,,
 
 
 U""'0355/77##D$9o#VVV#*#5f#=#= 	v 	vK{{;77 v'DIII
&&(( vTY]g>OPZP^>_>_-_-_))$*F*Fz*R*RSSSS++-- v$)-7CTU_UcCdCd2d2d))$*I*I**U*UVVVV O33))$*J*J:WfgrWs*t*tuuu6:&& 	O!(!5fo!F!F O O7A;;w77 O*d+>+>W+>+>??D))$*G*G*M*MNNNs5   "A 
B0&B?B0B*'B0)B**B0/B0clsc                 <    | j         }| j        }|dk    r|S | d| S )Nbuiltinsr-   )rf   rg   )r   modqnames      r*   _class_pathzLoader._class_path  s5    n *Lr4   c           
          |j         }t          j        |j        pd          } fd|j        D             }	 t          t          j        |j                    }n# t          t          f$ r d}Y nw xY wt          |j
        |j        |j        |||          }i }t          |j        dd                   D ]}	t          |t!          |	                      d|i}
d|j        v r\	 |                    t'          |j                             t          j        |j                  |
d<   n# t          t,          f$ r Y nw xY w |j         j        fi |
 |d	u r|S |pt3                      }i }t3                      }|j        }t5          t          j        |                    }|                                D ]]\  }}||u r
|t:          u sJ|t<          u sA                     ||          r+||vr" j         r|||<   |!                    |           X|||<   ^|                                D ]@\  }}tE          |||
          }|#                                r $                    |          }n|%                                r &                    |          }n|'                                r (                    |          }nw|)                                r *                    |          }nM|+                                r ,                    |          }n#||v r -                    |||                   }n||v r|j.        /                    d           |0                    |           Bddg j1        fddg j2        fddg j3        fddg j4        ffD ]T\  }}} 5                    |||          r7|j.        6                    |            7                    |||||||            nU|S )a  Get the documentation for a class and its children.

        Arguments:
            node: The node representing the class and its parents.
            select_members: Explicit members to select.

        Returns:
            The documented class object.
         c                 :    g | ]}                     |          S rS   )r   )r   br)   s     r*   r   z2Loader.get_class_documentation.<locals>.<listcomp>  s'    ???!!!$$???r4   N)r"   rj   r9   r   basesr   ro   r   r+   	signatureFrp   	inherited
__fields__zpydantic-model_declared_fieldszmarshmallow-modelz_meta.get_fieldszdjango-model__dataclass_fields__	dataclass)8r!   r&   cleandocrh   	__bases__r   getsourcelinesr   	TypeErrorr   r"   r3   r9   r0   __mro__r   r   r\   updater   r+   r   rq   r   r   r   dictr   itemsrU   objectr   r   addr    r@   r   rd   r   ra   r   rW   r   rK   r   r   
propertiesr.   r    get_pydantic_field_documentation#get_marshmallow_field_documentationget_django_field_documentationget_annotated_dataclass_fielddetect_field_modelextend
add_fields)r)   r   r   class_r   r   r   r   r   parent_classcontextr   r   direct_membersall_membersr   r   r   r   	attr_namer   
add_methods   `                     r*   r   zLoader.get_class_documentation  s    $V^%9r::	????f.>???	W3DH==>FF# 	 	 	FFF	 !n
 
 
 68$V^CRC%899 	G 	GL/#7#E#EFFFF#/"A((&&'>v'O'OPPP'.'8'I'I$$z*   ##D$9EEWEEEU""'0355 EE	7-f5566#.#4#4#6#6 		2 		2KdNNf&6&6DKKUc<d<d&6n444 3/5,!k222+1GK( $+==?? 	) 	)K#FKEEEJ""$$ 44Z@@**,, :::FF++-- 	;;JGG%%'' ==jII'')) 77
CC//88_U`Eabbi'' ''444!!%(((( ,-t/TU"5!68`a.!143VW#k]D4VW	2
 	 	-Iz: &&y.+NN &--j999"    s$    A A/.A/"AD& &D:9D:r   r   r   c                     t          |          \  }}||v s| j        r||v sdS |r  t          |          ||                   sdS dS )aH  Detect if an attribute is present in members.

        Arguments:
            attr_name: The name of the attribute to detect, can contain dots.
            direct_members: The direct members of the class.
            all_members: All members of the class.

        Returns:
            Whether the attribute is present.
        FT)split_attr_namer   r   )r)   r   r   r   first_order_attr_name	remainders         r*   r   zLoader.detect_field_model  so     ,;9+E+E(y!^33- 42G;2V2V5 	2Z	22;?T3UVV 	5tr4   r   
base_classr   c                     t          ||          }|                                D ]g\  }	}
|                     |	|          }t          |	||          }|r9| j        s|s0t          |
|	|          }|                     ||                     hdS )a  Add detected fields to the current object.

        Arguments:
            node: The current object node.
            root_object: The current object.
            attr_name: The fields attribute name.
            members: The members to pick the fields attribute in.
            select_members: The members to select.
            base_class: The class declaring the fields.
            add_method: The method to add the children object.
        )r   )r!   r"   r#   N)
get_fieldsr   r   field_is_inheritedr   r    r   )r)   r   r   r   r   r   r   r   fields
field_namefieldselect_fieldis_inheritedr   s                 r*   r   zLoader.add_fields1  s    * Iw777!' 	> 	>J;;z>BBL-j)ZPPL >!> >l >'E
4PPP
%%jj&<&<===	> 	>r4   c           	         |j         }	 t          j        |          }n# t          $ r d}Y nw xY w	 t	          t          j        |           }n# t          $ r d}Y nw xY wg }|                                r|                    d           t          |j
        |j        |j        t          j        |          |||          S )zGet the documentation for a function.

        Arguments:
            node: The node representing the function and its parents.

        Returns:
            The documented function object.
        Nasync)r"   rj   r9   r   r   r   r   )r!   r&   r   r   r   r   r   rF   r.   r   r"   r3   r9   r   )r)   r   functionr   r   r   s         r*   r   z!Loader.get_function_documentationP  s     8	)(33II 	 	 	III		W3H==>FF 	 	 	FFF	 !#
%%'' 	'g&&&!nnX..!
 
 
 	
s    --A AAc           	         |j         }|j        }dg}|                                r|                    ddg           |j        }n%|                    |j        dnd           |j        }	 t          j	        |          }|j
        }n# t          t          f$ r d}Y nw xY w	 t          t          j        |           }n# t          t          f$ r d}Y nw xY wt!          |j        ||j        t          j        |          |||          S )zGet the documentation for a property.

        Arguments:
            node: The node representing the property and its parents.

        Returns:
            The documented attribute object (properties are considered attributes for now).
        rI   writablecachedNreadonly)r"   rj   r9   r   	attr_typer   r   )r!   r3   rJ   r   funcr.   fsetfgetr&   r   return_annotationr   rq   r   r   r   r   r"   r9   r   )	r)   r   proprj   r   sig_source_funcr   r  r   s	            r*   r   z!Loader.get_property_documentationu  sC    x \
""$$ 	(z84555"iOODI,=jj:NNN"iO	4)/::I "3II :& 	 	 	III	
	W3ODDEFF# 	 	 	FFF	 nnT**!
 
 
 	
s$   +B BB!B= =CCc                     | j         }| j        }dg}|j        r|                    d           t	          | j        || j        |j        j        |j	        |          S )zGet the documentation for a Pydantic Field.

        Arguments:
            node: The node representing the Field and its parents.

        Returns:
            The documented attribute object.
        zpydantic-fieldrequiredr"   rj   r9   r   r  r   )
r!   r3   r
  r.   r   r"   r9   
field_infodescriptionouter_type_r   r  rj   r   s       r*   r   z'Loader.get_pydantic_field_documentation  sn     x&'
= 	*j)))no1&!
 
 
 	
r4   c                 4   | j         }| j        }dg}|j        r|                    d           |j        r|                    d           |j        r|j         d|j         nt          |j                  }t          | j	        || j
        ||j        |          S )zGet the documentation for a Django Field.

        Arguments:
            node: The node representing the Field and its parents.

        Returns:
            The documented attribute object.
        zdjango-fieldnullableblankz: r  )r!   r3   nullr.   r  	help_textverbose_nameri   r   r"   r9   	__class__)r   r  rj   r   r   s        r*   r   z%Loader.get_django_field_documentation  s     x$%
9 	*j))): 	'g&&&
 AEjt(<<DN<<<TWX\XiTjTj	nn!
 
 
 	
r4   c           	          | j         }| j        }dg}|j        r|                    d           t	          | j        || j        |j                            d          t          |          |          S )zGet the documentation for a Marshmallow Field.

        Arguments:
            node: The node representing the Field and its parents.

        Returns:
            The documented attribute object.
        zmarshmallow-fieldr
  r  r  )
r!   r3   r
  r.   r   r"   r9   metadatar]   rU   r  s       r*   r   z*Loader.get_marshmallow_field_documentation  s|     x)*
= 	*j)))nm''664jj!
 
 
 	
r4   attribute_datac                 Z   |y|                                  r3t          | j        j                                      | j        i           }n2t          | j        j                                      | j        i           }t          | j        | j	        | j
        |d         |d         dg          S )a  Get the documentation for a dataclass field.

        Arguments:
            node: The node representing the annotation and its parents.
            attribute_data: Docstring and annotation for this attribute.

        Returns:
            The documented attribute object.
        Nr   
annotationzdataclass-fieldr  rO   r   r#   r!   r]   r"   r   r7   r   r3   r9   r   r  s     r*   r   z$Loader.get_annotated_dataclass_field  s     !##%% Y!5dko!F!F!J!J49VX!Y!Y!6ty}!E!E!I!I$)UW!X!X!n$[1$\2)*
 
 
 	
r4   c                 0    |                      |dg          S )zGet the documentation for a class-method.

        Arguments:
            node: The node representing the class-method and its parents.

        Returns:
            The documented method object.
        rc   get_method_documentationr)   r   s     r*   r   z$Loader.get_classmethod_documentation  s     ,,TM?CCCr4   c                 0    |                      |dg          S )zGet the documentation for a static-method.

        Arguments:
            node: The node representing the static-method and its parents.

        Returns:
            The documented method object.
        r^   r  r!  s     r*   r   z%Loader.get_staticmethod_documentation  s     ,,TN3CDDDr4   c                 J   |                      |          }|j        r|j        j        }t          j        |j                  ra|j        }|j        dd         }|D ]H}	 t          ||j                  }|t          j
        |          k    rd|_         n# t          $ r Y Ew xY w|S )as  Get the documentation for a regular method (not class- nor static-method).

        We do extra processing in this method to discard docstrings of `__init__` methods
        that were inherited from parent classes.

        Arguments:
            node: The node representing the method and its parents.

        Returns:
            The documented method object.
        rn   Nr   )r   r#   r!   r   matchr"   r   r   ry   r&   r   AttributeError)r)   r   methodr   r   parent_classesr   parent_methods           r*   r   z'Loader.get_regular_method_documentation$  s     ..t44; 	[_F	** ",	!'!3$2  L(/di(H(H %}(E(EEE/1F, * ! ! ! ! s   B
B B r   c           	         |j         }|j        }	 t          t          j        |           }n# t
          $ r d}Y nt          $ r d}Y nw xY w|                                r|dg}n|                    d           	 t          j	        |          }n# t          $ r d}Y nw xY wt          |j        ||j        t          j        |          ||pg |          S )a  Get the documentation for a method or method descriptor.

        Arguments:
            node: The node representing the method and its parents.
            properties: A list of properties to apply to the method.

        Returns:
            The documented method object.
        Nr   )r"   rj   r9   r   r   r   r   )r!   r3   r   r&   r   r   r   rF   r.   r   rq   r   r"   r9   r   )r)   r   r   r&  rj   r   r   s          r*   r   zLoader.get_method_documentationA  s%    	W3F;;<FF 	 	 	FFF 	 	 	FFF	 %%'' 	+!%Y

!!'***	  )&11II 	 	 	III	 nnV,,!'R
 
 
 	
s&   , AAA;B BBc           
         |y|                                  r3t          | j        j                                      | j        i           }n2t          | j        j                                      | j        i           }t          | j        | j	        | j
        |                    dd          |                    dd                    S )a  Get the documentation for an attribute.

        Arguments:
            node: The node representing the method and its parents.
            attribute_data: Docstring and annotation for this attribute.

        Returns:
            The documented attribute object.
        Nr   r   r  )r"   rj   r9   r   r  r  r  s     r*   r   z"Loader.get_attribute_documentationq  s     !##%% Y!5dko!F!F!J!J49VX!Y!Y!6ty}!E!E!I!I$)UW!X!X!n$((b99$((t<<
 
 
 	
r4   r"   namesc                 :    |r||v S |                      |           S )a]  Tells whether we should select an object or not, given its name.

        If the set of names is not empty, we check against it, otherwise we check against filters.

        Arguments:
            name: The name of the object to select or not.
            names: An explicit list of names to select.

        Returns:
            Yes or no.
        )filter_name_out)r)   r"   r+  s      r*   r   zLoader.select  s-      	!5= ''----r4   )maxsizec                     | j         sdS d}| j         D ]P\  }}t          |                    |                    }|r't          |                              d          r| }|}Q| S )zFilter a name based on the loader's filters.

        Arguments:
            name: The name to filter.

        Returns:
            True if the name was filtered out, False otherwise.
        FTr   )r   rN   searchri   
startswith)r)   r"   keepfltrregexis_matchings         r*   r-  zLoader.filter_name_out  s~     | 	5< 	# 	#KD%u||D1122K #t99'',, 2&1/K"xr4   )Nr   NFFrR   )-re   rf   rg   rh   r   r
   ri   r   rN   r+   r   r   r   r   r    r   r   r^   rU   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r-  rS   r4   r*   r   r     s         (,',0"' %/ /$s)$/ / $D>	/
  / / 
/ / / /4% %C %(5QTUXQY[_Q_K`Ba %ms % % % %T ;?= == !s3x~!67= 
	= = = =~    #       \  ;?m mm !s3x~!67m 
	m m m m^C # ]a fj    ,>> > 	>
 c"> !s3x~!67> > > 
> > > >>#
z #
h #
 #
 #
 #
J*
z *
i *
 *
 *
 *
X 
z 
i 
 
 
 \
0 
Z 
I 
 
 
 \
@ 
* 
 
 
 
 \
0 
 
J 
QU 
bk 
 
 
 \
2	D* 	D 	D 	D 	D 	D	E: 	E& 	E 	E 	E 	EZ F    :.
 .
Z .
XdSViEX .
dj .
 .
 .
 .
` 
 
* 
htn 
`i 
 
 
 \
..3 .s3x .D . . . .  YtC D      r4   r   r   fields_namer   c           	      f    | t          t          fd|j        dd         D                        v S )aU  Check if a field with a certain name was inherited from parent classes.

    Arguments:
        field_name: The name of the field to check.
        fields_name: The name of the attribute in which the fields are stored.
        base_class: The base class in which the field appears.

    Returns:
        Whether the field was inherited.
    c              3   ^   K   | ]'}t          |i                                           V  (d S rR   )ry   keys)r   r   r6  s     r*   	<genexpr>z%field_is_inherited.<locals>.<genexpr>  s;      iiglK4499;;iiiiiir4   rn   ro   )r   r   r   )r   r6  r   s    ` r*   r   r     sM     iiiiPZPbcdegcgPhiii	
   r4   r   c                 T    |                      dd          ^}}|r|d         nd}||fS )a  Split an attribute name into a first-order attribute name and remainder.

    Args:
        attr_name: Attribute name (a)

    Returns:
        Tuple containing:
            first_order_attr_name: Name of the first order attribute (a)
            remainder: The remainder (b.c)

    r-   rn   )maxsplitr   N)rr   )r   r   	remainingr   s       r*   r   r     s<     )2a(H(H%I )3	!tI )++r4   )r   	class_objr   r>  c                   t          |          t          |          z  st          d          t          |           \  }}|r||         n/t          t	          |                                        |i           }|r t          |          |          }t          |          r
 |            }t          |t                    s 	 d |D             }n# t          $ r i }Y nw xY w|S )Nz(Either members or class_obj is required.c           	      n    i | ]2}t          |d d          t          |dt          |                    |3S )auto_createdFr"   )ry   ri   )r   fs     r*   
<dictcomp>zget_fields.<locals>.<dictcomp>  s@    mmm7STVdfkKlKlmgaQ00!mmmr4   )
rN   rq   r   r   varsr]   r   callablerH   r   )r   r   r>  r   r   r   s         r*   r   r     s    MMDOO+ ECDDD'6y'A'A$9/6pW*++Di<Q<Q<U<UVkmo<p<pF /&I&&v.. fd## 	mmVmmmFF 	 	 	FFF	 Ms   C C C )F)4rh   rs   r&   r   r   	functoolsr   	itertoolsr   operatorr   pathlibr   typingr   r   r	   r
   r   r   r   r   r   r   pytkdocs.objectsr   r   r   r   r   r   r   pytkdocs.parsers.attributesr   r   r   r   pytkdocs.parsers.docstringsr   pytkdocs.propertiesr   r   ru   r    ri   rN   r   r   rU   r   r   r   rS   r4   r*   <module>rO     s          				                         \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ W W W W W W W W W W W W W W W W W W s s s s s s s s s s s s / / / / / / * * * * * *0))))))) 0 0 0////////0eT eT eT eT eT eT eT eTZR R# R R R R R RjN
 N
 N
 N
 N
 N
 N
 N
b3 S d t    (,s ,uS(3--?'@ , , , ,( ,0 $	   gc3h'( ~	
 
#s(^     s   .A5 5BB