code: def modify_document(self, doc):
          ''' 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(docf modify_document(self, doc):
          ''' 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)
docs: 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.