
    ij                        d Z ddlZddlZddlmZmZ ddlmZm	Z	m
Z
mZmZ d,dZd,dZd,dZd,d	Zej"                  j%                  d
g d      dededdfd       Zej"                  j%                  dg d      dededededdf
d       Zej"                  j%                  dg d      dedej.                  e   dej.                  e   dededdfd       Zd,dZd,dZd,dZd,dZd,dZd,dZd,d Zd,d!Z d,d"Z!d,d#Z"d,d$Z#d,d%Z$ej"                  j%                  d
g d&      dededdfd'       Z%ej"                  j%                  d
d(g      dededdfd)       Z&ej"                  j%                  d
d*g      dededdfd+       Z'y)-z*Tests for Google-style docstring routines.    N)
ParseErrorRenderingStyle)GoogleParserSectionSectionTypecomposeparsereturnc                      t               } | j                  d      }|j                  dk(  sJ |j                  dk(  sJ t	        |j
                        dk(  sJ y)zQTest parsing an unknown section with default GoogleParser
    configuration.
    z.
        Unknown:
            spam: a
        zUnknown:zspam: ar   N)r   r	   short_descriptionlong_descriptionlenmetaparser	docstrings     QC:\Projects\mas-dev\.venv\Lib\site-packages\docstring_parser/tests/test_google.py"test_google_parser_unknown_sectionr      s_     ^F	I &&*444%%222y~~!###    c                  v    t               } | j                  d      }|j                  d   j                  dk(  sJ y)zBTest parsing a multi-line parameter type with default GoogleParsera  Description of the function.

        Args:
            output_type (Literal["searchResults", "sourcedAnswer",
                "structured"]): The type of output.
                This can be one of the following:
                - "searchResults": Represents the search results.
                - "sourcedAnswer": Represents a sourced answer.
                - "structured": Represents a structured output format.

        Returns:
            bool: Indicates success or failure.

        r   output_typeN)r   r	   paramsarg_namer   s     r   ,test_google_parser_multi_line_parameter_typer       s=    ^F	I  A''=888r   c            
      `   t        t        ddt        j                        t        ddt        j                        t        ddt        j                        t        ddt        j                        gd	
      } | j                  d      }|j                  J |j                  J t        |j                        dk(  sJ |j                  d   j                  dgk(  sJ |j                  d   j                  dk(  sJ |j                  d   j                  ddgk(  sJ |j                  d   j                  dk(  sJ |j                  d   j                  ddgk(  sJ |j                  d   j                  dk(  sJ |j                  d   j                  ddgk(  sJ |j                  d   j                  dk(  sJ |j                  d   j                  ddgk(  sJ |j                  d   j                  dk(  sJ |j                  d   j                  dgk(  sJ |j                  d   j                  dk(  sJ y)zPTest parsing an unknown section with custom GoogleParser
    configuration.
    DESCRIPTIONdesc	ARGUMENTSparam
ATTRIBUTES	attributeEXAMPLESexamplesFtitle_colona/  
        DESCRIPTION
            This is the description.

        ARGUMENTS
            arg1: first arg
            arg2: second arg

        ATTRIBUTES
            attr1: first attribute
            attr2: second attribute

        EXAMPLES
            Many examples
            More examples
        N   r   zThis is the description.   arg1z	first arg   arg2z
second arg   attr1zfirst attribute   attr2zsecond attribute   zMany examples
More examples)r   r   r   SINGULARMULTIPLEr	   r   r   r   r   argsdescriptionr   s     r   "test_google_parser_custom_sectionsr4   6   s*    M6;+?+?@K+*>*>?L+{/C/CDJ
K,@,@A		
 F 	I& &&...%%---y~~!###>>!!!fX--->>!((,FFFF>>!!!gv%6666>>!((K777>>!!!gv%6666>>!((L888>>!!!k7%;;;;>>!((,====>>!!!k7%;;;;>>!((,>>>>>>!!!j\111>>!((,JJJJr   c                     t        d      } | j                  t        ddt        j                               | j                  d      }|j                  dk(  sJ |j                  dk(  sJ | j                  d      }|j                  dk(  sJ |j                  d	k(  sJ | j                  d
      }t        |j                        dk(  sJ |j                  d   j                  dgk(  sJ |j                  d   j                  dk(  sJ y)zjTest parsing an unknown section with custom GoogleParser configuration
    that was set at a runtime.
    Fr$   NotenotezE
        short description

        Note:
            a note
        zshort descriptionzNote:
    a notez8
        short description

        Note a note
        zNote a notezD
        short description

        Note
            a note
        r'   r   za noteN)r   add_sectionr   r   r0   r	   r   r   r   r   r2   r3   r   s     r   (test_google_parser_custom_sections_afterr9   g   s    e,F
wvv{/C/CDE	I &&*====%%)<<<<	I &&*====%%666	I y~~!###>>!!!fX--->>!((H444r   zsource, expected)) N)
NShort descriptionr=   z
Short description
r=   z
   Short description
r=   sourceexpectedc                 t    t        |       }|j                  |k(  sJ |j                  J |j                  rJ y)zTest parsing short description.N)r	   r   r   r   )r@   rA   r   s      r   test_short_descriptionrC      sB     fI&&(222%%---~~~r   z?source, expected_short_desc, expected_long_desc, expected_blank))#Short description

Long descriptionr=   Long descriptionT)I
            Short description

            Long description
            r=   rE   T)a
            Short description

            Long description
            Second line
            r=   Long description
Second lineT)"Short description
Long descriptionr=   rE   F)H
            Short description
            Long description
            r=   rE   F)$
Short description
Long description
r=   rE   F)`
            Short description
            Long description
            Second line
            r=   rH   Fexpected_short_descexpected_long_descexpected_blankc                     t        |       }|j                  |k(  sJ |j                  |k(  sJ |j                  |k(  sJ |j                  rJ y)zTest parsing long description.N)r	   r   r   blank_after_short_descriptionr   )r@   rM   rN   rO   r   s        r   test_long_descriptionrR      s[    L fI&&*====%%);;;;22nDDD~~~r   zdsource, expected_short_desc, expected_long_desc, expected_blank_short_desc, expected_blank_long_desc))zR
            Short description
            Args:
                asd:
            r=   NFF)zo
            Short description
            Long description
            Args:
                asd:
            r=   rE   FF)z
            Short description
            First line
                Second line
            Args:
                asd:
            r=   First line
    Second lineFF)z
            Short description

            First line
                Second line
            Args:
                asd:
            r=   rS   TF)z
            Short description

            First line
                Second line

            Args:
                asd:
            r=   rS   TT)z4
            Args:
                asd:
            NNFFexpected_blank_short_descexpected_blank_long_descc                     t        |       }|j                  |k(  sJ |j                  |k(  sJ |j                  |k(  sJ |j                  |k(  sJ t        |j                        dk(  sJ y)z2Test parsing newlines around description sections.r'   N)r	   r   r   rQ   blank_after_long_descriptionr   r   )r@   rM   rN   rT   rU   r   s         r   test_meta_newlinesrX      sy    r fI&&*====%%);;;;226OOOO115MMMMy~~!###r   c                  (   t        d      } | j                  dk(  sJ t        | j                        dk(  sJ | j                  d   j                  ddgk(  sJ | j                  d   j
                  dk(  sJ | j                  d   j                  dk(  sJ y)	z*Test parsing multiline meta documentation.z
        Short description

        Args:
            spam: asd
                1
                    2
                3
        r=   r'   r   r   spamasd
1
    2
3N)r	   r   r   r   r2   r   r3   r   s    r   $test_meta_with_multiline_descriptionr]   O  s    	
I &&*====y~~!###>>!!!gv%6666>>!%%///>>!((,>>>>r   c                     t        d      } | J t        | j                        dk(  sJ | j                  d   }|j                  dk(  sJ |j                  sJ |j
                  dk(  sJ |j                  dk(  sJ |j                  dk(  sJ y)	zTest parsing default arguments.a  A sample function

A function the demonstrates docstrings

Args:
    arg1 (int): The firsty arg
    arg2 (str): The second arg
    arg3 (float, optional): The third arg. Defaults to 1.0.
    arg4 (Optional[Dict[str, Any]], optional): The last arg. Defaults to None.
    arg5 (str, optional): The fifth arg. Defaults to DEFAULT_ARG5.

Returns:
    Mapping[str, Any]: The args packed in a mapping
Nr/   r+   arg4zOptional[Dict[str, Any]]NonezThe last arg. Defaults to None.)r	   r   r   r   is_optional	type_namedefaultr3   )r   r_   s     r   test_default_argsrd   c  s    	I     y A%%%AD==F""">>7777<<6!!!@@@@r   c                     t        d      } | j                  dk(  sJ t        | j                        dk(  sJ | j                  d   j                  ddgk(  sJ | j                  d   j
                  dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  d	d
gk(  sJ | j                  d   j                  d
k(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  d	dgk(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  dk(  sJ y)zTest parsing multiple meta.z
        Short description

        Args:
            spam: asd
                1
                    2
                3

        Raises:
            bla: herp
            yay: derp
        r=   r+   r   r   rZ   r[   r'   raisesblaherpr)   yayderpN)r	   r   r   r   r2   r   r3   rb   r\   s    r   test_multiple_metark     sT   	I &&*====y~~!###>>!!!gv%6666>>!%%///>>!((,>>>>>>!!!h%6666>>!&&%///>>!((F222>>!!!h%6666>>!&&%///>>!((F222r   c                     t        d      } t        | j                        dk(  sJ t        d      } t        | j                        dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  J | j                  d   j
                  dk(  sJ | j                  d   j                  rJ | j                  d   j                  d	k(  sJ | j                  d   j                  d
k(  sJ | j                  d   j
                  dk(  sJ | j                  d   j                  rJ | j                  d   j                  dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j
                  dk(  sJ | j                  d   j                  sJ | j                  d   j                  dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j
                  dk(  sJ | j                  d   j                  sJ t        d      } t        | j                        dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  J | j                  d   j
                  dk(  sJ | j                  d   j                  d	k(  sJ | j                  d   j                  d
k(  sJ | j                  d   j
                  dk(  sJ y)zTest parsing params.r=   r   z
        Short description

        Args:
            name: description 1
            priority (int): description 2
            sender (str?): description 3
            ratio (Optional[float], optional): description 4
        r-   nameNdescription 1r'   priorityintdescription 2r)   senderstrdescription 3r+   ratioOptional[float]description 4z
        Short description

        Args:
            name: description 1
                with multi-line text
            priority (int): description 2
        "description 1
with multi-line textr	   r   r   r   rb   r3   ra   r\   s    r   test_paramsrz        )*Iy A%%%	
I y A%%%A''6111A((000A**o==="....A'':555A((E111A**o==="....A''8333A((E111A**o===A****A''7222A((,====A**o===A****		I y A%%%A''6111A((000A**-   A'':555A((E111A**o===r   c                     t        d      } t        | j                        dk(  sJ t        d      } t        | j                        dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  J | j                  d   j
                  dk(  sJ | j                  d   j                  rJ | j                  d   j                  d	k(  sJ | j                  d   j                  d
k(  sJ | j                  d   j
                  dk(  sJ | j                  d   j                  rJ | j                  d   j                  dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j
                  dk(  sJ | j                  d   j                  sJ | j                  d   j                  dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j
                  dk(  sJ | j                  d   j                  sJ t        d      } t        | j                        dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  J | j                  d   j
                  dk(  sJ | j                  d   j                  d	k(  sJ | j                  d   j                  d
k(  sJ | j                  d   j
                  dk(  sJ y)zTest parsing attributes.r=   r   z
        Short description

        Attributes:
            name: description 1
            priority (int): description 2
            sender (str?): description 3
            ratio (Optional[float], optional): description 4
        r-   rm   Nrn   r'   ro   rp   rq   r)   rr   rs   rt   r+   ru   rv   rw   z
        Short description

        Attributes:
            name: description 1
                with multi-line text
            priority (int): description 2
        rx   ry   r\   s    r   test_attributesr}     r{   r   c                  v   t        d      } | j                  J | j                  J t        | j                        dk(  sJ t        d      } | j                  J | j                  j                  J | j                  j
                  dk(  sJ | j                  J t        | j                        dk(  sJ | j                  d   | j                  k(  sJ t        d      } | j                  J | j                  j                  J | j                  j
                  dk(  sJ | j                  J t        | j                        dk(  sJ | j                  d   | j                  k(  sJ t        d	      } | j                  J | j                  j                  d
k(  sJ | j                  j
                  dk(  sJ | j                  J t        | j                        dk(  sJ | j                  d   | j                  k(  sJ t        d      } | j                  J | j                  j                  dk(  sJ | j                  j
                  dk(  sJ | j                  J t        | j                        dk(  sJ | j                  d   | j                  k(  sJ t        d      } | j                  J | j                  j                  d
k(  sJ | j                  j
                  dk(  sJ | j                  J t        | j                        dk(  sJ | j                  d   | j                  k(  sJ t        d      } | j                  J | j                  j                  d
k(  sJ | j                  j
                  dk(  sJ | j                  J t        | j                        dk(  sJ | j                  d   | j                  k(  sJ y)zTest parsing returns.#
        Short description
        Nr   zL
        Short description
        Returns:
            description
        r3   r'   z[
        Short description
        Returns:
            description with: a colon!
        zdescription with: a colon!zQ
        Short description
        Returns:
            int: description
        rp   ze
        Returns:
            Optional[Mapping[str, List[int]]]: A description: with a colon
        z!Optional[Mapping[str, List[int]]]zA description: with a colonzP
        Short description
        Yields:
            int: description
        z
        Short description
        Returns:
            int: description
            with much text

            even some spacing
        z-description
with much text

even some spacing)r	   returnsmany_returnsr   rb   r3   r\   s    r   test_returnsr     s   	I
 $$$!!---y%%&!+++	I (((&&...((M999!!---y%%&!+++!!!$	(9(9999	I (((&&...((,HHHH!!---y%%&!+++!!!$	(9(9999	I (((&&%///((M999!!---y%%&!+++!!!$	(9(9999	I (((&&*MMMM((,IIII!!---y%%&!+++!!!$	(9(9999	I (((&&%///((M999!!---y%%&!+++!!!$	(9(9999		I (((&&%///((:   !!---y%%&!+++!!!$	(9(9999r   c                     t        d      } t        | j                        dk(  sJ t        d      } t        | j                        dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  dk(  sJ y)zTest parsing raises.r   r   zW
        Short description
        Raises:
            ValueError: description
        r'   
ValueErrorr3   N)r	   r   rf   rb   r3   r\   s    r   test_raisesr   p  s    	I
 y A%%%	I y A%%%A((L888A**m;;;r   c                      t        d      } t        | j                        dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  dk(  sJ y)zTest parsing examples.z
        Short description
        Example:
            example: 1
        Examples:
            long example

            more here
        r)   r   z
example: 1r'   zlong example

more hereN)r	   r   r#   r3   r\   s    r   test_examplesr     sk    	
I y!!"a'''a ,,<<<a ,,0KKKKr   c                      t        j                  t              5  t        d       ddd       t        j                  t              5  t        d       ddd       y# 1 sw Y   7xY w# 1 sw Y   yxY w)zTest parsing broken meta.zArgs:NzArgs:
    herp derppytestrf   r   r	    r   r   test_broken_metar     sK    	z	"g 
# 
z	"$% 
#	" 
#	" 
#	"s   AA(A%(A1c                  
   t        d      } | j                  d   j                  dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  dk(  sJ | j                  d   j                  dk(  sJ y)	zTest parsing unknown meta.zShort desc

        Unknown 0:
            title0: content0

        Args:
            arg0: desc0
            arg1: desc1

        Unknown1:
            title1: content1

        Unknown2:
            title2: content2
        r   arg0desc0r'   r(   desc1N)r	   r   r   r3   r\   s    r   test_unknown_metar     s    	I$ A''6111A**g555A''6111A**g555r   c                  v    t        j                  t              5  t        d       ddd       y# 1 sw Y   yxY w)zTest parsing broken arguments.zWThis is a test

            Args:
                param - poorly formatted
            Nr   r   r   r   test_broken_argumentsr     s'    	z	"	
 
#	"	"s   /8c                      t        d      } t        | j                        dk(  sJ | j                  d   j                  dgk(  sJ | j                  d   j                  dk(  sJ y)z$Test parsing empty examples section.z]Short description

        Example:

        Raises:
            IOError: some error
        r'   r   r#   r:   N)r	   r   r#   r2   r3   r\   s    r   test_empty_exampler     sl    	I y!!"a'''a %%*555a ,,222r   ))r:   r:   )r;   r:   r<   r>   r?   )rD   rD   )rF   rD   )rG   z/Short description

Long description
Second line)rI   rI   )rJ   rI   )rK   rI   )rL   z.Short description
Long description
Second line)zQ
            Short description
            Meta:
                asd
            zShort description
Meta:
    asd)zn
            Short description
            Long description
            Meta:
                asd
            z0Short description
Long description
Meta:
    asd)z
            Short description
            First line
                Second line
            Meta:
                asd
            z:Short description
First line
    Second line
Meta:
    asd)z
            Short description

            First line
                Second line
            Meta:
                asd
            z;Short description

First line
    Second line
Meta:
    asd)z
            Short description

            First line
                Second line

            Meta:
                asd
            z<Short description

First line
    Second line

Meta:
    asd)z
            Short description

            Meta:
                asd
                    1
                        2
                    3
            zBShort description

Meta:
    asd
        1
            2
        3)z
            Short description

            Meta1:
                asd
                1
                    2
                3
            Meta2:
                herp
            Meta3:
                derp
            zWShort description

Meta1:
    asd
    1
        2
    3
Meta2:
    herp
Meta3:
    derp)  
            Short description

            Args:
                name: description 1
                priority (int): description 2
                sender (str, optional): description 3
                message (str, optional): description 4, defaults to 'hello'
                multiline (str?):
                    long description 5,
                        defaults to 'bye'
            zShort description

Args:
    name: description 1
    priority (int): description 2
    sender (str?): description 3
    message (str?): description 4, defaults to 'hello'
    multiline (str?): long description 5,
        defaults to 'bye')zg
            Short description
            Raises:
                ValueError: description
            z5Short description
Raises:
    ValueError: descriptionc                 6    t        t        |             |k(  sJ y)zTest compose in default mode.N)r   r	   r@   rA   s     r   test_composer     s    H 5=!X---r   )r   a	  Short description

Args:
    name: description 1
    priority (int): description 2
    sender (str, optional): description 3
    message (str, optional): description 4, defaults to 'hello'
    multiline (str, optional): long description 5,
        defaults to 'bye'c                 V    t        t        |       t        j                        |k(  sJ y)zTest compose in clean mode.rendering_styleN)r   r	   r   CLEANr   s     r   test_compose_cleanr     s*    > 	f~/C/CD		r   )r   a1  Short description

Args:
    name:
        description 1
    priority (int):
        description 2
    sender (str, optional):
        description 3
    message (str, optional):
        description 4, defaults to 'hello'
    multiline (str, optional):
        long description 5,
        defaults to 'bye'c                 V    t        t        |       t        j                        |k(  sJ y)zTest compose in expanded mode.r   N)r   r	   r   EXPANDEDr   s     r   test_compose_expandedr     s+    H 	f~/F/FG		r   )r
   N)(__doc__typingTr   docstring_parser.commonr   r   docstring_parser.googler   r   r   r   r	   r   r   r4   r9   markparametrizers   rC   boolrR   OptionalrX   r]   rd   rk   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s^   0   > $ 9,.Kb%5P 	3 # $ 	 E;>~  	
 
>~ :LPb$$C$ 

3$  $	$
 #$ 
$cPb$ ?(A:3<4>n4>na:H<*L$&64	
3" ~AD. . . .EAD.
 	
8s c d 98 	
 B#   C Br   