o $a @sdZddlZddlZddlZddlmZmZmZddlm Z ddl m Z m Z e e jdZdedeeeeefffd d Zdedeeeffd d ZddedededeefddZdedeefddZdS)z sphinx.util.docstrings ~~~~~~~~~~~~~~~~~~~~~~ Utilities for docstring processing. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N)DictListTuple)Body)RemovedInSphinx50WarningRemovedInSphinx60Warning field_markersreturncCsd}i}g}|s ||fSt|D]N}|dkr d}||qt|}|rW|sW|ddddd}|drQ|dd}||d||<q||qd }||qd ||fS) z,Separate docstring into metadata and others.FN:rzmeta T ) prepare_docstringstripappendfield_list_item_rematchgroupsplit startswithendjoin)r in_other_elementmetadatalineslinematched field_namenamer!8/usr/lib/python3/dist-packages/sphinx/util/docstrings.pyseparate_metadatas&       r#cCs tjdtddt|\}}|S)Nz!extract_metadata() is deprecated. stacklevel)warningswarnrr#)r docstringrr!r!r"extract_metadata4s  r*ignoretabsizec Cs|durd}ntjdtdd||}tj}||dD]}t|}|r4t||}t ||}qt |D]}|t|krI||||<q9|tjkrct |t|D] }|||d||<qV|rt|dst| d|rt|dri|r|dr| d|S) aConvert a docstring into lines of parseable reST. Remove common leading indentation, where the indentation of a given number of lines (usually just one) is ignored. Return the docstring as a list of lines usable for inserting into a docutils ViewList (used as argument of nested_parse().) An empty line is added to act as a separator between this docstring and following content. Nr z;The 'ignore' argument to prepare_docstring() is deprecated.r$r%rr ) r'r(r expandtabs splitlinessysmaxsizelenlstripminrangepopr) r r,r-rmarginrcontentindentir!r!r"r<s4           rcCszg}dd|D}|D] }|dr/|dd}|r*|ddkr*|dd}||q|r;|d r;|d |S) zExtract documentation comment lines (starting with #:) and return them as a list of lines. Returns an empty list if there is no documentation. cSsg|]}|qSr!)r).0rr!r!r" hsz&prepare_commentdoc..z#:r$Nr r r.r )r/r0rr)r resultrrr!r!r"prepare_commentdoccs      r@)Nr+)__doc__rer1r'typingrrrdocutils.parsers.rst.statesrsphinx.deprecationrrcompilepatternsrstrr#r*intrr@r!r!r!r"s  " '