
    -Phk;                        d dl 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mZmZmZ ddlmZ ddlmZ d	Z G d
 de          Z G d dee          Z G d dee          Z G d dee          ZddZdS )    N)FileSystemLoader)SandboxedEnvironment)BuiltinTemplateLoader   )ClassDocFunctionDocNumpyDocStringObjDoc)get_doc_object)	make_xrefz1\b(import +matplotlib|from +matplotlib +import)\bc                        e Zd ZddZd ZddZd ZddZd	 Zd
 Z	d Z
ddZd Zd Zd dZd Zd Z fdZd Zd Zd Zd Zd!dZ xZS )"SphinxDocStringNc                 f    |i }t          j        | ||           |                     |           d S )N)config)r	   __init__load_config)self	docstringr   s      Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numpydoc/docscrape_sphinx.pyr   zSphinxDocString.__init__   s>    >Fi????         c                    |                     dd          | _        |                     dd          | _        |                     dd          | _        |                     dd          | _        |                     dt                                | _        |                     dt                                | _        |                     d	d           | _	        | j	        ~t          j                            t          j                            t                    d
          g}t          |          }t!          |          }|                    d          | _	        d S d S )N	use_plotsFclass_members_toctreeTattributes_as_param_listxref_param_typexref_aliasesxref_ignoretemplate	templatesloadernumpydoc_docstring.rst)getr   r   r   r   dictr   setr   r   ospathjoindirname__file__r   r   get_template)r   r   template_dirstemplate_loadertemplate_envs        r   r   zSphinxDocString.load_config   s   K77%+ZZ0G%N%N"(.

3Mt(T(T%%zz*;UCC"JJ~tvv>>!::mSUU;;

:t44= W\\"'//(*C*C[QQRM.}==O/GGGL(556NOODMMM	 ! r   `c                     d|z   dgS )N.. rubric::   )r   namesymbols      r   _str_headerzSphinxDocString._str_header(   s    %r**r   c                     d|z   dz   gS )N:r3   r   r4   s     r   _str_field_listzSphinxDocString._str_field_list+   s    d
S !!r      c                 ,    g }|D ]}|d|z  |z   gz  }|S )N r3   )r   docindentoutlines        r   _str_indentzSphinxDocString._str_indent.   s3     	) 	)DC&L4'((CC
r   c                     dgS )Nr2   r3   r   s    r   _str_signaturezSphinxDocString._str_signature4   s	    tr   c                     | d         dgz   S )NSummaryr2   r3   rD   s    r   _str_summaryzSphinxDocString._str_summary7   s    I"%%r   c                     | d         dgz   S )NzExtended Summaryr2   r3   rD   s    r   _str_extended_summaryz%SphinxDocString._str_extended_summary:   s    &'2$..r   Returnsc                 .   d}d}g }| |         r||                      |          z  }|dgz  }| |         D ]}|j        }|r"| j        rt          || j        | j                  }|j        r6||                     ||j                                        |fz  g          z  }n.||                     ||                                z  g          z  }|j	        s||                     dgd          z  }n||                     |j	        d          z  }|dgz  }|S )Nz**%s** : %sz%sr2   ..   )
r:   typer   r   r   r   r4   rB   stripdesc)r   r4   	named_fmtunnamed_fmtr@   param
param_types          r   _str_returnszSphinxDocString._str_returns=   sU   !	: 	4''---CB4KCd  "Z
 $"6 !*"D$5t7G" "J : P4++"ej&6&6&8&8*%EEF  CC 4++[:;K;K;M;M-M,NOOOCz ;4++TFA666CC4++EJ:::Ct
