Ë Y²Lêk^»ãóÔ—dZddlZddlZddlZddlZddlmZddlm Z m Z m Z ddl m Z mZdZej e«Zd„Zd„Zd „Zd „Zd „Zd „Zigfd „Zigfd„Zd„Zd„Zd„Zd„Zy)a¹ Customizations for and integration with the Sphinx_ documentation generator. The :mod:`humanfriendly.sphinx` module uses the `Sphinx extension API`_ to customize the process of generating Sphinx based Python documentation. To explore the functionality this module offers its best to start reading from the :func:`setup()` function. .. _Sphinx: http://www.sphinx-doc.org/ .. _Sphinx extension API: http://sphinx-doc.org/extdev/appapi.html éN)Ú get_aliases)ÚcompactÚdedentÚformat)Ú USAGE_MARKERÚ render_usage) Údeprecation_note_callbackÚenable_deprecation_notesÚenable_man_roleÚenable_pypi_roleÚenable_special_methodsÚenable_usage_formattingÚloggerÚman_roleÚ pypi_roleÚsetupÚspecial_methods_callbackÚusage_message_callbackcó—t|tj«rè|råt|j«}|rÍt dj |««g}|jd«d}t|«dk(rd} nd} |j|t| «z«|j«D]@\}} |jtd||««|jtd|d z| ««ŒBt|d j |««y y y y ) aZ Automatically document aliases defined using :func:`~humanfriendly.deprecation.define_aliases()`. Refer to :func:`enable_deprecation_notes()` to enable the use of this function (you probably don't want to call :func:`deprecation_note_callback()` directly). This function implements a callback for ``autodoc-process-docstring`` that reformats module docstrings to append an overview of aliases defined by the module. The parameters expected by this function are those defined for Sphinx event callback functions (i.e. I'm not going to document them here :-). Ú z.. note:: Deprecated namesz éa+ The following alias exists to preserve backwards compatibility, however a :exc:`~exceptions.DeprecationWarning` is triggered when it is accessed, because this alias will be removed in a future release. a2 The following aliases exist to preserve backwards compatibility, however a :exc:`~exceptions.DeprecationWarning` is triggered when they are accessed, because these aliases will be removed in a future release. z%s.. data:: %sz%sAlias for :obj:`%s`.éz N) Ú isinstanceÚtypesÚ ModuleTyperÚ__name__rÚjoinÚappendÚlenrÚitemsrÚ update_lines) ÚappÚwhatÚnameÚobjÚoptionsÚlinesÚaliasesÚblocksÚindentÚ explanationÚtargets ú9/usr/lib/python3.12/site-packages/humanfriendly/sphinx.pyr r 4së€ô�#”u×'Ñ'Ô(©UܘcŸl™lÓ+ˆÙ ô ˜TŸY™Y uÓ-Ó.Ð/ˆFð �M‰MÐ6Ô 7؈FÜ�7‹|˜qÒ ð‘ ð� ð �M‰M˜&¤7¨;Ó#7Ñ7Ô 8Ø '§ ¡ ¦‘ ��fØ— ‘ œfÐ%5°v¸tÓDÔEØ— ‘ œfÐ%=¸vȹzÈ6ÓRÕSð!0ô ˜ § ¡ ¨FÓ 3Õ 4ð; ð.3Ð(ócó0—|jdt«y)aK Enable documenting backwards compatibility aliases using the autodoc_ extension. :param app: The Sphinx application object. This function connects the :func:`deprecation_note_callback()` function to ``autodoc-process-docstring`` events. .. _autodoc: http://www.sphinx-doc.org/en/stable/ext/autodoc.html úautodoc-process-docstringN)Úconnectr ©r"s r-r r es€ð‡K�KÐ+Ô-FÕGr.có0—|jdt«y)zÜ Enable the ``:man:`` role for linking to Debian Linux manual pages. :param app: The Sphinx application object. This function registers the :func:`man_role()` function to handle the ``:man:`` role. ÚmanN)Úadd_rolerr2s r-r r ss€ð‡L�L�œÕ!r.có0—|jdt«y)zÞ Enable the ``:pypi:`` role for linking to the Python Package Index. :param app: The Sphinx application object. This function registers the :func:`pypi_role()` function to handle the ``:pypi:`` role. ÚpypiN)r5rr2s r-r r s€ð‡L�L�œÕ#r.có0—|jdt«y)a6 Enable documenting "special methods" using the autodoc_ extension. :param app: The Sphinx application object. This function connects the :func:`special_methods_callback()` function to ``autodoc-skip-member`` events. .. _autodoc: http://www.sphinx-doc.org/en/stable/ext/autodoc.html zautodoc-skip-memberN)r1rr2s r-r r ‹s€ð‡K�KÐ%Ô'?Õ@r.có0—|jdt«y)aQ Reformat human friendly usage messages to reStructuredText_. :param app: The Sphinx application object (as given to ``setup()``). This function connects the :func:`usage_message_callback()` function to ``autodoc-process-docstring`` events. .. _reStructuredText: https://en.wikipedia.org/wiki/ReStructuredText r0N)r1rr2s r-rr™s€ð‡K�KÐ+Ô-CÕDr.có–—d|z}tjj|tjj |«fd|i|¤Ž}|ggfS)aï Convert a Linux manual topic to a hyperlink. Using the ``:man:`` role is very simple, here's an example: .. code-block:: rst See the :man:`python` documentation. This results in the following: See the :man:`python` documentation. As the example shows you can use the role inline, embedded in sentences of text. In the generated documentation the ``:man:`` text is omitted and a hyperlink pointing to the Debian Linux manual pages is emitted. zhttps://manpages.debian.org/%sÚrefuri©ÚdocutilsÚnodesÚ referenceÚutilsÚunescape) ÚroleÚrawtextÚtextÚlinenoÚinlinerr&ÚcontentÚman_urlr?s r-rr§sK€ð$/°Ñ5€GÜ—‘×(Ñ(¨´(·.±.×2IÑ2IÈ$Ó2OÑkÐX_ÐkÐcjÑk€IØ ˆ;˜ˆ?Ðr.có–—d|z}tjj|tjj |«fd|i|¤Ž}|ggfS)aô Generate hyperlinks to the Python Package Index. Using the ``:pypi:`` role is very simple, here's an example: .. code-block:: rst See the :pypi:`humanfriendly` package. This results in the following: See the :pypi:`humanfriendly` package. As the example shows you can use the role inline, embedded in sentences of text. In the generated documentation the ``:pypi:`` text is omitted and a hyperlink pointing to the Python Package Index is emitted. zhttps://pypi.org/project/%s/r;r<) rBrCrDrErFr&rGÚpypi_urlr?s r-rr¾sK€ð$.°Ñ4€HÜ—‘×(Ñ(¨´(·.±.×2IÑ2IÈ$Ó2OÑlÐX`ÐlÐdkÑl€IØ ˆ;˜ˆ?Ðr.có˜—ddlm}t|«t|«t |«t |«t |«tdd|¬«S)a¢ Enable all of the provided Sphinx_ customizations. :param app: The Sphinx application object. The :func:`setup()` function makes it easy to enable all of the Sphinx customizations provided by the :mod:`humanfriendly.sphinx` module with the least amount of code. All you need to do is to add the module name to the ``extensions`` variable in your ``conf.py`` file: .. code-block:: python # Sphinx extension module names. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'humanfriendly.sphinx', ] When Sphinx sees the :mod:`humanfriendly.sphinx` name it will import the module and call its :func:`setup()` function. This function will then call the following: - :func:`enable_deprecation_notes()` - :func:`enable_man_role()` - :func:`enable_pypi_role()` - :func:`enable_special_methods()` - :func:`enable_usage_formatting()` Of course more functionality may be added at a later stage. If you don't like that idea you may be better of calling the individual functions from your own ``setup()`` function. r)Ú __version__T)Úparallel_read_safeÚparallel_write_safeÚversion)Ú humanfriendlyrLr r r r rÚdict)r"rLs r-rrÕs?€õF*ä˜SÔ!Ü�CÔÜ�SÔܘ3ÔܘCÔ ä  4¸TÈ;Ô WÐWr.cóv—t|dd«r+t|tjtjf«ry|S)a’ Enable documenting "special methods" using the autodoc_ extension. Refer to :func:`enable_special_methods()` to enable the use of this function (you probably don't want to call :func:`special_methods_callback()` directly). This function implements a callback for ``autodoc-skip-member`` events to include documented "special methods" (method names with two leading and two trailing underscores) in your documentation. The result is similar to the use of the ``special-members`` flag with one big difference: Special methods are included but other types of members are ignored. This means that attributes like ``__weakref__`` will always be ignored (this was my main annoyance with the ``special-members`` flag). The parameters expected by this function are those defined for Sphinx event callback functions (i.e. I'm not going to document them here :-). Ú__doc__NF)ÚgetattrrrÚ FunctionTypeÚ MethodType)r"r#r$r%Úskipr&s r-rrs2€ô&ˆs�I˜tÔ$¬°C¼%×:LÑ:LÌe×N^ÑN^Ð9_Ô)`Øàˆ r.cól—|r|j«|rŒ|j|j««y)z;Private helper for ``autodoc-process-docstring`` callbacks.N)ÚpopÚextendÚ splitlines)r'rDs r-r!r!s&€á Ø � ‰ Œ ò à ‡L�L�—‘Ó"Õ#r.có¾—t|tj«rC|r@|djt«r't dj |««}t||«yyyy)aë Reformat human friendly usage messages to reStructuredText_. Refer to :func:`enable_usage_formatting()` to enable the use of this function (you probably don't want to call :func:`usage_message_callback()` directly). This function implements a callback for ``autodoc-process-docstring`` that reformats module docstrings using :func:`.render_usage()` so that Sphinx doesn't mangle usage messages that were written to be human readable instead of machine readable. Only module docstrings whose first line starts with :data:`.USAGE_MARKER` are reformatted. The parameters expected by this function are those defined for Sphinx event callback functions (i.e. I'm not going to document them here :-). rrN)rrrÚ startswithrrrr!)r"r#r$r%r&r'rDs r-rr#sR€ô$�#”u×'Ñ'Ô(©Uà �‰8× Ñ œ|Ô ,ä § ¡ ¨%Ó 0Ó1ˆDä ˜ Õ %ð -ð.3Ð(r.)rSÚloggingrÚdocutils.nodesr=Údocutils.utilsÚhumanfriendly.deprecationrÚhumanfriendly.textrrrÚhumanfriendly.usagerrÚ__all__Ú getLoggerrrr r r r r rrrrrr!r©r.r-Úrgs“ðñ óÛ óÛõ2ß6Ñ6ß:ð €ð ˆ× Ñ ˜8Ó $€ò.5òb Hò "ò $ò Aò Eð<>Àróð.=?Èóò.+Xò\ò2$ó&r.