3

V'íc ã@shdZddlZddlmZddlmZddlmZddlm	Z	dZ
dZd	Zd
Z
Gdd„deƒZd
d„ZdS)a
    pygments.sphinxext
    ~~~~~~~~~~~~~~~~~~

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

    :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
éN)Únodes)ÚViewList)Ú	Directive)Únested_parse_with_titlesz
.. module:: %s

%s
%s
zX
.. class:: %s

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

    %s

zA
.. class:: %s

    :Short names: %s
    :Filenames: %s

    %s

z'
.. class:: %s

    :Name: %s

    %s

c@sLeZdZdZdZdZdZdZiZdd„Z	dd„Z
d	d
„Zdd„Zd
d„Z
dS)ÚPygmentsDoczn
    A directive to collect all lexers/formatters/filters and generate
    autoclass directives for them.
    FércCsÀtƒ|_|jddkr |jƒ}nP|jddkr8|jƒ}n8|jddkrP|jƒ}n |jddkrh|jƒ}ntdƒ‚tj	ƒ}t
|jdƒdd	}t|j
||ƒx |jD]}|j
jjjj|ƒq W|jS)
NrÚlexersÚ
formattersÚfiltersZlexers_overviewz,invalid argument for "pygmentsdoc" directiveÚ
Ú)Úsource)ÚsetÚ	filenamesÚ	argumentsÚdocument_lexersÚdocument_formattersÚdocument_filtersÚdocument_lexers_overviewÚ	ExceptionrZcompoundrÚsplitrÚstateÚdocumentÚsettingsZrecord_dependenciesÚaddÚchildren)ÚselfÚoutÚnodeZvlÚfn©r ú6/tmp/pip-build-gk9425m9/Pygments/pygments/sphinxext.pyÚrunEs 



