code: def generate_doc_dict(module, user):
      from pale import extract_endpoints, extract_resources, is_pale_module
      if not is_pale_module(module):
          raise ValueError(
  )
      module_endpoints = extract_endpoints(module)
      ep_doc = { ep._route_name: document_endpoint(ep) for ep \
              in module_endpoints }
      ep_doc_filtered = {}
      for endpoint in ep_doc:
          if ep_doc[endpoint].get("requires_permission") != None and user != None and user.is_admin or \
              ep_doc[endpoint].get("requires_permission") == None:
              ep_doc_filtered[endpoint] = ep_doc[endpoint]
      module_resources = extract_resources(module)
      res_doc = { r._value_type: document_resource(r) for r \
              in module_resources }
      return {'endpoints': ep_doc_filtered,
              'resources': res_doc}