o
    =g-                     @   sh   d 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Z
dZd	Zd
ZG dd deZdd ZdS )a  
    pygments.sphinxext
    ~~~~~~~~~~~~~~~~~~

    Sphinx extension to generate automatic documentation of lexers,
    formatters and filters.

    :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)nodes)ViewList)	Directive)nested_parse_with_titlesz
.. module:: %s

%s
%s
z`
.. class:: %s

    :Short names: %s
    :Filenames:   %s
    :MIME types:  %s

    %s

    %s

zA
.. class:: %s

    :Short names: %s
    :Filenames: %s

    %s

z'
.. class:: %s

    :Name: %s

    %s

c                   @   sL   e Zd ZdZdZdZdZdZi Zdd Z	dd Z
d	d
 Zdd Zdd ZdS )PygmentsDoczn
    A directive to collect all lexers/formatters/filters and generate
    autoclass directives for them.
    F   r   c                 C   s   t  | _| jd dkr|  }n(| jd dkr|  }n| jd dkr(|  }n| jd dkr4|  }ntdt	 }t
|ddd	}t| j|| | jD ]}| jjjj| qO|jS )
Nr   lexers
formattersfilterslexers_overviewz,invalid argument for "pygmentsdoc" directive
 )source)set	filenames	argumentsdocument_lexersdocument_formattersdocument_filtersdocument_lexers_overview	Exceptionr   compoundr   splitr   statedocumentsettingsrecord_dependenciesaddchildren)selfoutnodevlfn r$   Q/var/www/html/venv/lib/python3.10/site-packages/pip/_vendor/pygments/sphinxext.pyrunG   s    




zPygmentsDoc.runc              
      s\  ddl m} ddlm} g }g dd }t| dd dD ]9\}}||d	 }|j|j }||d	 |j	d

|ddddpEdd

|d |d  d| d qg d}	fdd|	D   fdd fdd}
||
  |dddd ||
  D ]}||d |d |d d |d!  d" q||
  d#
|S )$zGenerate a tabular overview of all lexers.

        The columns are the lexer name, the extensions handled by this lexer
        (or "None"), the aliases and a link to the lexer class.r   LEXERS)find_lexer_classc                 S   s   |rd|  d| dS | S )N`z <z>`_r$   )nameurlr$   r$   r%   format_linke   s   z9PygmentsDoc.document_lexers_overview.<locals>.format_linkc                 S   s   | d d   S )Nr   )lowerxr$   r$   r%   <lambda>j   s    z6PygmentsDoc.document_lexers_overview.<locals>.<lambda>keyr   , *\*_\None   .)r+   
extensionsaliasesclassc                    s"   g | ] t  fd dD qS )c                    s    g | ]}|  rt |  qS r$   )len).0rowcolumnr$   r%   
<listcomp>v   s     zCPygmentsDoc.document_lexers_overview.<locals>.<listcomp>.<listcomp>)max)r@   )tablerB   r%   rD   v   s    z8PygmentsDoc.document_lexers_overview.<locals>.<listcomp>c                     sF   g }t  | D ]\}}|r||| q|d|  qd|S )zFormat a table row )zipappendljustjoin)columnsr    lengthcol)column_lengthsr$   r%   	write_rowy   s   
z7PygmentsDoc.document_lexers_overview.<locals>.write_rowc                     s   dd  D } |  S )zWrite a table separator rowc                 S   s   g | ]}d | qS )=r$   )r@   cr$   r$   r%   rD      s    zQPygmentsDoc.document_lexers_overview.<locals>.write_seperator.<locals>.<listcomp>r$   )sep)rO   rP   r$   r%   write_seperator   s   z=PygmentsDoc.document_lexers_overview.<locals>.write_seperatorNamezExtension(s)zShort name(s)zLexer classr+   r<   r=   z	:class:`~r>   r*   r   )$pip._vendor.pygments.lexers._mappingr(   pip._vendor.pygments.lexersr)   sorteditemsr   alias_filenamesrI   r,   rK   replace)r   r(   r)   r    r-   	classnamedata	lexer_clsr<   column_namesrT   rA   r$   )rO   rF   rP   r%   r   Z   s@   


