
    -Ph&                       U d Z ddlm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
mZmZmZmZ ddlmZmZ erWddlmZmZmZmZ ddlmZmZ eej        gej        f         Zd	ed
<   eej        gef         Zd	ed<   ddlmZ  G d de          Z i Z!ded<   d'dZ" G d dej                  Z#d(dZ$d)d*dZ%d+dZ&d,d#Z'd)d-d%Z(e)d&k    r e* e(                      dS ).a  Base 'sphinx' command.

Subcommands are loaded lazily from the ``_COMMANDS`` table for performance.

All subcommand modules must define three attributes:

- ``parser_description``, a description of the subcommand. The first paragraph
  is taken as the short description for the command.
- ``set_up_parser``, a callable taking and returning an ``ArgumentParser``. This
  function is responsible for adding options and arguments to the subcommand's
  parser.
- ``run``, a callable taking parsed arguments and returning an exit code. This
  function is responsible for running the main body of the subcommand and
  returning the exit status.

The entire ``sphinx._cli`` namespace is private, only the command line interface
has backwards-compatibility guarantees.
    )annotationsN)TYPE_CHECKING)bolddisable_colourenable_colourterminal_supports_colour	underline)__init_console)CallableIterableIteratorSequence)NoReturn	TypeAliasr   _PARSER_SETUP_RUNNER)Protocolc                  .    e Zd ZU ded<   ded<   ded<   dS )_SubcommandModulestrparser_descriptionr   set_up_parserr   runN)__name__
__module____qualname____annotations__     T/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/_cli/__init__.pyr   r   0   s1         $$$$r    r   zdict[str, str]	_COMMANDSreturnIterator[tuple[str, str]]c               #    K   t                                           D ]o\  } }t          j        |          }	 |j        }| |                    dd          d         fV  B# t          $ r! t          d|  t          j	                   Y lw xY wd S )Nz

   r   z#Failed to load the description for )file)
r"   items	importlibimport_moduler   splitAttributeErrorprintsysstderr)commandmodule_namemoduledescriptions       r!   _load_subcommand_descriptionsr4   :   s       ) 1 1 ; ;$-$;K$H$H	; 3K
 ;,,VQ77::::::	  	T 	T 	TAAA
SSSSSS	T	; ;s   A(B	B	c                  >    e Zd ZddZddZedd            ZddZdS )_RootArgumentParserr#   r   c           
     j   t          t          t          d                              dt          d                              t          | j                            ddt          d          dg}t          t                                x}rt          t          t          t          |ddid                    }t          t          |          d	          |dt          t          t          d
                              dgz  }|fd|D             z  }|                    d           t          d          | j        _        | j        dd          D ]5}d |j        D             x}r ||                     ||j        pd          z  }6|dt          d          dgz  }d                    |          S )NzUsage: z {0} [OPTIONS] <COMMAND> [<ARGS>]
z%  The Sphinx documentation generator.strictTr      z	Commands:c                .    g | ]\  }}d |d d | S )  z <r   ).0command_namecommand_desccommand_max_lengths      r!   
<listcomp>z3_RootArgumentParser.format_help.<locals>.<listcomp>Z   sJ       .L, K\J%7JJJJLJJ  r    Optionsr&   c                <    g | ]}|j         t          j        k    |S r   )helpargparseSUPPRESS)r>   actions     r!   rB   z3_RootArgumentParser.format_help.<locals>.<listcomp>d   s2       ;("333 333r     FFor more information, visit https://www.sphinx-doc.org/en/master/man/.)r   r	   r
   formatproglistr4   maplennextzipminmaxappend
_optionalstitle_action_groups_group_actions_format_optional_argumentsjoin)selfhelp_fragmentscommandscommand_lengthsargument_group	argumentsrA   s         @r!   format_helpz_RootArgumentParser.format_helpG   s   2h<<(())12299$ty//JJ677%
 9;;<<<8 	(!#tC,G$,G,G'L'LMMO!$S%9%92!>!>Yr+//00 N
     2:   N !!$''' !#9"1!""5 		 		N ,;   y 
 $"A"A"(.B# # 
 	X  
 	
 ww~&&&r    actionsIterable[argparse.Action]rV   Iterator[str]c           	   #    K   dV  t          t          |dz                       V  dV  |D ]}dt          d |j        D                       z  }|dz   d                    t          t           |j                            z   }|j        dk    r2|d|                     |j        |j        |j	        |j
                  z   z  }|V  dV  |j        pd	                                x}r$d
 |                                D             E d {V  d S )Nr9   :z    c              3  .   K   | ]}|d          dk    V  dS )r&   -Nr   )r>   os     r!   	<genexpr>zA_RootArgumentParser._format_optional_arguments.<locals>.<genexpr>   s*      !M!M!!A$#+!M!M!M!M!M!Mr    r=   , r   r8   rI   c              3  "   K   | ]
}d | dV  dS )z        r9   Nr   )r>   lines     r!   rj   zA_RootArgumentParser._format_optional_arguments.<locals>.<genexpr>   s.      UUD/t///UUUUUUr    )r   r	   alloption_stringsrZ   rN   nargs_format_metavarmetavarchoicesdestrE   strip
splitlines)r[   rb   rV   rH   prefixoptaction_helps          r!   rY   z._RootArgumentParser._format_optional_argumentsw   sK     
 


9US[))*****


 
	V 
	VFc!M!Mv7L!M!M!MMMMF4-$))Cf6K,L,L"M"MMC|q  sT11L&.&.&+    IIIJJJ%{0b77999{ VUUK<R<R<T<TUUUUUUUUUU
	V 
	Vr    rp   int | str | Nonerr   str | tuple[str, ...] | Noners   Iterable[str] | Nonert   c                   |?|)dd                     t          |                    z   dz   }n|                                }| | S | t          j        k    rd| dS | t          j        k    r.t          |          dk    rd|d          d|d	          d
S d| dS | t          j        k    r| d| dS | t          j        k    rdS | t          j	        k    r| dS d}t          |          )N{rk   }[]   r   z [r&   z ...]]z ...]z...z ...zinvalid nargs value)rZ   sortedupperrF   OPTIONALZERO_OR_MORErO   ONE_OR_MORE	REMAINDERPARSER
ValueError)rp   rr   rs   rt   msgs        r!   rq   z#_RootArgumentParser._format_metavar   s    ?"		&// : ::S@**,,=<h'''!w>>>!h+++7||q  ;71:;;;;;;)7))))h***//////h(((5ho%%#####oor    messager   c                    t          d          }t          j                            |                    | j        |                     t          d          )Nz0{0}: error: {1}
Run '{0} --help' for informationr   )r
   r.   r/   writerK   rL   
