
    -er                    0   d Z ddlmZ ddlZ ej        e          ZddlZddl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 dd	lmZmZmZ dd
lmZ ddlmZ ddlmZ ddlmZm Z  ddl!m"Z" dZ# G d de          Z$d Z% G d de          Z&ddZ'dS )aW   Thoroughly document Bokeh model classes.

The ``bokeh-model`` directive will automatically document all the attributes
(including Bokeh properties) of a Bokeh Model subclass. A JSON prototype showing
all the possible JSON fields will also be generated.

This directive takes the name of a Bokeh model class as an argument and its
module as an option:

.. code-block:: rest

    .. bokeh-model:: Foo
        :module: bokeh.sphinxext.sample

Examples
--------

For the following definition of ``bokeh.sphinxext.sample.Foo``:

.. code-block:: python

    class Foo(Model):
        ''' This is a Foo model. '''
        index = Either(Auto, Enum('abc', 'def', 'xzy'), help="doc for index")
        value = Tuple(Float, Float, help="doc for value")

usage yields the output:

    .. bokeh-model:: Foo
        :module: bokeh.sphinxext.sample

The ``bokeh-model`` direction may be used explicitly, but it can also be used
in conjunction with the :ref:`bokeh.sphinxext.bokeh_autodoc` extension.

To enable this extension, add `"bokeh.sphinxext.bokeh_model"` to the
extensions list in your Sphinx configuration module.

    )annotationsN)getenv)Any)	unchanged)SphinxError)	Undefined)AnyRep
Serializer	SymbolRep)Model)BokehDeprecationWarning   )PARALLEL_SAFE)BokehDirective	py_sig_re)MODEL_DETAIL)BokehModelDirectivesetupc                  .    e Zd ZdZdZdZdZeedZd Z	dS )r   Tr   r   )module	canonicalc                   d                     | j                  }t          j        |          }|t	          d|          |                                \  }}}}t          d          dk    r,|                     | ddt          |          z   dd          S | j	        d         }	 t          j        |          }n## t          $ r t	          d	| d
|           w xY wt          ||d           }	|	t	          d| d|           t          |	t                    st	          d| d          t!          j                    5  t!          j        dt&                      |	            }
d d d            n# 1 swxY w Y   t)          j        t-          |
          ddd          }|                    d          rdn|}t1          j        |||          }|                     |d          S )N z+Unable to parse signature for bokeh-model: BOKEH_SPHINX_QUICK1
-z<bokeh-model>r   z,Unable to generate model reference docs for z, couldn't import module z6Unable to generate model reference docs: no model for z in module z)Unable to generate model reference docs: z, is not a subclass of Modelignore)categoryT   )z, z: )	sort_keysindent
separatorszbokeh.models)namemodule_name
model_json)join	argumentsr   matchr   groupsr   parselenoptions	importlibimport_moduleImportErrorgetattr
issubclassr   warningscatch_warningsfilterwarningsr   jsondumpsto_json_rep
startswithr   render)selfsigmname_prefix
model_namearglistretannr%   r   model	model_objr&   adjusted_module_namerst_texts                 ;lib/python3.11/site-packages/bokeh/sphinxext/bokeh_model.pyrunzBokehModelDirective.runn   sm   hht~&&OC  9SCSSTTT3488::0Z&&''3..::FFs3z??/BFFFXXXl8,	A,[99FF 	A 	A 	AZr}  A  A  A	A 
D11={Wa{{ny{{|||%'' 	tr*rrrsss
 $&& 	  	 #H7NOOOOI	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  ZI 6 6$q]ijjj
 2=1G1G1W1Wh~~]h&,!
 
 
 zz(O444s   )B> > C&E66E:=E:N)
__name__
__module____qualname__has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacer   option_specrG        rF   r   r   c   sL        K $ K
,5 ,5 ,5 ,5 ,5rQ   r   c                H    |                      ddt                     t          S )z+ Required Sphinx extension setup function. pyzbokeh-model)add_directive_to_domainr   r   )apps    rF   r   r      s!    m5HIIIrQ   c                        e Zd Zd fdZ xZS )DocsSerializerobjr   returnr	   c                z    |t           u rt          dd          S t                                          |          S )Nsymbolunset)typer$   )r   r   super_encode)r;   rX   	__class__s     rF   r_   zDocsSerializer._encode   s7    )(999977??3'''rQ   )rX   r   rY   r	   )rH   rI   rJ   r_   __classcell__)r`   s   @rF   rW   rW      s=        ( ( ( ( ( ( ( ( ( (rQ   rW   rX   r   rY   dict[str, AnyRep]c                    t                      |                     dd          }fd|                                D             }t          dd| j        i|S )NT)include_defaultsinclude_undefinedc                B    i | ]\  }}|                     |          S rP   )encode).0keyval
serializers      rF   
<dictcomp>zto_json_rep.<locals>.<dictcomp>   s-    QQQ(#s#z((--QQQrQ   idrP   )rW   properties_with_valuesitemsdictrm   )rX   
properties
attributesrk   s      @rF   r8   r8      sg    !!J++TUY+ZZJQQQQj>N>N>P>PQQQJ((36(Z(((rQ   )rX   r   rY   rb   )(__doc__
__future__r   logging	getLoggerrH   logr.   r6   r3   osr   typingr   docutils.parsers.rst.directivesr   sphinx.errorsr   bokeh.core.property.singletonsr   bokeh.core.serializationr	   r
   r   bokeh.modelr   bokeh.util.warningsr    r   bokeh_directiver   r   	templatesr   __all__r   r   rW   r8   rP   rQ   rF   <module>r      s  % %T # " " " " " g!!                   6 5 5 5 5 5 % % % % % % 5 4 4 4 4 4 B B B B B B B B B B       7 7 7 7 7 7       6 6 6 6 6 6 6 6 # # # # # #75 75 75 75 75. 75 75 75t  ( ( ( ( (Z ( ( () ) ) ) ) )rQ   