z$PygmentsDoc.document_lexers_overviewc              
   C   s~  ddl m} ddlm} dd l}dd l}g }i }i }t| dd dD ]\}}	|	d }
t|
d d |g}| j	
|j t||}|jsKtd| d |j}t|trX|d	}t|d
d }|r|||jjd d | }|jdd}|std| d| |	d r|	d d }|d7 }|d| d7 }| D ]
}|d| d7 }q|jrd|j }nd}||
g |d|	d pdd|	d ddddpdd|	d  pd||f |
|vr|j}t|tr|d	}|||
< q$t| d!d dD ]:\}
}||
 d u rtd"|
 ||
  d   d#}|t|
|d$t | f  |D ]
}	|t!|	  q.qd|S )%Nr   r'   )pygmentsc                 S      | d S Nr   r$   r/   r$   r$   r%   r1          z-PygmentsDoc.document_lexers.<locals>.<lambda>r2   z	Warning: z does not have a docstring.utf8_exampletestsexamplefileszutf-8)encodingzEmpty example file 'z' for lexer r:   z

    .. admonition:: Example
z
      .. code-block:: z

z
          r   z.. versionadded:: r   r4   r9      r5   r6   r7   r8      c                 S   ra   rb   r$   r/   r$   r$   r%   r1      rc   zMissing docstring for r;   -)"rV   r(   pip._vendorr`   inspectpathlibrX   rY   
__import__r   r   __file__getattr__doc__print
isinstancebytesdecodePath
getabsfileparent	read_textr   
splitlinesversion_added
setdefaultrI   rK   r[   striprstrip	MODULEDOCr?   LEXERDOC)r   r(   r`   rm   rn   r    modulesmoduledocstringsr\   r]   modulemodcls	docstringexample_filepcontent
lexer_namelineversion_linemoddocr   headingr$   r$   r%   r      s   


 


zPygmentsDoc.document_lexersc           
   
   C   s   ddl m} g }t| dd dD ]I\}}|d }t|d d |g}| j|j t||}|j	}t
|tr;|d}|j}	|t|	d|d pJd	d|d
 ddpVd	|f  qd|S )Nr   )
FORMATTERSc                 S   ra   rb   r$   r/   r$   r$   r%   r1      rc   z1PygmentsDoc.document_formatters.<locals>.<lambda>r2   rd   r4   r:   r9   ri   r5   r6   r   )pip._vendor.pygments.formattersr   rX   rY   ro   r   r   rp   rq   rr   rt   ru   rv   __name__rI   FMTERDOCrK   r[   )
r   r   r    r\   r]   r   r   r   r   r   r$   r$   r%   r      s    




zPygmentsDoc.document_formattersc                 C   sr   ddl m} g }| D ]'\}}| jtj|j j |j	}t
|tr(|d}|t|j||f  qd|S )Nr   )FILTERSrd   r   )pip._vendor.pygments.filtersr   rY   r   r   sysr   
__module__rp   rr   rt   ru   rv   rI   	FILTERDOCr   rK   )r   r   r    r+   r   r   r$   r$   r%   r      s   


zPygmentsDoc.document_filtersN)r   r   __qualname__rr   has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespaceoption_specr&   r   r   r   r   r$   r$   r$   r%   r   <   s    <Ar   c                 C   s   |  dt d S )Npygmentsdoc)add_directiver   )appr$   r$   r%   setup   s   r   )rr   r   docutilsr   docutils.statemachiner   docutils.parsers.rstr   sphinx.util.nodesr   r   r   r   r   r   r   r$   r$   r$   r%   <module>   s    

 ;