
    h?                     |    d 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y)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.
    )	signature)nodes)
PyFunction)FunctionDocumenter)BaseTaskc                   H     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                 >    t        |t              xr t        |d      S )N__wrapped__
isinstancer   getattr)clsmember
membernameisattrparents        Q/var/www/Befach/backend/env/lib/python3.12/site-packages/celery/contrib/sphinx.pycan_document_memberz"TaskDocumenter.can_document_member0   s    &(+N0NN    c                    t        | j                  dd       }|ht        |      }d|j                  v sd|j                  v r6|j	                  t        |j                  j                               dd        }t        |      S y)Nr   selfr      )
parameters )r   objectr   r   replacelistvaluesstr)r   wrappedsigs      r   format_argszTaskDocumenter.format_args4   sp    $++}d;G$C'5CNN+BkkT#..2G2G2I-J12-NkOs8Or   c                      y N )r   all_memberss     r   document_memberszTaskDocumenter.document_members=   s    r   c                     t        | j                  dd       }|rt        |d      | j                  k(  ryt        |          S )Nr   
__module__T)r   r   modnamesupercheck_module)r   r#   	__class__s     r   r/   zTaskDocumenter.check_module@   s=    
 $++}d;ww5Ew#%%r   )F)__name__r,   __qualname____doc__objtypemember_orderclassmethodr   r%   r*   r/   __classcell__)r0   s   @r   r	   r	   *   s8    $GLO O& &r   r	   c                       e Zd ZdZd Zy)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_prefixN   s"    

488??==>??r   N)r1   r,   r2   r3   r?   r(   r   r   r9   r9   K   s     @r   r9   c                 B    t        |t              rt        |d      r|ryy)z&Handler for autodoc-skip-member event.r   FNr   )appwhatnameobjskipoptionss         r   autodoc_skip_member_handlerrG   R   s      #x WS-%@r   c                     | j                  d       | j                  t               | j                  ddt               | j                  ddd       | j                  dt               ddiS )	zSetup Sphinx extension.zsphinx.ext.autodocpyr
   r>   z(task)Tzautodoc-skip-memberparallel_read_safe)setup_extensionadd_autodocumenterr	   add_directive_to_domainr9   add_config_valueconnectrG   )rA   s    r   setuprP   _   se    ,->*fm<-x>KK%'BC 	d r   N)r3   inspectr   docutilsr   sphinx.domains.pythonr   sphinx.ext.autodocr   celery.app.taskr   r	   r9   rG   rP   r(   r   r   <module>rV      sB   @   , 1 $&' &B@J @

r   