zPygmentsDoc.runc	sjddlm}ddl}g}g‰dd„}xŽt|jƒdd„dD]v\}}|jj|d	ƒ}|j|j}ˆj	||d	|j
ƒd
j|ƒjddƒjd
dƒpŒdd
j|dƒ|d›d|›dœƒq:Wddddg}	‡fdd„|	Dƒ‰‡fdd„‰‡‡fdd„}
|j	|
ƒƒ|j	ˆdddd ƒƒ|j	|
ƒƒx:ˆD]2}|j	ˆ|d|d|dd!|d›d"ƒƒqW|j	|
ƒƒd#j|ƒS)$z¸Generate 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)ÚLEXERSNcSs|rd|›d|›dS|S)Nú`z <z>`_r )ÚnameÚurlr r r!Úformat_linkcsz9PygmentsDoc.document_lexers_overview.<locals>.format_linkcSs|ddjƒS)Nr)Úlower)Úxr r r!Ú<lambda>hsz6PygmentsDoc.document_lexers_overview.<locals>.<lambda>)Úkeyrz, Ú*z\*Ú_ú\ÚNoneéÚ.)r%Ú
extensionsÚaliasesÚclassr%r2r3r4cs"g|]‰t‡fdd„ˆDƒƒ‘qS)cs g|]}|ˆrt|ˆƒ‘qSr )Úlen)Ú.0Úrow)Úcolumnr r!ú
<listcomp>tszCPygmentsDoc.document_lexers_overview.<locals>.<listcomp>.<listcomp>)Úmax)r6)Útable)r8r!r9tsz8PygmentsDoc.document_lexers_overview.<locals>.<listcomp>csJg}x:tˆ|ƒD],\}}|r.|j|j|ƒƒq|jd|ƒqWdj|ƒS)zFormat a table rowú )ÚzipÚappendÚljustÚjoin)ÚcolumnsrÚlÚc)Úcolumn_lengthsr r!Ú	write_rowwsz7PygmentsDoc.document_lexers_overview.<locals>.write_rowcsdd„ˆDƒ}ˆ|ŽS)zWrite a table separator rowcSsg|]}d|‘qS)ú=r )r6rCr r r!r9„szQPygmentsDoc.document_lexers_overview.<locals>.write_seperator.<locals>.<listcomp>r )Úsep)rDrEr r!Úwrite_seperator‚sz=PygmentsDoc.document_lexers_overview.<locals>.write_seperatorÚNamezExtension(s)z
Short name(s)zLexer classz	:class:`~r$r)
Úpygments.lexers._mappingr#Zpygments.lexersÚsortedÚitemsrZfind_lexer_classrZalias_filenamesr>r&r@Úreplace)rr#Zpygmentsrr'Ú	classnameÚdataZ	lexer_clsr2Zcolumn_namesrHr7r )rDr;rEr!rXs:

z$PygmentsDoc.document_lexers_overviewcCs¸ddlm}g}i}i}xþt|jƒdd„dD]æ\}}|d}t|dd|gƒ}|jj|jƒt||ƒ}	|	j	szt
d|ƒ|	j	}
t|
tƒr”|
j
dƒ}
|j|gƒj|dj|d	ƒp²d
dj|dƒjdd
ƒjddƒpÒd
dj|dƒpâd
|
fƒ||kr0|j	}t|tƒr|j
dƒ}|||<q0Wx’t|jƒdd„dD]z\}}||dkrTtd|fƒ‚||jƒdjƒjdƒ}
|jt||
dt|
ƒfƒx|D]}|jt|ƒqWq0Wdj|ƒS)Nr)r#cSs|dS)Nrr )r)r r r!r*™sz-PygmentsDoc.document_lexers.<locals>.<lambda>)r+z&Warning: %s does not have a docstring.Úutf8z, r0r/ér,z\*r-r.écSs|dS)Nrr )r)r r r!r*¯szMissing docstring for %sr1ú-r)rJr#rKrLÚ
__import__rrÚ__file__ÚgetattrÚ__doc__ÚprintÚ
isinstanceÚbytesÚdecodeÚ
setdefaultr>r@rMrÚ
splitlinesÚstripÚrstripÚ	MODULEDOCr5ÚLEXERDOC)rr#rÚmodulesZmoduledocstringsrNrOÚmoduleÚmodÚclsÚ	docstringZmoddocrÚheadingr r r!r”sB 


 

zPygmentsDoc.document_lexersc
CsÆddlm}g}xªt|jƒdd„dD]’\}}|d}t|dd|gƒ}|jj|jƒt||ƒ}|j	}t
|tƒrx|jdƒ}|j
}	|jt|	dj|dƒp–d	dj|d
ƒjddƒp®d	|fƒq&Wd
j|ƒS)Nr)Ú
FORMATTERScSs|dS)Nrr )r)r r r!r*½sz1PygmentsDoc.document_formatters.<locals>.<lambda>)r+rPz, r0r/rQr,z\*r)Zpygments.formattersrhrKrLrTrrrUrVrWrYrZr[Ú__name__r>ÚFMTERDOCr@rM)
rrhrrNrOrcrdrerfrgr r r!r¹s


zPygmentsDoc.document_formatterscCsvddlm}g}xZ|jƒD]N\}}|jjtj|jjƒ|j	}t
|tƒrR|jdƒ}|j
t|j||fƒqWdj|ƒS)Nr)ÚFILTERSrPr)Zpygments.filtersrkrLrrÚsysrbÚ
__module__rUrWrYrZr[r>Ú	FILTERDOCrir@)rrkrr%rerfr r r!rËs

zPygmentsDoc.document_filtersN)rirmÚ__qualname__rWZhas_contentZrequired_argumentsZoptional_argumentsZfinal_argument_whitespaceZoption_specr"rrrrr r r r!r:s<%rcCs|jdtƒdS)NZpygmentsdoc)Z
add_directiver)Zappr r r!ÚsetupØsrp)rWrlZdocutilsrZdocutils.statemachinerZdocutils.parsers.rstrZsphinx.util.nodesrr`rarjrnrrpr r r r!Ú<module>
s