r   c                 r    |d d         dk    rd|dd          z   S |d d         dk    rd|dd          z   S |S )N   **z\*\*r   *z\*r3   r9   s     r   _escape_args_and_kwargsz'SphinxDocString._escape_args_and_kwargsX   sQ    8tT!""X%%"1"X__48##Kr   c                 D   |                      |                                          }d| d}|s||fS t          | j        |d          }t	          |          s?t          |t                    s*t          j        |          st          j	        |          sd}t          j        |          }|r|s||fS t          | dd          }|r| d}nd}d| d| | d}|rt          j        d	|                                d
          d         }t          j        dd                    |                                                    }	|	r(|	                    d
                                          }n|                    d          d         }|                    d          }||fS )a  Determine how to display a parameter

        Emulates autosummary behavior if fake_autosummary

        Parameters
        ----------
        param : str
            The name of the parameter
        desc : list of str
            The parameter description as given in the docstring. This is
            ignored when autosummary logic applies.
        fake_autosummary : bool
            If True, autosummary-style behaviour will apply for params
            that are attributes of the class and have a docstring.

        Returns
        -------
        display_param : str
            The marked up parameter name for display. This may include a link
            to the corresponding attribute's own documentation.
        desc : list of str
            A list of description lines. This may be identical to the input
            ``desc``, if ``autosum is None`` or ``param`` is not a class
            attribute, or it will be a summary of the class attribute's
            docstring.

        Notes
        -----
        This does not have the autosummary functionality to display a method's
        signature, and hence is not used to format methods.  It may be
        complicated to incorporate autosummary's signature mangling, as it
        relies on Sphinx's plugin mechanism.
        rY   N_namer2   .z:obj:`z <z>`z\n\s*\nr   r   z^([A-Z].*?\.)(?:\s|$)r=   
)r[   rP   getattr_objcallable
isinstancepropertyinspectisgetsetdescriptorismemberdescriptorpydocgetdocresplitsearchr(   group	partition)
r   rT   rQ   fake_autosummarydisplay_param	param_objobj_docprefixlink_prefixms
             r   _process_paramzSphinxDocString._process_param`   s   D ,,U[[]];;
 'U 	' $&&DIud33	Y	)X..	 ))44	 ))44		 I,y)) 	'g 	' $&&w++ 	#,,,KKK A@@+@u@@@ 
	$8J;;A>D 	2CHHTZZ\\4J4JKKA /wwqzz''))~~d++A.::d##Dd""r   Fc                    g }| |         r||                      |          z  }|dgz  }| |         D ]}|                     |j        |j        |          \  }}g }|r|                    |           |j        }|r>|j        }| j        rt          || j        | j	                  }|                    |           || 
                    d                    |          g          z  }|sdg}|| 
                    |d          z  }|dgz  }|S )aI  Generate RST for a listing of parameters or similar

        Parameter names are displayed as bold text, and descriptions
        are in definition lists.

        Parameters
        ----------
        name : str
            Section name (e.g. Parameters)
        fake_autosummary : bool
            When True, the parameter names may correspond to attributes of the
            object beign documented, usually ``property`` instances on a class.
            In this case, names will be linked to fuller descriptions.

        Returns
        -------
        rst : list of str
        r2   z : rM   rN   )r:   rv   r4   rQ   appendrO   r   r   r   r   rB   r(   )	r   r4   ro   r@   rT   rp   rQ   partsrU   s	            r   _str_param_listzSphinxDocString._str_param_list   sE   & : 	4''---CB4KCd  &*&9&9J
,<' '#t   0LL///"Z
 -!&J+ %.&(94;K& &
 LL,,,t''E):):(;<<< " 6Dt''a000t
r   c                    g }| |         r|d| dgz  }t          | dd          }|rd| d}g }g }| |         D ]}|                    |j                                                  }t          | j        |j        d          }t          |          s+t          |t                    st          j	        |          sd}|r%t          j        |          r|d| |j         gz  }|                    |           |r|d	gz  }| j        r|d
gz  }|dg|z   z  }|rt          dt          d |D                                 }d|z  dz   dz   }	d|fz  }
|dd|	gz  }|D ]v}d|j                                        z   dz   }d                    d |j        D                                                       }|j        rd|j         d| }||
||fz  gz  }w||	gz  }|dgz  }|S )zp
        Generate a member listing, autosummary:: table where possible,
        and a table where not.

        r1   r2   r]   ~r^   )r4   N   z.. autosummary::z   :toctree:   c              3   D   K   | ]}t          |j                  d z   V  dS )r;   N)lenr4   ).0ps     r   	<genexpr>z3SphinxDocString._str_member_list.<locals>.<genexpr>  s.      %F%F!c!&kkAo%F%F%F%F%F%Fr   =z  z
==========z%%%ds  %%s  rY   r=   c              3   >   K   | ]}|                                 V  d S N)rP   )r   xs     r   r   z3SphinxDocString._str_member_list.<locals>.<genexpr>  s*      #B#B!AGGII#B#B#B#B#B#Br   (z) )r`   _replacer4   rP   ra   rb   rc   rd   re   isdatadescriptorrh   ri   rx   r   maxr(   rQ   rO   )r   r4   r@   rs   autosumothersrT   rq   maxlen_0hdrfmtrQ   s               r   _str_member_listz SphinxDocString._str_member_list   s|    : -	)4))2..CT7B//F '&VGFd ) )EJ,<,<,>,>?? $DIuz4@@	Y''%!)X66% /	::%
 !%I )i!8!8 ) :f :ej : :;;GGMM%(((( &*++- ,N++Ctg~% q#%F%Fv%F%F%F"F"FGGHnt+h6${2B}$# 0 0E%*"2"2"4"44t;D88#B#Buz#B#B#BBBHHJJDz 875:7777C4,.//CCuB4KC
r   c                     g }| |         rc||                      |          z  }t          j        d                    | |                                                 d          }||z  }|dgz  }|S )Nr_   r2   )r6   textwrapdedentr(   rk   )r   r4   r@   contents       r   _str_sectionzSphinxDocString._str_section  sq    : 	4##D)))CodiiT
&;&;<<BB4HHG7NCB4KC
r   c                     g }| d         rEt                                          |          }ddg}||                     |dd                    z  }|S )NzSee Alsoz.. seealso::r2   rX   )super_str_see_alsorB   )r   	func_roler@   see_also	__class__s       r   r   zSphinxDocString._str_see_also  s[    
 	2ww,,Y77H!2&C4##HQRRL111C
r   c                 j    g }| d         r(ddg}||                      | d                   z  }|dgz  }|S )NWarningsz.. warning::r2   )rB   )r   r@   s     r   _str_warningszSphinxDocString._str_warnings&  sK    
 	!2&C4##D$4555CB4KC