SystemExit)r[   r   r   s      r!   errorz_RootArgumentParser.error   sB    DEE
DIw77888mmr    N)r#   r   )rb   rc   rV   r   r#   rd   )
rp   rz   rr   r{   rs   r|   rt   r   r#   r   )r   r   r#   r   )r   r   r   ra   rY   staticmethodrq   r   r   r    r!   r6   r6   F   su        .' .' .' .'`V V V V*    \:     r    r6   c            
        t          dt          d          t          d          dd          } |                     dddt          j        t          d	          
           |                     ddddt          j        t          d          
           |                     t          d                    }|                    dddddt          d                     |                    dddddt          d                     |                    ddddt          d                     |                     d t          j        t          d!          "           | S )#Nsphinxz$   Manage documentation with Sphinx.rJ   F)rL   r3   epilogadd_helpallow_abbrev-V	--version
store_truezShow the version and exit.)rH   defaultrE   z-hz-?z--helpzShow this message and exit.Loggingz-vz	--verbosecount	verbosityr   z$Increase verbosity (can be repeated))rH   rt   r   rE   z-qz--quietstore_constzOnly print errors and warnings.)rH   rt   constrE   z--silentzNo output at allCOMMANDz	<command>)rp   rr   )r6   r
   add_argumentrF   rG   add_argument_groupr   )parserlog_controls     r!   _create_parserr      s    =>>T
 
   F !,--     !-..     ++ByMM::K677     122     "##      ;    
 Mr    r   argvSequence[str]tuple[str, Sequence[str]]c                   t                      }|                    |           }|j        pd^}}|                                }t	                      rt                       nt                       d|v sddh                    |          r8ddlm	} t          j                            d| d           t          d          d	|v s|d	k    r@t          j                            |                                           t          d          |t          vr?t          j                            t!          d
|d                     t          d          ||fS )N)rE   versionr   r   r   )__display_version__sphinx r9   rE   zsphinx: z/ is not a sphinx command. See 'sphinx --help'.
r   )r   
parse_argsr   lowerr   r   r   intersectionr   r   r.   r/   r   r   ra   r"   r
   )r   r   argsr?   command_argvr   s         r!   _parse_commandr      sq   FT""D"&,";)L<%%''L!!  DT;/<<\JJ......
:#6:::;;;mm ~~//
++--...mm9$$
)< ) ) ) 	
 	
 	
 mm%%r    r?   r   "tuple[str, _PARSER_SETUP, _RUNNER]c                    	 t          j        t          |                    }n$# t          $ r d| d}t	          |          d w xY w|j        |j        |j        fS )Nzinvalid command name .)r)   r*   r"   KeyErrorr   r   r   r   )r?   r2   r   s      r!   _load_subcommandr     sn    ($-$;Il<S$T$T ( ( (7l777oo4'( $f&:FJFFs	   " !Ar3   parser_setupargparse.ArgumentParserc                b    t          j        d|  |t           j        d          } ||          S )Nr   F)rL   r3   formatter_classr   )rF   ArgumentParserRawDescriptionHelpFormatter)r?   r3   r   r   s       r!   _create_sub_parserr     sD    
 $%|%% <	  F <r    intc                  t          j        t           j        d           t                       | pt          j        dd          } 	 t          |           \  }}t          |          \  }}}t          |||          }|	                    |          } ||          S # t          $ r}|j        cY d }~S d }~wt          t          f$ r Y dS w xY w)NrI   r&   r   )locale	setlocaleLC_ALLr   r.   r   r   r   r   r   r   code	ExceptionKeyboardInterrupt)	r   cmd_namecmd_argvcmd_descriptionr   runner
cmd_parsercmd_argsexcs	            r!   r   r   '  s    
V]B'''NNN38ABB<D	+D11(1A(1K1K.'/=QQ
((22vh   x()   qqs%   AB 
C	%B1+C	1C	C	__main__)r#   r$   )r#   r6   )r   )r   r   r#   r   )r?   r   r#   r   )r?   r   r3   r   r   r   r#   r   )r   r   r#   r   )+__doc__
__future__r   rF   r)   r   r.   typingr   sphinx._cli.util.colourr   r   r   r   r	   sphinx.localer
   r   collections.abcr   r   r   r   r   r   r   r   r   	Namespacer   r   r   r   r"   r4   r6   r   r   r   r   r   r   r   r   r    r!   <module>r      s    & # " " " " "       



                          + * * * * * * * FFFFFFFFFFFF********'		 !8#:: M     "8#5"6";<G<<<<    H    	    	; 	; 	; 	;g g g g g(1 g g gT9 9 9 9x!& !& !& !& !&HG G G G           " z
*SSUU

 r    