docs: def prepare_env(app, env, docname):
      """
      Prepares the sphinx environment to store sphinx-needs internal data.
      """
      if not hasattr(env, 'needs_all_needs'):
          # Used to store all needed information about all needs in document
          env.needs_all_needs = {}
  
      if not hasattr(env, 'needs_functions'):
          # Used to store all registered functions for supporting dynamic need values.
          env.needs_functions = {}
  
          # needs_functions = getattr(app.config, 'needs_functions', [])
          needs_functions = app.needs_functions
          if needs_functions is None:
              needs_functions = []
          if not isinstance(needs_functions, list):
              raise SphinxError('Config parameter needs_functions must be a list!')
  
          # Register built-in functions
          for need_common_func in needs_common_functions:
              register_func(env, need_common_func)
  
          # Register functions configured by user
          for needs_func in needs_functions:
              register_func(env, needs_func)
  
      app.config.needs_hide_options += ['hidden']
      app.config.needs_extra_options['hidden'] = directives.unchanged
  
      if not hasattr(env, 'needs_workflow'):
          # Used to store workflow status information for already executed tasks.
          # Some tasks like backlink_creation need be be performed only once.
          # But most sphinx-events get called several times (for each single document file), which would also
          # execute our code several times...
          env.needs_workflow = {
              'backlink_creation': False,
              'dynamic_values_resolved': False
          }