r   c                 P   | d         }g }t          |          dk    r|S |d|                    dd           gz  }|                                D ]N\  }}|dk    r|dk    r|dd                    |           gz  }/|d	| d
d                    |           gz  }O|dgz  }|S )Nindexr   z.. index:: defaultr2   refguidez   single: , r}   z: ,)r   r#   itemsr(   )r   idxr@   section
referencess        r   
_str_indexzSphinxDocString._str_index.  s    7ms88q==J6cggi446677#&99;; 	A 	AGZ)##J&&=dii
&;&;==>>?g??*)=)=??@@t
r   c                    g }| d         r||                      d          z  }t          | d         t                    r| d         g| d<   |                    | d                    |dgz  }|ddgz  }g }| d         D ]L}t	          j        d|t          j                  }|r(|                    |                    d                     M|dd	                    d |D                       z   dgz  }|S )	N
Referencesr2   z.. only:: latexz.. \[([a-z0-9._-]+)\]r   r}   r   c                     g | ]}d | d	S )[z]_r3   )r   items     r   
<listcomp>z3SphinxDocString._str_references.<locals>.<listcomp>O  s     &F&F&F|4|||&F&F&Fr   )
r6   rc   strextendrj   match
IGNORECASErx   rm   r(   )r   r@   r   rA   ru   s        r   _str_referenceszSphinxDocString._str_references?  s    	M4##L111C$|,c22 :&*<&8%9\"JJtL)***B4KC %r**CE\* - -H5tR]KK -LL,,,EDII&F&F&F&F&FGGGLLC
r   c                 :   d                     | d                   }| j        ret          j        t          |          rKd|vrGg }||                     d          z  }|ddgz  }||                     | d                   z  }|dgz  }|S |                     d          S )Nr_   Exampleszplot::z	.. plot::r2   )r(   r   rj   rl   IMPORT_MATPLOTLIB_REr6   rB   r   )r   examples_strr@   s      r   _str_exampleszSphinxDocString._str_examplesR  s    yyj!122 N	1	.==	1 ,,C4##J///CK$$C4##D$4555CB4KCJ$$Z000r   r   objc                 &   i d|                                  d|                                 d|                                 d|                                 d|                     d          d| j        r|                     dd	
          n|                     d          d|                     d          d|                     d          d|                     d          d|                     d          d|                     d          d|                     d          d|                     d          d|                                 d| 	                    |          d| 
                    d          d|                                 d|                                 i}d |                                D             } | j        j        d!i |}d                     |                     |                    d           |                    S )"N	signaturer   summaryextended_summary
