class_docstr: A Handler that accepts a plain python function to use for modifying
  Bokeh Documents.
  
  For example, the following code configures a handler with a function that
  adds an empty plot to a Document:
  
  .. code-block:: python
  
      def add_empty_plot(doc: Document):
          p = figure(x_range=(0, 10), y_range=(0, 10))
          doc.add_root(p)
          return doc
  
      handler = FunctionHandler(add_empty_plot)
  
  This handler could be configured on an Application, and the Application
  would run this function every time a new session is created.
docstr: Args:
      func (callable) : a function to modify and return a Bokeh Document.
          The function should have the form:
  
          .. code-block:: python
  
              def func(doc: Document):
                  # modify doc
                  return doc
  
          and it  should return the passed-in document after making any
          modifications in-place.
  
      trap_exceptions (bool) : should exceptions in `func` be caught and
          logged or allowed to propagate
docstr_tok: ["Args",":","func","(","callable",")",":","a","function","to","modify","and","return","a","Bokeh","Document",".","The","function","should","have","the","form",":","..","code-block",":",":","python","def","func","(","doc",":","Document",")",":","#","modify","doc","return","doc","and","it","should","return","the","passed-in","document","after","making","any","modifications","in-place",".","trap_exceptions","(","bool",")",":","should","exceptions","in","`","func","`","be","caught","and","logged","or","allowed","to","propagate"]
code: def __init__(
      self, func: ModifyDoc, *, trap_exceptions: bool = False
  ) -> None:
      """
  
      Args:
          func (callable) : a function to modify and return a Bokeh Document.
              The function should have the form:
  
              .. code-block:: python
  
                  def func(doc: Document):
                      # modify doc
                      return doc
  
              and it  should return the passed-in document after making any
              modifications in-place.
  
          trap_exceptions (bool) : should exceptions in `func` be caught and
              logged or allowed to propagate
  
      """
      super().__init__()
  
      _check_callback(func, ("doc",))
  
      self._func = func
      self._trap_exceptions = trap_exceptions
      self._safe_to_fork = True
  
file_path: bokeh/src/bokeh/application/handlers/function.py
imports: from __future__ import annotations
  import logging
  from typing import Callable
  from ...document import Document
  from ...util.callback_manager import _check_callback
  from .handler import Handler, handle_exception
label_desc: Use image node_id 1 to create a new FunctionHandler object from inherited base classes: Handler with example: obj = FunctionHandler(func)