o oa @sdZddlZddlZddlmZmZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZddlmZddlZddlmZddlmZmZdd lmZm Z dd l!m"Z"dd l#m$Z$m%Z%m&Z&m'Z'dd l(m)Z)m*Z*m+Z+dd l,m-Z-m.Z.ddl/m0Z0m1Z1ddl2mZm3Z3ddl4m5Z5m6Z6ddl7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@ddl=mAZBe rddlCmDZDe3EeFZGeHeHjIZJeKdejLZMeKdZNde de fddZOGdddZPGdddZQePZReQZSeTZUeTZVeTZWde deeTeeXffd d!ZYde deeTeeXffd"d#ZZde deeTeeXffd$d%Z[de deeTeeXffd&d'Z\de deeXfd(d)Z]de deeXfd*d+Z^eTZ_de de fd,d-Z`de deafd.d/Zbd0e ddfd1d2Zcd0e ddfd3d4Zddd5eed6eed7eXde fd8d9Zf : :dd;eXd7eeXdd?ZgGd@dAdAehZiGdBdCdCejZkeeekeeeXe ffZlGdDdEdEZmGdFdGdGemZnGdHdIdIemZoGdJdKdKemZpGdLdMdMZqGdNdOdOeqZrGdPdQdQeqeoZsGdRdSdSesZtdTgZudUgZvGdVdWdWeqeoZwGdXdYdYewZxGdZd[d[ZyGd\d]d]eyZzGd^d_d_eyZ{Gd`dadaeyZ|GdbdcdceyZ}Gdddedeeze{e|e}eoZ~Gdfdgdge~ZGdhdidieqepZGdjdkdkeyZGdldmdmeyZGdndodoeyZGdpdqdqeyZGdrdsdseze{ee|eeeerep ZGdtduduerepZGdvdwdweZdxede eXeemffdydzZdxed{e d|eXd}e de f d~dZdxededdfddZddlmZddlmZddlmZddlmZddlmZddlmZddlmZdxede eXe ffddZdS)ap sphinx.ext.autodoc ~~~~~~~~~~~~~~~~~~ Automatically insert docstrings for functions, classes or whole modules into the doctree, thus avoiding duplication between docstrings and documentation for those who like elaborate docstrings. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N) Parameter Signature) ModuleType) TYPE_CHECKINGAnyCallableDictIteratorListOptionalSequenceSetTupleTypeTypeVarUnion) StringList)Sphinx)ENUMConfig)RemovedInSphinx50WarningRemovedInSphinx60Warning)BuildEnvironment)get_class_membersget_object_members import_module import_object)ismockmock undecorate)___)ModuleAnalyzer PycodeError)inspectlogging)prepare_docstringseparate_metadata)evaluate_signaturegetdocobject_description safe_getattrstringify_signature) OptionSpecget_type_hintsrestify) stringify)DocumenterBridgeaQ^ ([\w.]+::)? # explicit module name ([\w.]+\.)? # module and/or class name(s) (\w+) \s* # thing name (?: \((.*)\) # optional: arguments (?:\s* -> \s* (.*))? # return annotation )? $ # and nothing more z ^__\S+__$xreturncCs|SN)r2r5r5=/usr/lib/python3/dist-packages/sphinx/ext/autodoc/__init__.pyidentity?r7c@s4eZdZdZdedefddZdeddfddZdS) _Allz;A special value for :*-members: that matches to any member.itemr3cCdSNTr5selfr:r5r5r6 __contains__Fr8z_All.__contains__NcCdSr4r5r=r5r5r6appendIr8z _All.append)__name__ __module__ __qualname____doc__rboolr?rAr5r5r5r6r9Csr9c@s"eZdZdZdedefddZdS)_EmptyzGA special value for :exclude-members: that never matches to any member.r:r3cCr;NFr5r=r5r5r6r?Pr8z_Empty.__contains__N)rBrCrDrErrFr?r5r5r5r6rGMsrGargcCs,|dvrtS|dur dSdd|dDS)8Used to convert the :members: option to auto directives.r<FNcSsg|] }|r|qSr5strip.0r2r5r5r6 bz"members_option..,)ALLsplitrIr5r5r6members_option[s rUcCs0tjdtdd|durtSdd|dDS)rJz#members_set_option() is deprecated. stacklevelNcSh|] }|r|qSr5rKrMr5r5r6 krPz%members_set_option..rQ)warningswarnrrRrSrTr5r5r6members_set_optiones r]cCs |dvrtSdd|dDS)z-Used to convert the :exclude-members: option.r<cSrYr5rKrMr5r5r6rZrrPz)exclude_members_option..rQ)EMPTYrSrTr5r5r6exclude_members_optionnsr_cCs|dvrdS|S)rJr<objectr5rTr5r5r6inherited_members_optionusracCs(|dvrdS|dvr |Sttd|)rJr<N) alphabeticalbysource groupwisez)invalid value for member-order option: %s ValueErrorr!rTr5r5r6member_order_option}s rgcCs|dvr|Sttd|)zDUsed to convert the :class-doc-from: option to autoclass directives.)bothclassinitz+invalid value for class-doc-from option: %srerTr5r5r6class_doc_from_optionsrkcCs|dvrtS|S)Nr<)SUPPRESSrTr5r5r6annotation_optionsrmcCr;)znUsed to convert flag options to auto directives. (Instead of directives.flag(), which returns None). Tr5rTr5r5r6 bool_optionrnoptionscCstjdtddd|vr>|dtur@|dturdS|dr6|dD]}||dvr3|d|q$dS|d|d<dSdSdS)z3Merge :special-members: option to :members: option.z-merge_special_members_option() is deprecated.rVrWspecial-membersmembersN)r[r\rrRgetrA)rpmemberr5r5r6merge_special_members_options   rucCsd|dtur dS|dg}dD]}||vr/||tdfvr/||D] }||vr.||q#qdS)z1Merge :*-members: option to the :members: option.rrN>private-membersrq)rsrR setdefaultrA)rprrkeyrtr5r5r6merge_members_options   ryprepostwhatcs6dtdtdtdtdtdttddffd d }|S) aReturn a listener that removes the first *pre* and last *post* lines of every docstring. If *what* is a sequence of strings, only docstrings of a type in *what* will be processed. Use like this (e.g. in the ``setup()`` function of :file:`conf.py`):: from sphinx.ext.autodoc import cut_lines app.connect('autodoc-process-docstring', cut_lines(4, what=['module'])) This can (and should) be used in place of :confval:`automodule_skip_lines`. appwhat_nameobjrplinesr3Ncsbr|vrdS|d=r |r|ds|d| d=|r-|dr/|ddSdSdS)N)poprA)r}r~rrrprr{rzr|r5r6processs      zcut_lines..process)rstrrr )rzr{r|rr5rr6 cut_liness  rFmarker keepemptyexcludecsBt|dtdtdtdtdtdttddffd d }|S) anReturn a listener that either keeps, or if *exclude* is True excludes, lines between lines that match the *marker* regular expression. If no line matches, the resulting docstring would be empty, so no change will be made unless *keepempty* is true. If *what* is a sequence of strings, only docstrings of a type in *what* will be processed. r}r~rrrprr3Nc sr|vrdSd} }|dd}t|D]&\} } |r(|| ||d7}| r=| }|r=|| ||d7}q|sHsH||dd<|rU|drW|ddSdSdS)Nrrr) enumeratermatchrA) r}r~rrrprdeleteddelete orig_linesilinerr marker_rer|r5r6rs(     zbetween..process)recompilerrrr )rr|rrrr5rr6betweens rcs4eZdZdZdfdd ZdedefddZZS) Optionsz>A dict/attribute hybrid that returns None on nonexisting keys.r3csttSr4)rsupercopyr> __class__r5r6rsz Options.copyrcCs(z ||ddWStyYdSw)Nr -)replaceKeyError)r>rr5r5r6 __getattr__s  zOptions.__getattr__)r3r) rBrCrDrErrrr __classcell__r5r5rr6rsrc s^eZdZdZdedededeffdd Z  ddeded eed ed eddf d dZ Z S) ObjectMembera}A member of object. This is used for the result of `Documenter.get_object_members()` to represent each member of the object. .. Note:: An instance of this class behaves as a tuple of (name, object) for compatibility to old Sphinx. The behavior will be dropped in the future. Therefore extensions should not use the tuple interface. rrkwargsr3c st|||fSr4)r__new__)clsrrrrr5r6rszObjectMember.__new__NF docstringclass_skippedcCs"||_||_||_||_||_dSr4)rBr`rrr)r>rrrrrr5r5r6__init__s  zObjectMember.__init__)NNF) rBrCrDrErrrr rFrrr5r5rr6rs rc @seZdZUdZdZdZdZdZdZde iZ e e d<de d ed e d e fd d Zede dedede d ef ddZdZddd eded dfddZed eeedffddZdededed dfd d!Zd"ed#e d$ed%e d eeeeff d&d'Zd efd(d)Zd[d*ed efd+d,Zd efd-d.Zd efd/d0Z d1e d efd2d3Z!d efd4d5Z"d1e d efd6d7Z#d1e d efd8d9Z$d:ed dfd;d<Z%d\d=ed e&eeefd>d?Z'd@eeed e(efdAdBZ)d efdCdDZ*d[dEe&e+dFed dfdGdHZ,dIed eee-ffdJdKZ.dLe-dIed eeee effdMdNZ/d[dOed dfdPdQZ0dReedefdSed eedeffdTdUZ1  d]dEe&e+dVedWedOed df dXdYZ2dS)^ Documenterae A Documenter knows how to autodocument a single object type. When registered with the AutoDirective, it will be used to document objects of that type when needed by autodoc. Its *objtype* attribute selects what auto directive it is assigned to (the directive name is 'auto' + objtype), and what directive it generates by default, though that can be overridden by an attribute called *directivetype*. A Documenter has an *option_spec* that works like a docutils directive's; in fact, it will be used to parse an auto directive's options that matches the Documenter. r` rFnoindex option_specrrdefargsr3cGst|jj||g|RS)z5getattr() override for types such as Zope interfaces.)autodoc_attrgetterenvr})r>rrrr5r5r6get_attrJszDocumenter.get_attrrt membernameisattrparentcCtd)z?Called to see if a member can be documented by this Documenter.!must be implemented in subclassesNotImplementedErrorrrtrrrr5r5r6can_document_memberNszDocumenter.can_document_memberr directiver1indentNcCsl||_|jj|_|j|_|j|_||_||_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_dSr4)rrconfiggenoptrprrmodnamemoduleobjpathfullnameargsretannr` object_nameranalyzer)r>rrrr5r5r6rTs   zDocumenter.__init__cCs |jjjjS)%Returns registered Documenter classes)rr}registry documentersrr5r5r6rms zDocumenter.documentersrsourcelinenocGsF|r|jjj|j||g|RdS|jjjd|g|RdS)z0Append one line of generated reST to the output.rN)rLrresultrAr)r>rrrr5r5r6add_liners"zDocumenter.add_linerparentspathbasecCr)a@Resolve the module and name of the object to document given by the arguments and the current module/class. Must return a pair of the module name and a chain of attributes; for example, it would return ``('zipfile', ['ZipFile', 'open'])`` for the ``zipfile.ZipFile.open`` method. rrr>rrrrr5r5r6 resolve_nameys zDocumenter.resolve_namec Cszt|j}|\}}}}}Wnty*tjtd|j|jfddYdSw|durB|dd}|r?| d dng}nd}g}t |j j |||||\|_|_Wdn1scwY|jsmdS||_||_|jpwd|jrdd|jnd|_d S) zDetermine what module to import and what attribute to document. Returns True and sets *self.modname*, *self.objpath*, *self.fullname*, *self.args* and *self.retann* if parsing and resolving was successful. z!invalid signature for auto%s (%r)autodoctypeFN.rT) py_ext_sig_rerrgroupsAttributeErrorloggerwarningr!objtyperstriprSrrautodoc_mock_importsrrrrrjoinr) r>matchedexplicit_modnamerrrrrrr5r5r6 parse_names2   zDocumenter.parse_name raiseerrorc Cst|jj[z-t|j|j|j|j|jjd}|\|_ |_ |_ |_ t |j r,t|j |_ WWddSty`}z |r?tj|jdddd|jWYd}~WddSd}~ww1sdwYdS) zImport the object given by *self.modname* and *self.objpath* and set it as *self.object*. Returns True if successful, False if an error occurred.  attrgetterwarningiserrorNTrrrrsubtypeF)rrrrrrrrautodoc_warningiserrorrrrr`rr ImportErrorrrrr note_rereadr>rretexcr5r5r6rs*      zDocumenter.import_objectcCs||jddp |jS)zGet the real module name of an object to document. It can differ from the name of the module through which the object was imported. rCN)rr`rrr5r5r6get_real_modnameszDocumenter.get_real_modnamecCs<|jjrdSt|j}||dd}|r||jkrdSdS)z`Check if *self.object* is really defined in the module given by *self.modname*. TrCNF)rpimported_membersr$ unpartialr`rr)r>subjectrr5r5r6 check_modules zDocumenter.check_modulercKr;)z}Format the argument signature of *self.object*. Should return None if the object does not have a signature. Nr5r>rr5r5r6 format_argsszDocumenter.format_argscCsd|jp|jS)zFormat the name of *self.object*. This normally should be something that can be parsed by the generated directive, but doesn't need to be (Sphinx will display it unparsed then). r)rrrrr5r5r6 format_names zDocumenter.format_namecKs8|rz |jdi|WStyY|Sw|SNr5)r TypeErrorrr5r5r6_call_format_argss zDocumenter._call_format_argsc Ks|jdurd|j}|j}nAz d}|jd i|}|r-td|}|r-|d}|d}Wn tyN}ztjt d|j |ddd}WYd}~nd}~ww|j j d |j|j |j|j||}|rf|\}}|duru||rrd |Sd Sd S) zFormat the signature (arguments and return annotation) of the object. Let the user process it via the ``autodoc-process-signature`` event. Nz(%s)z^(\(.*\))\s+->\s+(.*)$rrVz+error while formatting arguments for %s: %srrautodoc-process-signaturez -> %srr5)rrrrrgroup Exceptionrrr!rreventsemit_firstresultrr`rp)r>rrrrrrr5r5r6format_signatures8        zDocumenter.format_signaturesigc Cst|dd}t|d|j}|}|}d||f}t|dD]\}}|d|||f||dkr;dt|}q"|jj rF|d ||j rT|d |j |d Sd S) z>Add the directive header and options to the generated content.domainpy directivetypez .. %s:%s::  z%s%s%sr z :noindex:z :module: %sN) getattrrrget_sourcenamerrSrlenrprrr) r>rrrr sourcenameprefixrsig_liner5r5r6add_directive_headers"    zDocumenter.add_directive_headerignorecCs`|durtjd|jjtddt|j|j|jj |j |j }|r.|j j jjj}t|||gSgS)zDecode and return lines of the docstring(s) for the object. When it returns None, autodoc-process-docstring will not be called for this object. Nrrrr5r5r6get_doc+szDocumenter.get_doc docstringsc cs\|D](}|jjr&|jjd|j|j|j|j||r&|ddkr&|d|EdHqdS)z7Let the user process the docstrings before adding them.autodoc-process-docstringrrN)rr}emitrrr`rprA)r>rdocstringlinesr5r5r6 process_doc<s    zDocumenter.process_doccCsZt|jddrt|jddrd|jj|jjf}n|j}|jr)d|jj|fSd|S)NrCrDz%s.%sz%s:docstring of %szdocstring of %s)r$r+r`rCrDrrsrcname)r>rr5r5r6r KszDocumenter.get_sourcename more_content no_docstringc Cs|rtjd|jjtdd|}|jrL|j}|jrLd |jdd|jdf}||vrLd}t ||g}t | |D] \}}| |||q@|sq|}|durWn|s^|gt | |D] \}}| |||qe|rt|j|jD]\}} | || d| d qzdSdS) z>Add content from docstrings, attribute documentation and user.z>The 'no_docstring' argument to %s.add_content() is deprecated.rVrWrNrTrr)r[r\rrBrr rfind_attr_docsrrlistrrrrrAzipdataitems) r>rr r  attr_docsrxrrrsrcr5r5r6 add_contentYs:  zDocumenter.add_contentwant_allcCstdtt|j|j|j|j}|sE|jj sdgfSg}|jj D]}||vr2| |||j fq!t j td||jfddq!d|fS|jjrTddd|DfSddd|DfS) a+Return `(members_check_module, members)` where `members` is a list of `(membername, member)` pairs of the members of *self.object*. If *want_all* is True, return all members. Else, only return those members given by *self.options.members* (which may also be None). zVThe implementation of Documenter.get_object_members() will be removed from Sphinx-6.0.F!missing attribute %s in object %srrcSsg|]}|j|jfqSr5)rvaluerNmr5r5r6rOz1Documenter.get_object_members..cSsg|] }|jr|j|jfqSr5)directly_definedrr+r,r5r5r6rOs)r[r\rrr`rrrrprrrAr+rrr!rinherited_membersvaluesr>r)rrselectedrr5r5r6rs(  zDocumenter.get_object_membersrrc sdtdtdtffdd }g}dj}jrj}ni}|D]Z}|\}} | tur0d} n ||f|vr9d} nd} t| j j j j |} t | tsNd } | d d } | rd | d d } | | krdd } t |tro|jro|j} t| \} }t| }d |vrd}n d |vrd}n|d}d}t| rnjjr|jjvrd}n|rt|rʈjjr|jjvr|d krd}no|||rd}ng|pňjj}n`d}n]||f|vr|r|rjjd urd}nJ|jjv}nCd}n@|r|r|sjjr jjd urd}n*|||rd}n!|jjv}nd}njjtur |||r d}n|p&jj}t |tr3|jr3d}jjrrzjjdj || | j}|d urP| }Wn t!yq}zt"j#t$d| |ddd}WYd }~nd }~ww|r}|%|| | fq"|S)aFilter the given member list. Members are skipped if - they are private (except if given explicitly or the private-members option is set) - they are special methods (except if given explicitly or the special-members option is set) - they are undocumented (except if the undoc-members option is set) The user can override the skipping decision by connecting to the ``autodoc-skip-member`` event. rrr3cs~tjr=jjD]2}|jjjkr|jkrdS||jvr#dS||divr/dSt |t r<|j |ur<dSq dS)NTF__annotations__) r$isclassr`__mro__rBrpr0__dict__r isinstancerr)rrrrr5r6is_filtered_inherited_members   z?Documenter.filter_members..is_filtered_inherited_memberrTFNrrEprivatepublicr autodoc-skip-memberzXautodoc: failed to determine %r to be documented, the following exception was raised: %srr)&rrrFrrrr! INSTANCEATTRr)rrrr`r8rrr' startswithrrpexclude_membersspecial_member_rerspecial_members undoc_membersprivate_membersrrrRrrr}rrrrrr!rA)r>rrr)r9r namespacer&rrrtrdocrcls_docmetadatahas_doc isprivatekeep skip_userrr5rr6filter_memberss                 zDocumenter.filter_members all_membersc s8jjjd<jrjdjjd<|pjjpjjtu}|\}}g} ||D]>\fddj D}|sEq.|j dddjd d jg}|d j|j}||fq.jjptjj} || }|D]\}|jd j|o d q}djjd<djjd<dS)zGenerate reST for member documentation. If *all_members* is True, document all members, else those given by *self.options.members*. autodoc:moduler autodoc:classcs g|] }|r|qSr5)rrNrrrtmnamer>r5r6rOKs z/Documenter.document_members..cSs|jSr4priority)rr5r5r6Qsz-Documenter.document_members..rx::rrT)rM real_modnamerN)rr temp_datarrpr0rrrRrrLrr1sortrrrrA member_orderrautodoc_member_order sort_membersgeneraterX) r>rMr)members_check_modulerrmemberdocumentersclasses full_mname documenterr[r5rQr6document_members7s6    zDocumenter.document_membersrordercsz|dkr|jddd|S|dkr3|jr0|jjdtttfdtffdd }|j|d|S |S|jd dd|S) zSort the given member list.rdcSs|dj|djfSNr)r[rer5r5r6rUiz)Documenter.sort_members..rVrcentryr3cs$|djdd}|tSNrrWr)rrSrsr )rjrtagorderr5r6keyfuncosz(Documenter.sort_members..keyfunccS |djSrfrrgr5r5r6rUy )rZrrmrrrFintr>rrernr5rlr6r]ds  zDocumenter.sort_membersrXrc Cs|stjtd|jdddS|sdS|}|p||_zt |j|_ |j Wn.t y]}z"t d|d|_ t|jdrS|jjrS|jj|jjWYd}~nd}~ww|jj|j j|j|krzt |}|jj|jWn t yYnwt|pgg}t|jr|stjtd|jdd|r|sdS|} |d| z|} Wnty}ztjtd |j|ddWYd}~dSd}~ww|| |d| |j |j!7_ |"||#|dS) aGenerate reST for the object given by *self.name*, and possibly for its members. If *more_content* is given, include that content. If *real_modname* is given, use that module name to find attribute docs. If *check_module* is True, only generate if the object is defined in the module name it is imported from. If *all_members* is True, document all members. zdon't know which module to import for autodocumenting %r (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)rrNz$[autodoc] module analyzer failed: %s__file__zA mocked object is detected: %rrz+error while formatting signature for %s: %s)$rrrr!rrrrXr" for_modulerr!r#debughasattrrrtrrecord_dependenciesaddrsumrrr`rr rrrrrrcontent_indentr(rd) r>rrXrrM guess_modnamerrrr rr5r5r6r^}sl             zDocumenter.generate)rFr4NNFF)3rBrCrDrErr{rTr[titles_allowedrnrr-r4rrr classmethodrFrrpropertyrrrrrrrr rrrrrrrrrrr rr rr rr( ObjectMembersrrLrdr]r^r5r5r5r6r+sp     %   #  +  - rcsLeZdZUdZdZdZdZeeee ee e ee e eeeedZ eed<dedd ffd d Zed ed edededef ddZdededededeeeeff ddZdeffdd Zd+dedeffdd Zdedd fdd Zdeeeffd!d"Zd#edeeeffd$d%Z d&eed'efd(edeed'efffd)d* Z!Z"S),ModuleDocumenterz6 Specialized Documenter subclass for modules. rrT)rr undoc-membersrinherited-membersshow-inheritancesynopsisplatform deprecated member-orderexclude-membersrvrqzimported-memberszignore-module-allrrr3Ncs tj|t|jd|_dSr4)rrryrp__all__r>rrr5r6rs   zModuleDocumenter.__init__rtrrrcCr;rHr5rr5r5r6rroz$ModuleDocumenter.can_document_memberrrrrcCs*|dur tjtddd|pd|gfS)Nz*"::" in automodule name doesn't make senserrr)rrr!rr5r5r6rs  zModuleDocumenter.resolve_namecs2t}|js |jrtjtd|jdd|S)Nz@signature arguments or return annotation given for automodule %srr)rrrrrrr!r)r>rrr5r6rs   zModuleDocumenter.parse_nameFrc sxt|}z|jjst|j|_W|SW|Sty;}zt j t d|j d|j fddWYd}~|Sd}~ww)NzN__all__ should be a list of strings, not %r (in module %s) -- ignoring __all__rrr)rrrpignore_module_allr$getallr`rrfrrr!rrrrr5r6rs  zModuleDocumenter.import_objectrcCsht|||}|jjr|d|jj||jjr&|d|jj||jjr2|d|dSdS)Nz :synopsis: z :platform: z :deprecated:)rrr rprrrrr>rr r5r5r6rs z%ModuleDocumenter.add_directive_headerc Cs|jr|jj}ni}i}t|jD]0}z%t|j|d}t|r#t|}|d|fg}t||d |d||<Wqt yAYqwt |jD]}||vrb|d|fg}t|t d |d||<qH|S)zGet members of target module.Nrr)r)rr&dirr`r+rrrsrrrr$getannotationsr=)r>r&rrrr+rr5r5r6get_module_members"s,   z#ModuleDocumenter.get_module_membersr)cCs|}|r+|jdurdt|fS|D] }|j|jvr"d|_qdt|fS|jjp0g}g}|D] }||vrC|||q5t j t dt |j dd|fddq5d|fS)NTFzHmissing attribute mentioned in :members: option: module %s, attribute %srBz???rr)rrr"r1rBrrprrrArrr!r+r`)r>r)rrrt memberlistrrr5r5r6r=s(     z#ModuleDocumenter.get_object_membersrrrecsZ|dkr&jr&|jddddtttfdtffdd }|j|d|St||S) NrccSrorfrprgr5r5r6rU[rqz/ModuleDocumenter.sort_members..rVrjr3cs:|djdd}jr|jvrj|StjSrk)rrSrindexr )rjrrr5r6rn^s  z.ModuleDocumenter.sort_members..keyfunc)rrZrrrFrrrr]rsrrr6r]Ws  zModuleDocumenter.sort_membersr})#rBrCrDrErr{rrUrnrar7rgr_rr-r4rrrrrFrrr rrrrrrrrrr]rr5r5rr6rs>     rc @:eZdZdZdededededeeeeff ddZd S) ModuleLevelDocumenterzo Specialized Documenter subclass for objects on module level (functions, classes, data/constants). rrrrr3cCsF|dur|r |d}n|jjd}|s|jjd}|||gfS)NrrN py:module)rrrYrs ref_contextrr5r5r6rps z"ModuleLevelDocumenter.resolve_nameN rBrCrDrErrrr rr5r5r5r6rk rc @r) ClassLevelDocumenterz_ Specialized Documenter subclass for objects on class level (methods, attributes). rrrrr3cCs|durE|r |d}nd}|jjd}|dur |jjd}|dur(dgfS|d\}}}|g}|s<|jjd}|sE|jjd}|||gfS)NrrOzpy:classrNr)rrrYrsr rpartition)r>rrrrmod_clsseprr5r5r6rs  z!ClassLevelDocumenter.resolve_nameNrr5r5r5r6rrrcseZdZUdZdZeeeed<dZeeed<de eeffddZ dde deeeffd d Z d e deffd d ZZS)DocstringSignatureMixinz Mixin for FunctionDocumenter and MethodDocumenter to provide the feature of reading the signature from the docstring. N_new_docstrings _signaturesr3cCsJ|jdg}t|tr"|dt|jdr"|dd|jjD|}|dur,dS|dd|_ g|_ d}t |D]f\}}t |D]X\}}|sLnQ| drX| d }t|}|san<|\} } } } } | |vrpn-|jjjjj}td||d d|d |j |<|dur| | f}qD|j d | | fqD|r|Sq<|S) Nrrr6css|]}|jVqdSr4)rBrPr5r5r6 sz:DocstringSignatureMixin._find_signature..)NN\rrtabsizez (%s) -> %s)rr8ClassDocumenterrArwr`extendr6rrrrendswithrrrrrrrrrr&r)r> valid_namesrrrdoclinesjrrexmodrrrrrr5r5r6_find_signaturesF        z'DocstringSignatureMixin._find_signaturercs|jdur|jSt|Sr4)rrrr>rrr5r6rs  zDocstringSignatureMixin.get_docrc s\|jdur|jjr|}|dur|\|_|_tjdi|}|jr,d|g|jS|S)Nrr5) rrautodoc_docstring_signaturerrrrrr)r>rrrrr5r6rs z(DocstringSignatureMixin.format_signaturer4)rBrCrDrErr rr4rrrrrrrrrr5r5rr6rs  3rcs*eZdZdZdedeffdd ZZS)DocstringStripSignatureMixinzz Mixin for AttributeDocumenter to provide the feature of stripping any function signature from the docstring. rr3c s>|jdur|jjr|}|dur|\}|_tjdi|Sr)rrrrrrr)r>rr_argsrr5r6rs  z-DocstringStripSignatureMixin.format_signature)rBrCrDrErrrrr5r5rr6rsrc seZdZdZdZdZededede dede f d d Z d edefd d Z d de ddfddZ deddffdd Z d edeffdd ZdededefddZdededeefddZZS)!FunctionDocumenterz8 Specialized Documenter subclass for functions. functionrtrrrr3cCs(t|pt|pt|ot|tSr4)r$ isfunction isbuiltin isroutiner8rrr5r5r6rsz&FunctionDocumenter.can_document_memberrc Ks|jjdvr |ddz|jjd|jdtj|j|jj d}t |fi|}Wn't yG}zt td|j|WYd}~dSd}~wtyQd}Ynw|jjr\|dd }|S) Nnone descriptionshow_annotationF autodoc-before-process-signature type_aliases-Failed to get a function signature for %s: %srr\\)rautodoc_typehintsrwrr}rr`r$ signatureautodoc_type_aliasesr,rrrr!rrfstrip_signature_backslashr)r>rrrrr5r5r6rs$     zFunctionDocumenter.format_argsFrMNcCr@r4r5r>rMr5r5r6rd#r8z#FunctionDocumenter.document_membersrcs@|}t|t|jst|jr|d|dSdS)N :async:)r rrr$iscoroutinefunctionr`isasyncgenfunctionrrrr5r6r&s  z'FunctionDocumenter.add_directive_headerc  s6g}|jrd|j|jjvr|jjdkrd}nd}tjd i|}||t |j rZ|j j D]%\}}|t ur=q4|||}|rYt|jd}||_ dg|_||q4|rt j|j |jjd} t|j di} |jjd|jD]} || | } t| | |jj} t| fi|}||qxd|S) NrrTFrr __globals__rr5)rrr overloadsrrrrrAr$is_singledispatch_functionr`rr%annotate_to_first_argumentrrrrr+rsmerge_default_valuer(r,) r>rsigs overloadedrtypfunc dispatchfuncrcactualroverloadrr5r6r-s@        z#FunctionDocumenter.format_signaturerrcCZt|j}t|D]\}}|j|j}|r&|jdkr&|j|jd||<q |j|dSzGMerge default values of actual implementation to the overload variants.z...)default parametersr"rr1rrsrrrr>rrrrparam actual_paramr5r5r6rS z&FunctionDocumenter.merge_default_valuerrc Cz tj||jjd}Wn&ty(}zttd|j|WYd}~dSd}~wt y1YdSwt |j dkr;dSdd}t |j }|djtjuro|dj|d|d<z |j|d|_|WSttfynYdSwdS) ?Annotate type hint to the first argument of function if needed.rrNrcSr@r4r5r5r5r5r6dummykr8z.dummy annotationrr$rrrrrrr!rrfr rr"r1rremptyr __signature__rr>rrrrrparamsr5r5r6r]0  z-FunctionDocumenter.annotate_to_first_argumentr})rBrCrDrErr[rrrrFrrrdrrrrrrr rrr5r5rr6rs &" rcs2eZdZdZdZdZdedeffdd ZZS)DecoratorDocumenterzB Specialized Documenter subclass for decorator functions. decoratorrrr3c s"tjdi|}d|vr|SdS)NrQr5)rr)r>rrrr5r6rszDecoratorDocumenter.format_args) rBrCrDrErrTrrrr5r5rr6r{s rzenum.EnumMeta.__call__ztyping.Generic.__new__c seZdZUdZdZdZeeeeee e eee d Z e ed<dZeed<dZeed<d ed dffd d Zed edededed ef ddZd8ded effdd Zd eeeeeeeffddZded efddZded effdd Zd eefddZd eefd d!Z d"ed dffd#d$ Z!d%ed eee"ffd&d'Z#d9d(e$d eeeefd)d*Z%d eeefd+d,Z&d8d-ee'd.ed dffd/d0 Z(d8d1ed dffd2d3 Z)  d:d-ee'd4ed5ed1ed df fd6d7 Z*Z+S);rz6 Specialized Documenter subclass for classes. ri) rrrrrrrrrvrqclass-doc-fromrN_signature_class_signature_method_namerr3csjtj||jjdkr.|j|_|jjdur ddg|jd<n|jjd|jjdt|jdS)N separatedrrrq) rrrautodoc_class_signaturerprrArAryrrr5r6rs    zClassDocumenter.__init__rtrrrcCs t|tSr4)r8rrr5r5r6rs z#ClassDocumenter.can_document_memberFrcs>t|}|rt|jdr|jd|jjk|_|Sd|_|S)NrBrT)rrrwr`rrB doc_as_attrr>rrrr5r6rs  zClassDocumenter.import_objectcsdtdtdtffdd }tjdr!tjjtr!ddjjfS|tjd}|dur6d|t vr6d}|dur`j j d |d zt j|d jjd }tjd|fWSty_Ynw|jd }|dursd|tvrsd}|durj j d |d zt j|d jjd }jd |fWStyYnw|jd }|durɈj j d |d zt j|d jjd }jd |fWStyYnwj j d jdzt jjdjjd }dd|fWStyYdSw)Nrattrr3cs:t||rdS||d}t|st|sdS|S)zF Get the `attr` function or method from `obj`, if it is user-defined. N)r$is_builtin_class_methodrismethodr)rrrr5r6#get_user_defined_function_or_methods zKClassDocumenter._get_signature..get_user_defined_function_or_methodr__call__z{0.__module__}.{0.__qualname__}rT bound_methodrrrF)NNN)rrrwr`r8rrrformat_METACLASS_CALL_BLACKLISTrr}rr$rrrrf_CLASS_NEW_BLACKLIST)r>rcallrnewrjr5rr6_get_signaturesl         zClassDocumenter._get_signaturerc Ks|jjdvr |ddz |\|_|_}Wnty4}ztt d|j |WYd}~dSd}~ww|dur;dSt |fddi|S)NrrFz0Failed to get a constructor signature for %s: %sshow_return_annotation) rrrwrrrrrrr!rr,)r>rrrr5r5r6rs   zClassDocumenter.format_argsc  s|jrdS|jjdkr dSt}g}|}|r\|jjdkr\t|j|j d}t|di}|D]*}t |||jj }t |j }|j|ddtjd}t|fi|}||q0n||d|S)Nrrrrr)rreturn_annotationr)rrrrrget_overloaded_signaturesrr+rrr(rr"rr1rrrr,rAr) r>rrrrmethodrrrrr5r6r*s.     z ClassDocumenter.format_signaturec Cs|jrC|jrC|jjD]8}z-t|j}|d|j|jg}||j vr.|j |WS||j vr8gWSWq t yBYq wgS)Nr) rrr6r"rurCanalyzerrDrrsrmr#)r>rrqualnamer5r5r6rGs       z)ClassDocumenter.get_overloaded_signaturescCs^t|jd|j}t|jdd}|durt|jdd}|r"d|vr"d}|r-|r-d||gSdS)NrCrDrBzr)r+r`rr)r> __modname__rDr5r5r6get_canonical_fullnameXs z&ClassDocumenter.get_canonical_fullnamercs,|}|jr d|_t||jr#d|j|jjvr#| d|| }|js9|r9|j |kr9| d|||js|j j rt|jrMt|jj}nt|jdr`t|jjr`t|jj}ng}|jjd|j |j|j |dd|D}|}| d || d td d ||dSdSdS) N attributer :final:z :canonical: %s __bases__autodoc-process-basescSsg|]}t|qSr5)r/rPr5r5r6rOriz8ClassDocumenter.add_directive_header..rrz Bases: %s, )r rrrrrrrfinalsrr rrpshow_inheritancer$ getorigbasesr`r"__orig_bases__rwr r rrrr )r>rr canonical_fullnamebases base_classesrr5r6rfs.     "z$ClassDocumenter.add_directive_headerr)cstjjj}|s:jjsdgfSg}jjD]}||vr'|||qtjt d|j fddqd|fSjj rFdt | fSdfdd| DfS)NFr*rrcsg|] }|jjkr|qSr5)rr`r,rr5r6rOrPz6ClassDocumenter.get_object_members..)rr`rrrprrrArrr!rr0r"r1r2r5rr6rs"  z"ClassDocumenter.get_object_membersrc sP|jr |}|r gSdSt|dd}|dur|S|jd|jj}g}t|j|j }|r2| ||dvr| |jdd}t||j |jj |jd}|dur^|tj j ks\|tj j kr^d}|s| |jdd} t| |j |jj |jd}|dur|tjj ks|tjj krd}|r|dkr|g}n| ||jjjjjfdd|DS) Nrr)rhrjrrrjcsg|]}t|qSr5)r&)rNrrrr5r6rOr.z+ClassDocumenter.get_doc..)rget_variable_commentr rprsrautoclass_contentr)r`rrArrrErLrrrrrr) r>rcommentr classdoc_fromr attrdocstringr initdocstringrr5rr6rsN     zClassDocumenter.get_doccCsRzdd|jf}t|}|t|jj |gWSt y(YdSw)Nrr) rrr"rurrr"rr&rsr#)r>rxrr5r5r6rs z$ClassDocumenter.get_variable_commentrr csR|jr!|s!zttdt|jgdd}Wn ty Ynwt|dS)N alias of %sr)r) rrrr r/r`rrr(r>rr rr5r6r(s  zClassDocumenter.add_contentrMcs|jrdSt|dSr4)rrrdrrr5r6rdsz ClassDocumenter.document_membersrXrcstj|||dS)N)rrrM)rr^)r>rrXrrMrr5r6r^szClassDocumenter.generater}r4r~),rBrCrDrErr[rUrnrargr_rkrr-r4rrrrrrrFrrrr rrrrr rr rrrrrrrrr(rdr^rr5r5rr6rsR   $ N" 4  rc @s>eZdZdZdZdZdZedede de dede f d d Z d S) ExceptionDocumenterz> Specialized ClassDocumenter subclass for exceptions. exception rtrrrr3cCst|to t|tSr4)r8r issubclass BaseExceptionrr5r5r6rsz'ExceptionDocumenter.can_document_memberN) rBrCrDrErr[rTrrrrFrr5r5r5r6rsrc@seZdZUdZeed<dZeed<dZe ed<dZ e ed<dZ e ed<dZ ee ed<defd d Zdefd d Zd eddfddZdS)DataDocumenterMixinBaseNrrrrr`rr3cCr;)z,Check directive header should be suppressed.Fr5rr5r5r6 should_suppress_directive_header z8DataDocumenterMixinBase.should_suppress_directive_headercCr;)z*Check :value: header should be suppressed.Fr5rr5r5r6should_suppress_value_headerr&z4DataDocumenterMixinBase.should_suppress_value_headerrcCr;)z(Update docstring for the NewType object.Nr5r>rr5r5r6update_contentr&z&DataDocumenterMixinBase.update_content)rBrCrDrrr4rrrrrrr`rr rFr%r'rr)r5r5r5r6r$s     r$c<eZdZdZdeffdd Zdeddffdd ZZS) GenericAliasMixinzt Mixin for DataDocumenter and AttributeDocumenter to provide the feature for supporting GenericAliases. r3ct|jp tSr4)r$isgenericaliasr`rr%rrr5r6r% z2GenericAliasMixin.should_suppress_directive_headerrNcsBt|jr|tdt|jd|ddt|dSNrr)r$r-r`rAr r/rr)r(rr5r6r)#s  z GenericAliasMixin.update_content rBrCrDrErFr%rr)rr5r5rr6r+r+cr*) NewTypeMixinzn Mixin for DataDocumenter and AttributeDocumenter to provide the feature for supporting NewTypes. r3cr,r4)r$ isNewTyper`rr%rrr5r6r%1r.z-NewTypeMixin.should_suppress_directive_headerrNcsHt|jrt|jj}|td|d|ddt|dSr/) r$r3r`r/ __supertype__rAr rr))r>r supertyperr5r6r)5s   zNewTypeMixin.update_contentr0r5r5rr6r2+r1r2cs`eZdZdZdeffdd Zd dedeeee ffdd Z d e ddffd d Z Z S) TypeVarMixinzn Mixin for DataDocumenter and AttributeDocumenter to provide the feature for supporting TypeVars. r3cst|jtp tSr4)r8r`rrr%rrr5r6r%Dr.z-TypeVarMixin.should_suppress_directive_headerNrcsR|durtjd|jjtddt|jtr$|jjtjkr"t SgSt S)NrrVrW) r[r\rrBrr8r`rrErrrrr5r6rHs   zTypeVarMixin.get_docrcst|jtrOt|jjg}|jjD] }|t|q|jjr*|dt |jj|jj r3|d|jj r<|d|t dd |d|ddt|dS)Nzbound=\ zcovariant=Truezcontravariant=Truezalias of TypeVar(%s)rr)r8r`rreprrB__constraints__rAstringify_typehint __bound__r/ __covariant____contravariant__r rrr))r>rattrs constraintrr5r6r)Vs     zTypeVarMixin.update_contentr4)rBrCrDrErFr%rrr r rrrr)rr5r5rr6r6>s $r6cbeZdZdZd dedeffdd Zdeffdd Zdd edee e e ffd d Z Z S) UninitializedGlobalVariableMixinz Mixin for DataDocumenter to provide the feature for supporting uninitialized (type annotation only) global variables. Frr3c sztjddWSty|}zhzDt|jj4t|j|jj}t |d|jj }|j d|vrDt |_ ||_ WdWWYd}~dSWdn1sNwYWn ty]Ynw|ratj|jdddd|jWYd}~dSd}~ww) NTrrrrrrF)rrrrrrrrrr.rrUNINITIALIZED_ATTRr`rrrrrr)r>rrr annotationsrr5r6rns6  z.UninitializedGlobalVariableMixin.import_objectc|jtup tSr4r`rBrr'rrr5r6r' z=UninitializedGlobalVariableMixin.should_suppress_value_headerNrcs|jturgSt|Sr4r`rBrrrrr5r6r  z(UninitializedGlobalVariableMixin.get_docr}r4 rBrCrDrErFrr'rrr r rrrr5r5rr6r@hs ,r@c s8eZdZUdZdZdZdZeej Z e e d<e e d<e e d<eded ed ed ed ef d dZd ed dfddZd*ded effdd Zd effdd Zded dffdd Zd*ded dfddZd efddZd ed eeefd!d"Zd+d#ed eeeeffd$d% Zd*d&eed'ed dffd(d) ZZ S),DataDocumenterz9 Specialized Documenter subclass for data items. r$(irrno-valuertrrrr3cCst|to|Sr4)r8rrr5r5r6rz"DataDocumenter.can_document_memberNcCsttt|}||_z%t|j}||j D]\\}}}|dkr,||vr,|||<qWdSt y9YdSw)9Update __annotations__ to support type_comment and so on.rN) dictr$rr4r"rurrrCr%r#)r>rrCr classnameattrnamerr5r5r6update_annotationss  z!DataDocumenter.update_annotationsFrcs"t|}|jr||j|Sr4)rrrrRrrr5r6rs  zDataDocumenter.import_objectcs>trdS|}tdt|g\}}d|vrdSdSNTrz hide-valueFrr'rr'rrzr>rErrGrr5r6r's z+DataDocumenter.should_suppress_value_headerrct||}|jjtus|rdS|jjr&|d|jj|dS|jj dkrNt |j d|jj }|j d|vrNt||j d}|d||z|jjsW|rZWdSt|j}|d||WdStysYdSwNz :annotation: %srr :type: z :value: rrr rprrlr%rrrr.rrrr9rsno_valuer'r*r`rfr>rr rCobjreprrr5r6rs.    z#DataDocumenter.add_directive_headerrMcCr@r4r5rr5r5r6rdr8zDataDocumenter.document_memberscC ||jp|jdd}|p|jSNrCrrr`rr>rXr5r5r6r zDataDocumenter.get_real_modnamerQcCsRzt|j}|d|f}||jvrt|j|WSWdSty(YdSw)Nr)r"rurrr&r"r#)r>rQrrxr5r5r6get_module_comments   z!DataDocumenter.get_module_commentrcs&||jd}|r |gSt|S)Nr)rbrrr)r>rrrr5r6rs zDataDocumenter.get_docrr cs.d|_|st}||tj||ddS)N)r rrr)rr(rrr5r6r(s  zDataDocumenter.add_contentr}r4)!rBrCrDrErr[rTrOrrr-r4rmrnrrrrFrrRrr'rrdrr r rbrrrrr(rr5r5rr6rJs.   $ rJc @DeZdZdZdZdZejdZede de de de d e f d d Z d S) NewTypeDataDocumenterz Specialized Documenter subclass for NewTypes. Note: This must be invoked before FunctionDocumenter because NewType is a kind of function object. newtypedatar$rrtrrrr3cCst|o|Sr4)r$r3rr5r5r6rrMz)NewTypeDataDocumenter.can_document_memberN) rBrCrDrErrrrTrrrrFrr5r5r5r6re rec seZdZdZdZdZdZdZede de de de d e f d d Z d'd e d e ffdd Z de d e fddZde d dffdd Zd'de d dfddZde d e ffdd Zdeded efddZd ed!ed eefd"d#Zd(d$ed eeee ffd%d& ZZS))MethodDocumenterzQ Specialized Documenter subclass for methods (normal, static and class). r2rrtrrrr3cCst|o t|t Sr4)r$rr8rrr5r5r6rz$MethodDocumenter.can_document_memberFrcs`t|}|s |S|jj|j}|dur|j}t|s(tj ||j|jdr.|j d|_ |S)Nrrr) rrrr7rsrr`r$ isclassmethodisstaticmethodr[)r>rrrrr5r6r$s   zMethodDocumenter.import_objectrc Ks|jjdvr |ddzN|jtjkr|jtkrd}n>tj|j|j|jdr<|j j d|jdtj |jd|jj d}n|j j d|jdtj |jd|jj d}t|fi|}Wn'tyw}zttd |j|WYd}~dSd}~wtyd }Ynw|jjr|d d }|S) NrrFz()rkrrT+Failed to get a method signature for %s: %srrr)rrrwr`rrr$rmrrr}rrrr,rrrr!rrfrr)r>rrrrr5r5r6r5s8       zMethodDocumenter.format_argsrNcst||}|jj|j|j}t |r| d|t |s)t |r/| d|t |r:| d|tj||j|jdrJ| d||jr_d|j|jjvra| d|dSdSdS)N :abstractmethod:r :classmethod:rkz :staticmethod:rr )rrr rr7rsrr`r$isabstractmethodrrrrlrmrrrr)r>rr rrr5r6rVs       z%MethodDocumenter.add_directive_headerrMcCr@r4r5rr5r5r6rdfr8z!MethodDocumenter.document_membersc sg}|jrd|j|jjvr|jjdkrd}nd}tjd i|}|||j j |jd}t |rg|jjD])\}}|turFq=|||}|rft|jd} |j | _ || _dg| _|| q=|rt j|j|j |jdrt j|jd|jjd} n t j|jd|jjd} t|jd i} |jj d|jD]9} || | } t| | |jj} t j|j|j |jdst| j} | j| d dd } t | fi|}||qd |S)NrrTFrrrkrrrrrr5)!rrrrrrrrrArr7rsr$is_singledispatch_method dispatcherrr%r`rrhrrmrrrr+rr(r"rr1rr,)r>rrrrmethrr dispatchmethrcrrrrrr5r6risV           z!MethodDocumenter.format_signaturerrcCrrrrr5r5r6rrz$MethodDocumenter.merge_default_valuerrc Cr) rrrnNrcSr@r4r5r5r5r5r6rr8z:MethodDocumenter.annotate_to_first_argument..dummyrrrrr5r5r6rrz+MethodDocumenter.annotate_to_first_argumentrcs|jdur|jS|jddkrCt|j|j|jj|j|j}|dur1|tj j ks/| tj j kr1d}|rA|j j jjj}t||dgSgS|jddkr~t|j|j|jj|j|j}|durl|tjj ksj| tjj krld}|r||j j jjj}t||dgSgStS)Nrrrr)rrr)r`rrrrrrrErLrrrrrr&rrrrrr5r6rs:      zMethodDocumenter.get_docr}r4)rBrCrDrErrr[rTrrrrFrrrrrdrrrrrr rrrr rrr5r5rr6rhs$ !1 ,rhcr?)NonDataDescriptorMixina Mixin for AttributeDocumenter to provide the feature for supporting non data-descriptors. .. note:: This mix-in must be inherited after other mix-ins. Otherwise, docstring and :value: header will be suppressed unexpectedly. Frr3cs0t|}|rt|jsd|_|Sd|_|SNTF)rrr$isattributedescriptorr`non_data_descriptorrrr5r6rs z$NonDataDescriptorMixin.import_objectcst|dd p tSNryF)r rr%rrr5r6r'sz3NonDataDescriptorMixin.should_suppress_value_headerNrcst|ddrdSt|Srz)r rrrrr5r6rs  zNonDataDescriptorMixin.get_docr}r4rIr5r5rr6rvs  ,rvcseZdZdZdefddZddedeffdd Zdeffd d Zdd ede e e e ffd d Z e defddZZS) SlotsMixinzX Mixin for AttributeDocumenter to provide the feature for supporting __slots__. r3c CsDzt|j}|r|jd|vrWdSWdSttfy!YdSw)z/Check the subject is an attribute in __slots__.rTF)r$getslotsrrrfr)r> __slots__r5r5r6isslotsattribute s zSlotsMixin.isslotsattributeFrcst|}|r t|_|Sr4)rrr~ SLOTSATTRr`rrr5r6r s zSlotsMixin.import_objectcs|jturdStSr<)r`rrr'rrr5r6r' s  z'SlotsMixin.should_suppress_value_headerNrc s|jturHz t|j}|r#||jdr#t||jd}|gWSgWStyG}zt j t d|jj |fddgWYd}~Sd}~wwt |S)Nrz'Invalid __slots__ found on %s. Ignored.rr)r`rr$r|rrsrr&rfrrr!rDrr)r>rr}rrrr5r6r" s     zSlotsMixin.get_doccCstdt|jtur dSdS)Nz4AttributeDocumenter._datadescriptor() is deprecated.TF)r[r\rr`rrr5r5r6_datadescriptor2 s  zSlotsMixin._datadescriptorr}r4)rBrCrDrErFr~rr'rrr r rrrrrr5r5rr6r{ s $r{cseZdZdZeZdedefddZdedefddZ dd edeffd d Z deffd d Z dde de eeeffdd ZZS)RuntimeInstanceAttributeMixina1 Mixin for AttributeDocumenter to provide the feature for supporting runtime instance attributes (that are defined in __init__() methods with doc-comments). Example: class Foo: def __init__(self): self.attr = None #: This is a target of this mix-in. rr3cCs(|||jdr dS||rdSdS)z8Check the subject is an attribute defined in __init__().rTF)get_attribute_commentr+is_runtime_instance_attribute_not_commented)r>rr5r5r6is_runtime_instance_attributeJ s  z;RuntimeInstanceAttributeMixin.is_runtime_instance_attributec Cst|D]:}z-t|d}t|d}t|}||r3|jr3d||jdg}||jvr3WdSWqt t fy?YqwdS)zHCheck the subject is an attribute defined in __init__() without comment.rCrDrrTN) r$getmror+r"rurrrrmrr#)r>rrrrrrxr5r5r6rT s     zIRuntimeInstanceAttributeMixin.is_runtime_instance_attribute_not_commentedFrc sztjddWSty}zmzIt|jj9t|j|jddd|j|jj d}|d}| |rI|j |_ ||_ WdWWYd}~dSWdn1sSwYWn tybYnw|rftj|jdd d d |jWYd}~d Sd}~ww) z`Check the existence of runtime instance attribute after failing to import the attribute.TrANrrirrrrrF)rrrrrrrrrrrRUNTIME_INSTANCE_ATTRIBUTEr`rrrrrrr>rrrrrr5r6rf s8   z+RuntimeInstanceAttributeMixin.import_objectcs|j|jup tSr4)r`rrr'rrr5r6r' r.z:RuntimeInstanceAttributeMixin.should_suppress_value_headerNrcs(|j|jur||jrdSt|Sr4)r`rrrrrrrr5r6r s   z%RuntimeInstanceAttributeMixin.get_docr}r4)rBrCrDrEr`rrrFrrrr'rrr r rrrr5r5rr6r< s  ,rcsteZdZdZdedefddZddedeffdd Zdeffd d Zdd e de e e e ffdd Z ZS)#UninitializedInstanceAttributeMixinz Mixin for AttributeDocumenter to provide the feature for supporting uninitialized instance attributes (PEP-526 styled, annotation only attributes). Example: class Foo: attr: int #: This is a target of this mix-in. rr3cCs&t|d|jj}|jd|vrdSdS)z2Check the subject is an annotation only attribute.NrTF)r.rrr)r>rrCr5r5r6#is_uninitialized_instance_attribute szGUninitializedInstanceAttributeMixin.is_uninitialized_instance_attributeFrc sztjddWStyc}zOz+t|j|jddd|j|jjd}|d}||r:t |_ ||_ WWYd}~dSWn tyDYnw|rHt j |jdd d d |jWYd}~d Sd}~ww) eCheck the exisitence of uninitialized instance attribute when failed to import the attribute.TrANrrirrrrrrF)rrrrrrrrrrBr`rrrrrrrrr5r6r s0   z1UninitializedInstanceAttributeMixin.import_objectcrDr4rErrr5r6r' rFz@UninitializedInstanceAttributeMixin.should_suppress_value_headerNrcs|jturdSt|Sr4rGrrr5r6r rHz+UninitializedInstanceAttributeMixin.get_docr}r4)rBrCrDrErrFrrr'rrr r rrrr5r5rr6r s  ,rc s`eZdZUdZdZdZeejZe e d<e ed<e ed<dZ eded efd d Zed ed ededed ef ddZd/ded dfddZd efddZded dfddZd/ded effdd Zd efddZd effd d! Zd"ed dffd#d$ Zded%ed eeefd&d'Zd0d(ed eeeeffd)d* Z d/d+ee!d,ed dffd-d. Z"Z#S)1AttributeDocumenterz9 Specialized Documenter subclass for attributes. r <rrrLr!rr3cCst|pt|pt|Sr4)r$rrr)rr5r5r6is_function_or_method sz)AttributeDocumenter.is_function_or_methodrtrrrcCs4t|rdSt|tst|st|tsdSdSrw)r$rxr8rrrrr5r5r6r s  z'AttributeDocumenter.can_document_memberFrMNcCr@r4r5rr5r5r6rd r8z$AttributeDocumenter.document_membersc Cstdtt|jjPz5t|j|jddd|j |jj d}|d|_ t |j d|jj }|jd|vrAt|_WWddSWn tyKYn wWddSWddS1s_wYdS) z+Check the subject is an instance attribute.z8AttributeDocumenter.isinstanceattribute() is deprecated.NrrirrTF)r[r\rrrrrrrrrrr.rrBr`r)r>rrCr5r5r6isinstanceattribute s:    z'AttributeDocumenter.isinstanceattributec CszMtt|}||_t|D]:}z-t|d}t|d}t|}||j D]\\}}} ||kr=||vr=| ||<q+Wqt t fyJYqwWdSt t fyYYdSw)rNrCrDN)rOr$rr4rr+r"rurrCr%rr#r) r>rrCrrrrrPrQrr5r5r6rR s*    z&AttributeDocumenter.update_annotationsrcs8t|}t|jr|jj|_|jr||j|Sr4)rrr$isenumattributer`r+rrRrrr5r6r s    z!AttributeDocumenter.import_objectcCr]r^r_r`r5r5r6r raz$AttributeDocumenter.get_real_modnamecsBtrdS|}|rtdt|g\}}d|vrdSdSrSrTrUrr5r6r' s z0AttributeDocumenter.should_suppress_value_headerrcrVrWrYr[rr5r6r+ s*    z(AttributeDocumenter.add_directive_headerrQc Cst|D]:}z-t|d}t|d}t|}||r3|jr3||f}||jvr3t|j|WSWqt t fy?YqwdS)NrCrD) r$rr+r"rurrr&r"rr#)r>rrQrrrrrxr5r5r6rD s     z)AttributeDocumenter.get_attribute_commentrcsP||j|jd}|r|gSz|jj}d|j_t|W||j_S||j_w)NrF)rrrrrrr)r>rrorigrr5r6rU s zAttributeDocumenter.get_docrr cs0d|_|dur t}||t||dSr4rcrrr5r6r(e s  zAttributeDocumenter.add_contentr}r4)$rBrCrDrErr[rOrrr-r4rmrnrT staticmethodrrFrrrrrdrrRrrr'rr r rrrrrr(rr5r5rr6r s4     $rc seZdZdZdZdZejdZede de de de d e f d d Z dd e d e ffdd Z dde d dfddZd e fddZde d dffdd ZZS)PropertyDocumenterz9 Specialized Documenter subclass for properties. rrrrtrrrr3cCsJt|tr#t|r dSt|jdi}||}t|to"t|jSdS)NTr7F) r8rr$ ispropertyr+r`rsr__func__)rrtrrrr7rr5r5r6r{ s   z&PropertyDocumenter.can_document_memberFrcspt|}|r3t|js3t|jdi}||jd}t |t r1t|j r1|j |_d|_ dSdSd|_ |S)rr7rTF) rrr$rr`r+rrsrr8rrrl)r>rrr7rrr5r6r s z PropertyDocumenter.import_objectrMNcCr@r4r5rr5r5r6rd r8z#PropertyDocumenter.document_memberscCr]r^r_r`r5r5r6r raz#PropertyDocumenter.get_real_modnamerc st||}t|jr|d||jr|d|t|jddr+|jj }nt|jddr7|jj }nd}|r|j j dkrz"tj ||j jd}|jtjurat|j}|d||WdSWdSty}zttd|j|WYd}~dSd}~wtyYdSwdSdS) NrorpfgetrrrrXr)rrr r$rqr`rrlr+rrrrrrrrrr9rrrr!rrf)r>rr rrr\rrr5r6r s<          z'PropertyDocumenter.add_directive_headerr})rBrCrDrErr[rrTrrrrFrrrdrrrr5r5rr6rq s   rc @rd) NewTypeAttributeDocumenterz Specialized Documenter subclass for NewTypes. Note: This must be invoked before MethodDocumenter because NewType is a kind of function object. newvarattributer rrtrrrr3cCst|t o t|Sr4)r8rr$r3rr5r5r6r rjz.NewTypeAttributeDocumenter.can_document_memberN) rBrCrDrErrrhrTrrrrFrr5r5r5r6r rgrr}cCstjdtdd|jjS)rz get_documenters() is deprecated.rVrW)r[r\rrrr}r5r5r6get_documenters srrrrcGsH|jjD]\}}t||r|||g|RSqt||g|RS)zAlternative getattr() for types)rautodoc_attrgettrsr%r8r+)r}rrrrrr5r5r6r s  rrcCs&|jdkrttdd|_dSdS)N alphabeticzdautodoc_member_order now accepts "alphabetical" instead of "alphabetic". Please update your setting.rb)r\rrr!)r}rr5r5r6migrate_autodoc_member_order s  r)DataDeclarationDocumenter)GenericAliasDocumenter)InstanceAttributeDocumenter) SingledispatchFunctionDocumenter)SingledispatchMethodDocumenter)SlotsAttributeDocumenter)TypeVarDocumenterc Cs|t|t|t|t|t|t|t|t|t |t |t | dddt ddd| dddt ddd d | d d dt d d | did| ddd| dgd| dddt dddd| dddt dd| did| ddd| ddd|d|d|d|d|d|jd td!d"|d#|d$|d%tjdd&S)'NrriTrhrjr\rbrrcrdrmixedrautodoc_default_optionsrrrrrr$autodoc_typehints_description_targetall documentedrrrrrrr<r z config-initedi rSz$sphinx.ext.autodoc.preserve_defaultszsphinx.ext.autodoc.type_commentzsphinx.ext.autodoc.typehints)versionparallel_read_safe)add_autodocumenterrrrrJrerrrhrrradd_config_valuer add_eventconnectrsetup_extensionsphinx__display_version__rr5r5r6setup sL                         r)rN)NFF)rErr[r$rrtypesrtypingrrrrr r r r r rrrrdocutils.statemachinerrsphinx.applicationr sphinx.configrrsphinx.deprecationrrsphinx.environmentrsphinx.ext.autodoc.importerrrrrsphinx.ext.autodoc.mockrrr sphinx.localer r! sphinx.pycoder"r# sphinx.utilr%sphinx.util.docstringsr&r'sphinx.util.inspectr(r)r*r+r,sphinx.util.typingr-r.r/r0r9sphinx.ext.autodoc.directiver1 getLoggerrBrr__subclasses__MethodDescriptorTyperVERBOSErr@r7r9rGrRr^r`rBr=rrrUr]r_rargrkrlrmrFrnruryrrrrrOrtuplerrrrrrrrrrrrrrr$r+r2r6r@rJrerhrvr{rrrrrrrrsphinx.ext.autodoc.deprecatedrrrrrrrrr5r5r5r6s  <             & 5!Nz[*)sQ7P7/M