parameters
Parameters
attributes
AttributesT)ro   methodsMethodsreturnsrK   yieldsYieldsreceivesReceivesother_parameterszOther ParametersraisesRaiseswarnsWarnswarningsr   notesNotesr   examplesc                 @    i | ]\  }}|d                      |          S )r_   )r(   )r   kvs      r   
<dictcomp>z+SphinxDocString.__str__.<locals>.<dictcomp>|  s(    555$!Qa1555r   r_   r3   )rE   r   rH   rJ   rz   r   r   rV   r   r   r   r   r   r   r   renderr(   rB   rk   )r   r?   r   nsrendereds        r   __str__zSphinxDocString.__str__c  sX   
,,..
T__&&
 t((**
  : : < <	

 $..|<<
 09$$\D$III**<88
 t,,Y77
 t((33
 d''11
 ))*55
  4 45G H H
  d''11!
" T&&w//#
$ **,,%
& **955'
( T&&w//)
* $..00+
, **,,-
 
0 65"((**555'4='--"--yy))(..*>*>GGHHHr   r   )r/   )r;   )rK   )F)r   r   )__name__
__module____qualname__r   r   r6   r:   rB   rE   rH   rJ   rV   r[   rv   rz   r   r   r   r   r   r   r   r   __classcell__)r   s   @r   r   r      s       ! ! ! !P P P+ + + +" " "     & & &/ / /   6  L# L# L#\. . . .`5 5 5n          "  &1 1 1"I I I I I I I Ir   r   c                       e Zd ZddZdS )SphinxFunctionDocNc                 h    |i }|                      |           t          j        | |||           d S N)r>   r   )r   r   r   r   r   r>   r   s       r   r   zSphinxFunctionDoc.__init__  s@    >F   T3C??????r   NNr   r   r   r   r3   r   r   r   r     s.        @ @ @ @ @ @r   r   c                       e Zd ZddZdS )SphinxClassDocNc                 j    |i }|                      |           t          j        | ||d |           d S )N)r>   func_docr   )r   r   r   )r   r   r>   r   r   s        r   r   zSphinxClassDoc.__init__  sB    >F   $tFKKKKKKr   )NNNr   r3   r   r   r   r     s.        L L L L L Lr   r   c                       e Zd ZddZdS )SphinxObjDocNc                 h    |i }|                      |           t          j        | |||           d S r   )r   r
   r   r   s       r   r   zSphinxObjDoc.__init__  s?    >F   cs6::::::r   r   r   r3   r   r   r   r     s(        ; ; ; ; ; ;r   r   c           	         |i }t           j                            t           j                            t                    d          g}|&t                      }|                    ||           nt          |          }t          |          }|	                    d          |d<   t          | |||t          t          t                    S )Nr   )dirsr    r"   r   )whatr>   r   	class_docr   rr   )r&   r'   r(   r)   r*   r   initr   r   r+   get_doc_object_origr   r   r   )r   r   r>   r   builderr,   r-   r.   s           r   r   r     s    ~W\\"'//(";";[IIJM/11W=9999*=99'???L%223KLLF: "   r   )NNNN)re   r&   rh   rj   r   jinja2r   jinja2.sandboxr   sphinx.jinja2gluer   	docscraper   r   r	   r
   r   r   xrefr   r   r   r   r   r   r3   r   r   <module>r      s    				  				  # # # # # # / / / / / / 3 3 3 3 3 3 D D D D D D D D D D D D < < < < < <      K mI mI mI mI mIn mI mI mI`@ @ @ @ @ @ @ @L L L L L_h L L L; ; ; ; ;?F ; ; ;     r   