class_docstr: Load an application directory which modifies a Document.
      
class_docstr_tok: ["Load","an","application","directory","which","modifies","a","Document","."]
docstr: Execute the configured ``main.py`` or ``main.ipynb`` to modify the
  document.
  
  This method will also search the app directory for any theme or
  template files, and automatically configure the document with them
  if they are found.
docstr_tok: ["Execute","the","configured","``","main.py","``","or","``","main.ipynb","``","to","modify","the","document",".","This","method","will","also","search","the","app","directory","for","any","theme","or","template","files",",","and","automatically","configure","the","document","with","them","if","they","are","found","."]
code: def modify_document(self, doc: Document) -> None:
      """Execute the configured ``main.py`` or ``main.ipynb`` to modify the
      document.
  
      This method will also search the app directory for any theme or
      template files, and automatically configure the document with them
      if they are found.
  
      """
      if self._lifecycle_handler.failed:
          return
      # Note: we do NOT copy self._theme, which assumes the Theme
      # class is immutable (has no setters)
      if self._theme is not None:
          doc.theme = self._theme
  
      if self._template is not None:
          doc.template = self._template
  
      # This internal handler should never add a template
      self._main_handler.modify_document(doc)
  
imports: from __future__ import annotations
  import logging
  import sys
  from os.path import basename, dirname, exists, join
  from types import ModuleType
  from typing import TYPE_CHECKING, Any, Coroutine
  from jinja2 import Environment, FileSystemLoader, Template
  from ...core.types import PathLike
  from ...document import Document
  from ..application import ServerContext, SessionContext
  from .code_runner import CodeRunner
  from .handler import Handler
  from .notebook import NotebookHandler
  from .script import ScriptHandler
  from .server_lifecycle import ServerLifecycleHandler
  from .server_request_handler import ServerRequestHandler
label_desc: Use image node_id 6 for calling the DirectoryHandler obj's underlying member method code with example usage: obj.modify_document(doc) without return types