o
    Df?                     @   st   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 deZG d	d
 d
eZdd Zd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.
    )	signature)nodes)
PyFunction)FunctionDocumenter)BaseTaskc                       sF   e Zd ZdZdZdZedd Zdd Zdd	d
Z	 fddZ
  ZS )TaskDocumenterzDocument task definitions.task   c                 C   s   t |to	t|dS )N__wrapped__
isinstancer   getattr)clsmember
membernameisattrparent r   N/home/ubuntu/webapp/venv/lib/python3.10/site-packages/celery/contrib/sphinx.pycan_document_member0   s   z"TaskDocumenter.can_document_memberc                 C   s\   t | jdd }|d ur,t|}d|jv sd|jv r(|jt|j dd  d}t|S dS )Nr
   selfr      )
parameters )r   objectr   r   replacelistvaluesstr)r   wrappedsigr   r   r   format_args4   s   zTaskDocumenter.format_argsFc                 C   s   d S Nr   )r   all_membersr   r   r   document_members=   s   zTaskDocumenter.document_membersc                    s0   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__r   r   r(   @   s   
zTaskDocumenter.check_module)F)__name__r%   __qualname____doc__objtypemember_orderclassmethodr   r!   r$   r(   __classcell__r   r   r)   r   r   *   s    

	r   c                   @   s   e Zd ZdZdd ZdS )TaskDirectivezSphinx task directive.c                 C   s   t | jjjgS r"   )r   Textenvconfigcelery_task_prefix)r   r    r   r   r   get_signature_prefixN   s   z"TaskDirective.get_signature_prefixN)r+   r%   r,   r-   r7   r   r   r   r   r2   K   s    r2   c                 C   s    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optionsr   r   r   autodoc_skip_member_handlerR   s   r>   c                 C   sD   |  d | t | ddt | ddd | dt ddiS )	zSetup Sphinx extension.zsphinx.ext.autodocpyr   r6   z(task)Tzautodoc-skip-memberparallel_read_safe)setup_extensionadd_autodocumenterr   add_directive_to_domainr2   add_config_valueconnectr>   )r8   r   r   r   setup_   s   

rF   N)r-   inspectr   docutilsr   sphinx.domains.pythonr   sphinx.ext.autodocr   celery.app.taskr   r   r2   r>   rF   r   r   r   r   <module>   s     !