
    leJi                         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dl
mZ  G d d	e	          Z G d
 de          Zd Zd ZdS )a;  Sphinx documentation plugin used to document tasks.

Introduction
============

Usage
-----

The Celery extension for Sphinx requires Sphinx 2.0 or later.

Add the extension to your :file:`docs/conf.py` configuration module:

.. code-block:: python

    extensions = (...,
                  'celery.contrib.sphinx')

If you'd like to change the prefix for tasks in reference documentation
then you can change the ``celery_task_prefix`` configuration value:

.. code-block:: python

    celery_task_prefix = '(task)'  # < default

With the extension installed `autodoc` will automatically find
task decorated objects (e.g. when using the automodule directive)
and generate the correct (as well as add a ``(task)`` prefix),
and you can also refer to the tasks using `:task:proj.tasks.add`
syntax.

Use ``.. autotask::`` to alternatively manually document a task.

Sphinx 9.0+ Compatibility
-------------------------

Sphinx 9.0 introduced a rewritten autodoc implementation. The Celery
extension requires the legacy class-based autodoc mode to function
correctly. When using Sphinx 9.0 or later, add the following to your
:file:`conf.py`:

.. code-block:: python

    autodoc_use_legacy_class_based = True

The extension will automatically enable this setting if not configured,
but it is recommended to set it explicitly to avoid warnings.
    N)	signature)nodes)
PyFunction)FunctionDocumenter)BaseTaskc                   N     e Zd ZdZdZdZed             Zd Zd	dZ	 fdZ
 xZS )
TaskDocumenterzDocument task definitions.task   c                 L    t          |t                    ot          |d          S )N__wrapped__
isinstancer   getattr)clsmember
membernameisattrparents        [/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/celery/contrib/sphinx.pycan_document_memberz"TaskDocumenter.can_document_member@   s!    &(++N0N0NN    c                    t          | j        dd           }|rt          |          }d|j        v s	d|j        v rB|                    t          |j                                                  dd                    }t          |          S dS )Nr   selfr      )
parameters )r   objectr   r   replacelistvaluesstr)r   wrappedsigs      r   format_argszTaskDocumenter.format_argsD   s    $+}d;;G$$C''5CN+B+BkkT#.2G2G2I2I-J-J122-NkOOs88Orr   Fc                     d S N )r   all_memberss     r   document_memberszTaskDocumenter.document_membersM   s    r   c                     t          | j        dd           }|rt          |d          | j        k    rdS t                                                      S )Nr   
__module__T)r   r   modnamesupercheck_module)r   r#   	__class__s     r   r/   zTaskDocumenter.check_moduleP   sQ    
 $+}d;; 	ww55EE4ww##%%%r   )F)__name__r,   __qualname____doc__objtypemember_orderclassmethodr   r%   r*   r/   __classcell__)r0   s   @r   r	   r	   :   s        $$GLO O [O     & & & & & & & & &r   r	   c                       e Zd ZdZd ZdS )TaskDirectivezSphinx task directive.c                 J    t          j        | j        j        j                  gS r'   )r   Textenvconfigcelery_task_prefix)r   r$   s     r   get_signature_prefixz"TaskDirective.get_signature_prefix^   s    
48?=>>??r   N)r1   r,   r2   r3   r?   r(   r   r   r9   r9   [   s.          @ @ @ @ @r   r9   c                 X    t          |t                    rt          |d          r|rdS dS )z&Handler for autodoc-skip-member event.r   FNr   )appwhatnameobjskipoptionss         r   autodoc_skip_member_handlerrG   b   s9     #x   WS-%@%@  	54r   c                    ddl }|                     d           t          d |j                            d          dd         D                       }|dk    r>t          | j        dd	          s(t          j        d
t          d           d| j        _
        |                     t                     |                     ddt                     |                     ddd           |                     dt"                     ddiS )zSetup Sphinx extension.r   Nzsphinx.ext.autodocc              3   4   K   | ]}t          |          V  d S r'   )int).0xs     r   	<genexpr>zsetup.<locals>.<genexpr>w   s(      MMa3q66MMMMMMr   .   )	   r   autodoc_use_legacy_class_basedFzSphinx 9.0+ detected. celery.contrib.sphinx requires 'autodoc_use_legacy_class_based = True' in conf.py. Enabling it automatically.)
stacklevelTpyr
   r>   z(task)zautodoc-skip-memberparallel_read_safe)sphinxsetup_extensiontuple__version__splitr   r=   warningswarnUserWarningrQ   add_autodocumenterr	   add_directive_to_domainr9   add_config_valueconnectrG   )rA   rU   sphinx_versions      r   setuprb   o   s   MMM,--- MM6+=+C+CC+H+H!+LMMMMMNsz#CUKK 	=M-     9=CJ5>***fm<<<-x>>>KK%'BCCC 	d r   )r3   rZ   inspectr   docutilsr   sphinx.domains.pythonr   sphinx.ext.autodocr   celery.app.taskr   r	   r9   rG   rb   r(   r   r   <module>rh      s   . .^              , , , , , , 1 1 1 1 1 1 $ $ $ $ $ $& & & & &' & & &B@ @ @ @ @J @ @ @
 
 
    r   